src/gui/text/qfontengine.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
--- a/src/gui/text/qfontengine.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/text/qfontengine.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -357,9 +357,6 @@
                 ++i;
             }
         } else {
-            positions.resize(glyphs.numGlyphs);
-            glyphs_out.resize(glyphs.numGlyphs);
-            int i = 0;
             while (i < glyphs.numGlyphs) {
                 if (!glyphs.attributes[i].dontPrint) {
                     QFixed gpos_x = xpos + glyphs.offsets[i].x;
@@ -382,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)
 {
@@ -1388,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)
 {