minor: Clean up areMetricsTooLarge() conditions
This amendse2bdff3555
. 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 inb7e4367387
it was turned back into 16.6 again. But this was accidentally reverted as part of a bad conflict resolution inafb326f071
. 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)
|
||||
{
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user