diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-03-05 11:13:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-05 13:45:54 +0100 |
commit | 34e560fc928d2b0fb78cff60f690f3094ec36ac0 (patch) | |
tree | 6e03a38f09f017e3157f9c2068a482d948d8bd9b /src/gui/text | |
parent | f697f3ceb6751cfa04338ac8a62ad54dfadad73d (diff) |
Optimize QFontEngineMulti::stringToCMap() in case of missing glyphs
Use recently introduced glyphIndex() method and only recalc advances
if the glyph is present in the font. This allows to avoid restoring
the old advance when the glyph was not found in the fallback fonts.
Change-Id: I3e0aa549961767e5448816327328101cf6a78873
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 87d3090a39..a5f213113d 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1600,9 +1600,6 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()); uint ucs4 = surrogate ? QChar::surrogateToUcs4(str[i], str[i+1]) : str[i].unicode(); if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) { - QFixed tmpAdvance; - if (!(flags & GlyphIndicesOnly)) - tmpAdvance = glyphs->advances[glyph_pos]; for (int x = 1, n = qMin(engines.size(), 256); x < n; ++x) { if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4)) continue; @@ -1616,23 +1613,18 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (engine->type() == Box) continue; - if (!(flags & GlyphIndicesOnly)) - glyphs->advances[glyph_pos] = QFixed(); - int num = 2; - QGlyphLayout g = glyphs->mid(glyph_pos, num); - if (!engine->stringToCMap(str + i, surrogate ? 2 : 1, &g, &num, flags)) - Q_UNREACHABLE(); - Q_ASSERT(num == 1); - if (glyphs->glyphs[glyph_pos]) { + glyph_t glyph = engine->glyphIndex(ucs4); + if (glyph != 0) { + glyphs->glyphs[glyph_pos] = glyph; + if (!(flags & GlyphIndicesOnly)) { + QGlyphLayout g = glyphs->mid(glyph_pos, 1); + engine->recalcAdvances(&g, flags); + } // set the high byte to indicate which engine the glyph came from glyphs->glyphs[glyph_pos] |= (x << 24); break; } } - - // ensure we use metrics from the 1st font when we use the fallback image. - if (!(flags & GlyphIndicesOnly) && glyphs->glyphs[glyph_pos] == 0) - glyphs->advances[glyph_pos] = tmpAdvance; } if (surrogate) |