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>
This commit is contained in:
parent
810e755c18
commit
a5085d7f6a
@ -903,7 +903,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
|
|||||||
static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info)
|
static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info)
|
||||||
{
|
{
|
||||||
// false if exceeds QFontEngineFT::Glyph metrics
|
// 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)
|
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
|
// 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
|
// 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;
|
return nullptr;
|
||||||
|
|
||||||
g = new Glyph;
|
g = new Glyph;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user