summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine_p.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-08-17 17:59:06 +0200
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-09-02 09:11:31 +0000
commit54dbdc26bacd3ab776c99ebef734404ef2e08ce5 (patch)
tree6c3d5614ea3beefd023ab0a259ecf207655ba2ce /src/gui/text/qtextengine_p.h
parentba94e26b8b233456b004084892464ec55b20800c (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/qtextengine_p.h')
-rw-r--r--src/gui/text/qtextengine_p.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index d2b39f274c..160daa0cfd 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -107,6 +107,22 @@ struct Q_GUI_EXPORT glyph_metrics_t
glyph_metrics_t transformed(const QTransform &xform) const;
inline bool isValid() const {return x != 100000 && y != 100000;}
+
+ inline QFixed leftBearing() const
+ {
+ if (!isValid())
+ return QFixed();
+
+ return x;
+ }
+
+ inline QFixed rightBearing() const
+ {
+ if (!isValid())
+ return QFixed();
+
+ return xoff - x - width;
+ }
};
Q_DECLARE_TYPEINFO(glyph_metrics_t, Q_PRIMITIVE_TYPE);