I noticed text was off by +1 on x/y in my app, and could see it
in e.g. the fltk test/radio demo.
Opened issue #568:
https://github.com/fltk/fltk/issues/568
wcout mentioned it was probably the new use of Pango, and that
seemed
to be the cause.
But the question is: is this a given with pango, or is
there actually a small x+1/y+1 offset bug?
If it's a given, I'll close the issue.
Curious what the opinion is.
One really notices this in apps where the buttons are small, where
it's easy to see
when text is off, compared to previous releases. Trying to avoid
refactoring a lot of code
to get things recentered.
I noticed text was off by +1 on x/y in my app, and could see it
in e.g. the fltk test/radio demo.
Opened issue #568:
https://github.com/fltk/fltk/issues/568
wcout mentioned it was probably the new use of Pango, and that seemed
to be the cause.
But the question is: is this a given with pango, or is there actually a small x+1/y+1 offset bug?
If it's a given, I'll close the issue.
Curious what the opinion is.
One really notices this in apps where the buttons are small, where it's easy to see
when text is off, compared to previous releases. Trying to avoid refactoring a lot of code
to get things recentered.
Hmm, I don't see that Pango is used in 1.3.x at all. I understand that you report that the same issue as in 1.4.x (using Pango) is already in 1.3.x (i.e. branch-1.3 after the release of 1.3.8). I doubt that this is the case. Or maybe I misunderstand your report.
Greg, can you please double check your findings? If it's related to Pango, then 1.3.x (git) should *not* be affected and you might want to edit your report.
On 12/2/22 03:42, Albrecht Schlosser wrote:
Greg, can you please double check your findings? If it's related to Pango, then 1.3.x (git) should *not* be affected and you might want to edit your report.
FWIW, I fired up the unittests demo under Windows, both 1.3.x. and 1.4, built from the current tip of the repo. The text_extents test looks basically OK (on that platform)
I suspect that different fonts are being picked in each case and that may account for the visible differences?
ISTR there was some attempt to enhance the font selection, possibly between 1.3.4 and 1.3.8, so that may be in effect here? Or maybe I'm talking nonsense...
On 12/2/22 06:07, imm wrote:
I suspect that different fonts are being picked in each case and that may account for the visible differences?
Maybe, but I think perhaps more it's the new pango effects.
If the pango stuff does have a problem (that's undecided at present),
it might perhaps be a scaling type of problem, as text near the top/left
corner doesn't wiggle as much as further away on the x and y axis,
which I think my radio animation comparison might be showing:
https://user-images.githubusercontent.com/6484779/205161223-33cae018-dccd-4fd3-9162-eb59881dfa9c.gif
..the text for the top left button "Fl_Button A1", the top left of the first "F" doesn't move at all.
But as you go down the window, the first "F" in the other buttons start to be offset +1 on x.
And the radio buttons seem to all be +1 on both X and Y.
The position of the radio text is probably pre-calculated based on the font measuring stuff
to get things centered, so if something is wrong with that, that might explain the offset for
only those.
I'm not sure yet.. will try to do some tests drawing text at fixed positions in a grid
across the window and comparing with vs without pango, etc.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/349282ed-7638-b341-2ef9-2d551d99b5e9%40online.de.
On 12/2/22 08:36, Albrecht Schlosser wrote:
..the text for the top left button "Fl_Button A1", the top left of the first "F" doesn't move at all.
..but if you look closely at 200% zoom you see that the 'F' changes a bit: the top left stays the same but the vertical line becomes a tiny bit longer. The same is true for all 'F's in all buttons.
Manolo did mention in his first comment in the issue listing
4 factors at work,
specifically point #4 on kerning, where kerning is "off" for
xft, but on for pango.
He wrote: "Kerning applies in Pango. Despite much efforts, I
didn't find how to turn it off.
Any hint about how to do that is much welcome."
So perhaps that's related to the text width being slightly
affected due to inter-letter spacing.
BTW, I would like to see separate images additionally to animated gifs to be able to view them in a browser and switch the image on a button click rather than at fixed times. TIA
If you want to do that, you can load the gif in gimp, and
under layers you'll see
the two images as separate layers, and you can simply turn the
visibility of one
layer on and off by just repeatedly clicking the "eyeball"
icon for that top layer.
There /may/ be more to do, perhaps not with text drawing, but with text measuring,
as I can only guess the button and radio widgets determine how to center text based
on, maybe the fl_measure() stuff or Ian's relatively new extents, or some such.
Manolo did mention in his first comment in the issue listing 4 factors at work,
specifically point #4 on kerning, where kerning is "off" for xft, but on for pango.
He wrote: "Kerning applies in Pango. Despite much efforts, I didn't find how to turn it off.
Any hint about how to do that is much welcome."
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/376693fe-ae63-60b0-8b12-acbc14ae0190%40online.de.
On 12/2/22 15:56, Albrecht Schlosser wrote:
On 12/3/22 00:03 Greg Ercolano wrote:
See my recent two comments using a text grid.
Really seems to show, at least regarding drawing text at an x,y position with fl_draw(s,x,y),
that things are more stable now.
I'm a little surprised to see that because my previous tests with the latest commit seemed to show that Manolo's fix moved the text even a little more down than before (x was good but y seemed to be too large, text moved downwards). I'll have to look at your test program but it's too late here now, so maybe tomorrow...
I'll add these oberservations to the issue, as there's obviously some weirdness going
on with the font measuring stuff, which is causing trouble with the positions of labels
that are 'aligned'.
I thought about closing the issue as resolved (because the positioning issue seems to be clear) and opening another issue for font measurement and label alignment. What do you think about this?
On 12/3/22 16:54, Albrecht Schlosser wrote:
I don't know where the y position is aligned, is it the bottom of the printing area, or is it the baseline of the font, or ... ?
> As an aside, Greg mentioned drawing a baseline for the fonts, and I do
> wonder if that is something we should add to the render text Unit test?
+1
That would be nice to have. Maybe with a light or check button to switch
the baseline drawing on/off.
On Sunday, 4 December 2022 at 20:11:50 UTC Albrecht Schlosser wrote:
> As an aside, Greg mentioned drawing a baseline for the fonts, ...
Attached, a suggestion of how the revised test would work...
On 12/5/22 15:04 imacarthur wrote:
Attached, a suggestion of how the revised test would work...
Thanks, I tried it and it looks good. However, on Linux (X11 and Wayland) the button box is too small to hold the label. I fixed this in my attached patch(es). Now it is not filled completely on Windows but this is IMHO the minor issue (sure, we could measure the text ... :-)).
Then I stumbled across your casts. I looked at the CMP and saw that we do not really forbid 'reinterpret_cast' (it is not mentioned in the STR) but I didn't find it anywhere in the sources. While trying to change this to an old style cast I noticed the (Fl_Callback *) cast as well and (SCNR) I "simplified" the code: I changed the first parameter of cb_base_bt to Fl_Widget* to comply with (Fl_Callback *) and used it then with parent() to get the group pointer. This is less code and no casts, but parent() is yet another function call. Anyway, this is in unittest_text_v1.diff.
Further I wasn't sure if the baseline would overwrite the lower border of the green fl_text_extents box (it did not in my tests). But since the baseline is longer anyway (good idea, BTW) I thought it would be a better to draw the baseline first. If it is not visible below the text, then the fl_text_extents() box must have been drawn over it. This needed separate variables for the text measurement and I rearranged the measurement and drawing.
The result is in unittest_text_v2.diff and I personally prefer this one. What do you think?
The result is in unittest_text_v2.diff and I personally prefer this one. What do you think?
The question is: do we allow or forbid 'reinterpret_cast' in FLTK 1.4?
Here "static_cast" is saying "copy the VALUE of this variable to this other different type of variable" which is pretty much what the C-style cast "usually" does.
But you can’t "static_cast" a pointer type, that fails, so use "reinterpret_cast" instead which is "treat this pointer as if it were a pointer of this other type, even though it isn't". Which is what the C-style cast does *only sometimes", but is conceptually a different behaviour from the "static cast" case - it was this ambiguity that Stroustroup et al were trying to make explicit...
As Matt says, "dynamic_cast" is a trickier one as it may need RTTI etc., which we probably do not want in the library - though I do use it a fair bit in my own code. (It may also be "expensive" as it is often evaluated at runtime rather than at compile time if the code analysis can't unambiguously determine the type at compile time, so this has a performance penalty.)
And the "last" case is "const_cast" which basically means "I did something stupid and declared this variable as const but now I'm going to try and write to it anyway" which is essentially a sign that it is time to refactor your code...
On Tuesday, 6 December 2022 at 14:24:24 UTC Matt wrote:
Albrecht Schlosser schrieb am Dienstag, 6. Dezember 2022 um 12:33:07 UTC+1:
The question is: do we allow or forbid 'reinterpret_cast' in FLTK 1.4?
AFAIK, reinterpret_cast is pretty much the same as the cast operator, which we use extensively. I don't see much harm, but no much benefit over the operator either. ...
Hmm, no, I don't think reinterpret_cast is "the same" as the C cast operator, it is more restricted.Consider this sample:
Here "static_cast" is saying "copy the VALUE of this variable to this other different type of variable" which is pretty much what the C-style cast "usually" does.But you can’t "static_cast" a pointer type, that fails, so use "reinterpret_cast" instead which is "treat this pointer as if it were a pointer of this other type, even though it isn't". Which is what the C-style cast does *only sometimes", but is conceptually a different behaviour from the "static cast" case - it was this ambiguity that Stroustroup et al were trying to make explicit...
On Tuesday, 6 December 2022 at 11:13:52 UTC Albrecht Schlosser wrote:
The result is in unittest_text_v2.diff and I personally prefer this one. What do you think?
Yes, looks good. Let's do that...
My question was more about: do we *allow* to use it in the code? This was meant to discuss whether our users might use ancient compilers that don't support it.
All FLTK developers are entitled to push to master. I'd say the policy is to push there changes a developeris confident they are functional. In case of doubt, a dedicated branch in the developer's own fltk fork is handyto allow further work until confidence arrives.