diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-08-17 17:59:06 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-09-02 09:11:31 +0000 |
commit | 54dbdc26bacd3ab776c99ebef734404ef2e08ce5 (patch) | |
tree | 6c3d5614ea3beefd023ab0a259ecf207655ba2ce /src/gui/text/qfontengine_ft.cpp | |
parent | ba94e26b8b233456b004084892464ec55b20800c (diff) |
Move min left/right bearing calculations to QFontEngine baseclass
The logic used in the FreeType font engine can be generalized
and move to the QFontEngine baseclass. This allows the CoreText
font engine to correctly report the minimum left/right bearings,
which decreases the chance that an optimization in QTextLayout's
line breaking algorithm will produce wrong results.
The calculation of left and right bearing has been moved to the
glyph_metrics_t type to reduce code duplication. This allows us
to use the with and height of the bounding box to determine if
the glyph has any contours.
Change-Id: I864697d3f31ed56f22f04666199b6c5023c5e585
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 246df127ad..0d28785aa1 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -688,7 +688,6 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive)); } - lbearing = rbearing = SHRT_MIN; freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing); FT_Face face = lockFace(); @@ -1258,54 +1257,6 @@ qreal QFontEngineFT::maxCharWidth() const return metrics.max_advance >> 6; } -static const ushort char_table[] = { - 40, - 67, - 70, - 75, - 86, - 88, - 89, - 91, - 95, - 102, - 114, - 124, - 127, - 205, - 645, - 884, - 922, - 1070, - 12386 -}; - -static const int char_table_entries = sizeof(char_table)/sizeof(ushort); - - -qreal QFontEngineFT::minLeftBearing() const -{ - if (lbearing == SHRT_MIN) - (void) minRightBearing(); // calculates both - return lbearing.toReal(); -} - -qreal QFontEngineFT::minRightBearing() const -{ - if (rbearing == SHRT_MIN) { - lbearing = rbearing = 0; - for (int i = 0; i < char_table_entries; ++i) { - const glyph_t glyph = glyphIndex(char_table[i]); - if (glyph != 0) { - glyph_metrics_t gi = const_cast<QFontEngineFT *>(this)->boundingBox(glyph); - lbearing = qMin(lbearing, gi.x); - rbearing = qMin(rbearing, (gi.xoff - gi.x - gi.width)); - } - } - } - return rbearing.toReal(); -} - QFixed QFontEngineFT::lineThickness() const { return line_thickness; |