QFontEngineFT::loadGlyph() takes care of caching

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-12-25 00:05:03 +02:00
parent 57288229b1
commit 8a1f8d5abf

View file

@ -677,7 +677,6 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(glyph_t glyph,
::memcpy(glyph_buffer, slot->bitmap.buffer, bytes); ::memcpy(glyph_buffer, slot->bitmap.buffer, bytes);
} }
if (!g) { if (!g) {
g = new Glyph; g = new Glyph;
g->data = 0; g->data = 0;
@ -1000,13 +999,10 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag
default_hint_style == HintLight || default_hint_style == HintLight ||
(flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(face); (flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(face);
for (int i = 0; i < glyphs->numGlyphs; i++) { for (int i = 0; i < glyphs->numGlyphs; i++) {
Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); Glyph *g = loadGlyph(glyphs->glyphs[i], Format_None, true);
// Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph if (g) {
GlyphFormat acceptableFormat = (defaultFormat != Format_None) ? defaultFormat : Format_Mono;
if (g && g->format == acceptableFormat) {
glyphs->advances_x[i] = design ? QFixed::fromFixed(g->linearAdvance) : QFixed(g->advance); glyphs->advances_x[i] = design ? QFixed::fromFixed(g->linearAdvance) : QFixed(g->advance);
} else { } else {
g = loadGlyph(glyphs->glyphs[i], Format_None, true);
glyphs->advances_x[i] = design ? QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10) glyphs->advances_x[i] = design ? QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10)
: QFixed::fromFixed(face->glyph->metrics.horiAdvance).round(); : QFixed::fromFixed(face->glyph->metrics.horiAdvance).round();
} }
@ -1029,10 +1025,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) const
QFixed ymax = 0; QFixed ymax = 0;
QFixed xmax = 0; QFixed xmax = 0;
for (int i = 0; i < glyphs.numGlyphs; i++) { for (int i = 0; i < glyphs.numGlyphs; i++) {
Glyph *g = defaultGlyphSet.getGlyph(glyphs.glyphs[i]); Glyph *g = loadGlyph(glyphs.glyphs[i], Format_None, true);
if (!g) {
g = loadGlyph(glyphs.glyphs[i], Format_None, true);
}
if (g) { if (g) {
QFixed x = overall.xoff + glyphs.offsets[i].x + g->x; QFixed x = overall.xoff + glyphs.offsets[i].x + g->x;
QFixed y = overall.yoff + glyphs.offsets[i].y - g->y; QFixed y = overall.yoff + glyphs.offsets[i].y - g->y;
@ -1066,10 +1059,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph) const
{ {
FT_Face face = getFace(); FT_Face face = getFace();
glyph_metrics_t overall; glyph_metrics_t overall;
Glyph *g = defaultGlyphSet.getGlyph(glyph); Glyph *g = loadGlyph(glyph, Format_None, true);
if (!g) {
g = loadGlyph(glyph, Format_None, true);
}
if (g) { if (g) {
overall.x = g->x; overall.x = g->x;
overall.y = -g->y; overall.y = -g->y;