Eskil Abrahamsen Blomfeldt 3728032e03 Account for rounding error when rounding height metrics
In Qt 5 we would ask FreeType for height metrics. FreeType
always returns rounded metrics, so for e.g. DejaVu Sans at
pixel size 21 it would return ascender=20 and descender=5,
which is actually incorrect, since the actual ascender is
19.49. The descender is rounded correctly. This is likely
due to the use of fixed point math internally.

In Qt, we would account for this error by setting the
leading to -1, so that the rounded height still becomes
24. (This is also technically incorrect, since the line gap
of the font is 0.)

In Qt 6, we got the same fixed point rounding error (so
ascender becomes 20 instead of 19), but we didn't account
for the error, so we would end up with lines that were 25
high instead of 24.

To reduce the chance of getting this error, we do the full
metrics calculation in floating point numbers instead. For
the case in question, we will then get arounded ascender of
19 and descender of 5, giving us a height of 24.

Fixed point numbers are still used for storing the results,
so while it's less likely, we could still end up with the
same error. Therefore, we also apply the same trick as in
Qt 5 when this occurs: Adapting the leading of the font to
account for the rounding error if it occurs.

[ChangeLog][QtGui][Text] Fixed an issue where the line
distance for hinted fonts would be off by one for specific
sizes of some fonts.

Fixes: QTBUG-134602
Pick-to: 6.8 6.9
Change-Id: I09f1806199b7b2b02a932bb65fe4da055bd60f51
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-26 14:38:19 +00:00
2025-03-24 19:01:57 +02:00
2024-11-05 14:36:16 +01:00
2024-11-05 14:36:16 +01:00
2024-12-13 14:54:23 +00:00
2025-03-24 23:19:04 +01:00
2024-06-25 11:44:00 +02:00
Description
Qt Base (Core, Gui, Widgets, Network, ...)
822 MiB
Languages
C++ 84.3%
HTML 4.9%
C 3.9%
CMake 3.6%
Objective-C++ 2%
Other 0.8%