diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-05-25 11:32:31 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-05-27 10:13:55 +0200 |
commit | a5085d7f6ac0ee4e066431ec9a99b7e0f13d2d0c (patch) | |
tree | 36084bf779ad80135f30721a0faccd3af6b8cf4e /src/gui/text | |
parent | 810e755c180212892dbd5a8784ffe9c99258862a (diff) | |
download | qtbase-a5085d7f6ac0ee4e066431ec9a99b7e0f13d2d0c.tar.gz |
minor: Clean up areMetricsTooLarge() conditions
This amends e2bdff3555f8c2a275c7bbcf964d939a5f489100.
The linearAdvance property has some history. First it was
a 16 bit value (allowing for 10.6 fixed point numbers). Then
it was turned into 22 bits to fit the 16 bits of Freetype
integer parts into it (16.6). Then back to 10.6. Then in
b7e436738756b1d5d7a45201b7a7204d7fe128a1 it was turned
back into 16.6 again. But this was accidentally reverted
as part of a bad conflict resolution in
afb326f07109da0035112e6f56e683e37b8a5d72.
Since there was no check for it, we would sometimes overflow
the linearAdvance, but only in the rare cases where the
width and height did not also overflow. Specifically this
is the case for whitespace, which always has a width of 0
regardless of the advance.
This change just moves the linearAdvance condition in
together with the other checks to avoid fragmentation, and
also adds this fun story to the commit log.
Pick-to: 6.1 5.15
Change-Id: Iaac09942f4c50d1aced4a160b6eabb11eb8e6373
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/freetype/qfontengine_ft.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index ae1e139251..12ba46b7ed 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -903,7 +903,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags, static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info) { // false if exceeds QFontEngineFT::Glyph metrics - return info.width > 0xFF || info.height > 0xFF; + return info.width > 0xFF || info.height > 0xFF || info.linearAdvance > 0x7FFF; } static inline void transformBoundingBox(int *left, int *top, int *right, int *bottom, FT_Matrix *matrix) @@ -1052,7 +1052,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, // If any of the metrics are too large to fit, don't cache them // Also, avoid integer overflow when linearAdvance is to large to fit in a signed short - if (areMetricsTooLarge(info) || info.linearAdvance > 0x7FFF) + if (areMetricsTooLarge(info)) return nullptr; g = new Glyph; |