src/gui/text/qfontengine.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/gui/text/qfontengine.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/gui/text/qfontengine.cpp	Mon May 03 13:17:34 2010 +0300
@@ -379,6 +379,15 @@
     Q_ASSERT(positions.size() == glyphs_out.size());
 }
 
+void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
+{
+    glyph_metrics_t gi = boundingBox(glyph);
+    bool isValid = gi.isValid();
+    if (leftBearing != 0)
+        *leftBearing = isValid ? gi.x.toReal() : 0.0;
+    if (rightBearing != 0)
+        *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : 0.0;
+}
 
 glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs)
 {
@@ -1385,6 +1394,12 @@
     return overall;
 }
 
+void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
+{
+    int which = highByte(glyph);
+    engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing);
+}
+
 void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
                                         QPainterPath *path, QTextItem::RenderFlags flags)
 {