Le 29/02/2020 à 18:27, Scott Kostyshak a écrit :
In Qt 5.11, horizontalAdvance() was added "to replace the confusingly named width() function", which was deprecated in the same release. [1]
Do you know whether they are equivalent, or subtly different?
"I am pretty sure that in most cases QFontMetrics::boundingRect() is what you want, unless you are writing custom text shaping/layouting code".
This will be the case where we also measure ascent and descent indeed.
From what I understand, we are indeed writing custom text shaping/layouting code.
Yes, but mostly for the code in GuiFontMetrics.
Attached is a patch. I don't propose to commit this patch; I just attach it to give an idea of how many replacements are needed and in case someone can check that we do indeed want horizontalAdvance() as the replacement in all cases and not boundingRect().
The best is to apply small bits by small bits. As I said, only GuiFontMetrics should be problematic.
JMarc, I'm guessing you're the one that I should bother about taking a look at this specific change. Can you take a look when you have time? If you prefer to not think about this or don't have time, it can wait; it's just a compilation warning message.
Mostly for font metrics, but I can have a look. For the ones that are in dialogs and such; you guess is as good as mine.
After figuring out the above, the next question would be how to implement the changes in a way that preserves compatibility with Qt versions < 5.11. Should we use a directive to condition on the Qt version around each instance or since there are several instances should we use the approach of a macro as is done at [3]?
I think that the only places where we need horizontal advance is when we do layout things, so mainly what is in GuiFontMetrics. In the other cases, we want the size of a box that contains the string, so the boundingBox().width() approach is fine (although it seems to me tht it computes ascent and descent unnecessarily).
Thanks for the patch. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel