[QFontEngineFT::loadGlyph] Consolidate paths for fetchMetricsOnly cases
Use GlyphInfo as a temporary buffer for storing the glyph metrics and go through the same code for fetchMetricsOnly and !fetchMetricsOnly. Change-Id: If8bb85056e5f09588cc3956b43dc51a54d5aecfe Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
550fb85b65
commit
237cb0d082
@ -801,6 +801,17 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
|
|||||||
return load_flags;
|
return load_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info)
|
||||||
|
{
|
||||||
|
// false if exceeds QFontEngineFT::Glyph metrics
|
||||||
|
return (short)(info.linearAdvance) == info.linearAdvance
|
||||||
|
&& (signed char)(info.xOff) == info.xOff
|
||||||
|
&& (uchar)(info.width) == info.width
|
||||||
|
&& (uchar)(info.height) == info.height
|
||||||
|
&& (signed char)(info.x) == info.x
|
||||||
|
&& (signed char)(info.y) == info.y;
|
||||||
|
}
|
||||||
|
|
||||||
QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
||||||
QFixed subPixelPosition,
|
QFixed subPixelPosition,
|
||||||
GlyphFormat format,
|
GlyphFormat format,
|
||||||
@ -885,6 +896,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlyphInfo info;
|
GlyphInfo info;
|
||||||
|
info.linearAdvance = slot->linearHoriAdvance >> 10;
|
||||||
info.xOff = TRUNC(ROUND(slot->advance.x));
|
info.xOff = TRUNC(ROUND(slot->advance.x));
|
||||||
info.yOff = 0;
|
info.yOff = 0;
|
||||||
|
|
||||||
@ -893,27 +905,23 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
|||||||
int right = CEIL(slot->metrics.horiBearingX + slot->metrics.width);
|
int right = CEIL(slot->metrics.horiBearingX + slot->metrics.width);
|
||||||
int top = CEIL(slot->metrics.horiBearingY);
|
int top = CEIL(slot->metrics.horiBearingY);
|
||||||
int bottom = FLOOR(slot->metrics.horiBearingY - slot->metrics.height);
|
int bottom = FLOOR(slot->metrics.horiBearingY - slot->metrics.height);
|
||||||
int width = right-left;
|
info.x = TRUNC(left);
|
||||||
int height = top-bottom;
|
info.y = TRUNC(top);
|
||||||
|
info.width = TRUNC(right - left);
|
||||||
|
info.height = TRUNC(top - bottom);
|
||||||
|
|
||||||
// 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
|
||||||
if (qAbs(info.xOff) >= 128
|
if (areMetricsTooLarge(info))
|
||||||
|| qAbs(TRUNC(top)) >= 128
|
|
||||||
|| TRUNC(width) >= 256
|
|
||||||
|| TRUNC(height) >= 256
|
|
||||||
|| qAbs(TRUNC(left)) >= 128
|
|
||||||
|| qAbs(TRUNC(ROUND(slot->advance.x))) >= 128) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
g = new Glyph;
|
g = new Glyph;
|
||||||
g->data = 0;
|
g->data = 0;
|
||||||
g->linearAdvance = slot->linearHoriAdvance >> 10;
|
g->linearAdvance = info.linearAdvance;
|
||||||
g->width = TRUNC(width);
|
g->width = info.width;
|
||||||
g->height = TRUNC(height);
|
g->height = info.height;
|
||||||
g->x = TRUNC(left);
|
g->x = info.x;
|
||||||
g->y = TRUNC(top);
|
g->y = info.y;
|
||||||
g->advance = TRUNC(ROUND(slot->advance.x));
|
g->advance = info.xOff;
|
||||||
g->format = format;
|
g->format = format;
|
||||||
|
|
||||||
if (set)
|
if (set)
|
||||||
@ -1014,16 +1022,9 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
|||||||
info.x -= 1;
|
info.x -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool large_glyph = (((short)(slot->linearHoriAdvance>>10) != slot->linearHoriAdvance>>10)
|
// If any of the metrics are too large to fit, don't cache them
|
||||||
|| ((uchar)(info.width) != info.width)
|
if (areMetricsTooLarge(info))
|
||||||
|| ((uchar)(info.height) != info.height)
|
|
||||||
|| ((signed char)(info.x) != info.x)
|
|
||||||
|| ((signed char)(info.y) != info.y)
|
|
||||||
|| ((signed char)(info.xOff) != info.xOff));
|
|
||||||
|
|
||||||
if (large_glyph) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
int pitch = (format == Format_Mono ? ((info.width + 31) & ~31) >> 3 :
|
int pitch = (format == Format_Mono ? ((info.width + 31) & ~31) >> 3 :
|
||||||
(format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4));
|
(format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4));
|
||||||
@ -1136,7 +1137,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
|
|||||||
g->data = 0;
|
g->data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g->linearAdvance = slot->linearHoriAdvance >> 10;
|
g->linearAdvance = info.linearAdvance;
|
||||||
g->width = info.width;
|
g->width = info.width;
|
||||||
g->height = info.height;
|
g->height = info.height;
|
||||||
g->x = info.x;
|
g->x = info.x;
|
||||||
|
@ -143,6 +143,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct GlyphInfo {
|
struct GlyphInfo {
|
||||||
|
int linearAdvance;
|
||||||
unsigned short width;
|
unsigned short width;
|
||||||
unsigned short height;
|
unsigned short height;
|
||||||
short x;
|
short x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user