-
Notifications
You must be signed in to change notification settings - Fork 166
[GTK] Initialize text-antialias when initializing GC object #1839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GTK] Initialize text-antialias when initializing GC object #1839
Conversation
@HeikoKlare This is the problem I mentioned in #1757. I genuinely believe that this is an issue in Cairo, given that it only happens on some platforms. The only workarounds I found to fix this change is by either reverting your changes to the Image class or by explicitly calling |
ca235b7
to
ed5ebc6
Compare
Sorry, I saw this one after writing a comment to the other PR. Please see #1835 (comment) |
ed5ebc6
to
9537dda
Compare
@HeikoKlare I investigated this problem further on my Ubuntu VM and I believe the cleanest solution is to explicitly call |
Sorry for the late response. From what you explained it might be necessary to explicitly set text antialiasing as proposed, but that should probably not happen in GC directly (so that it affects every GC) but rather in the GC creation specific for image (i.e., in Anyway, I think there is quite some risk in such a change, so we should properly test it throughout a release cycle. Thus, I would be in favor of merging your orignal change (reverting the change to the Image class), as that should be safe to do, and then reapply that change together with a fix for the text antialiasing once development opens for 2025-06. What do you think? |
Sadly, that doesn't really work. The property needs to be overwritten in the Cairo context that is created by the GC, but this has then nothing to do with the image. But you are correct that this problem doesn't exist for e.g. Shells and Composites. In that case, the value doesn't need explicitly set. The options I see are to either always create a pango context (effectively duplicating createLayout()) when creating the Image GC or to somehow encode this information in the GCData instance.
I agree that the current change is too risky. But I also don't really like to only partially revert the previous commit. Given how close we are to the RC1, I'd rather leave the ruler fix in a tested state and then handle this case for the 2025-06. At least for GEF, we temporarily disabled the problematic test case, so there is no longer any real pressure from our side. |
Okay, sounds good. I was wondering whether we should at least merge #1835 then, as the switch to 32 bit was actually wrong, but maybe that's also too risky now that we are after RC1. |
I think my initial guess might've been a red herring. I at least could not detect any issues that could be traced back to using a 32bit, as opposed to 24bit. For GTK3, I also would've expected the previously used |
If I am not mistaken, the previous implementation used 24bit as surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height); |
No, you are correct. SWT used a 24bit surface in both the GTK3 and GTK4 case. Then it makes sense to merge the other commit, even if its just to avoid any unpleasant edge cases. |
9537dda
to
50b45ac
Compare
Could you please bump SWT tests version? |
50b45ac
to
ca932cc
Compare
On some platforms, the default text-antialias of the system might differ from Cairo. When a new GC object is created, the strings painted with the initial font options no longer match the strings painted after calling setTextAntialias(SWT.DEFAULT). This problem primarily exists for images. For this case, setTextAntialias(SWT.DEFAULT) should always be called to.
ca932cc
to
949d963
Compare
The fragment was already updated with ccc69c2, so I don't think this is necessary anymore? But related to the original problem. I tried to set the font options directly for the image handle in the In any case, the issue only seems to happen for images, so I've restricted the |
I believe the verification builds generally add version increment commits when they are needed. E.g., the second commit in this PR was automatic: |
It did not work for tests/examples so far, But we already had to do the version bump for the tests bundle for another change today, which is why it is not necessary here anymore, as mentioned by Patrick. |
Maybe it's not enabled for SWT's repo in general? |
It is not enabled for equinox and swt IIRC but unfortunately I don't remember what the problem was. |
fwiw: the according PR for SWT is still open #1491 |
On some platforms, the default text-antialias of the system might differ from Cairo. When creating a new GC object is created, the Cairo default is used. But when setTextAntialias(SWT.DEFAULT) is called, the system default is used instead.
To avoid this ambiguity, setTextAntialias(SWT.DEFAULT) should always be called when creating a GC object, in order to always use the system default.