Get font's underline position in DirectWrite font engine
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Tue, 10 Jul 2012 08:17:22 +0000 (10:17 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 10 Jul 2012 12:23:46 +0000 (14:23 +0200)
Fetch the correct underline position for the font along with
other metrics.

Task-number: QTBUG-22656
Change-Id: I35f6ea15ad18088033a5e7b7b83e2430c1b32a8f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
src/plugins/platforms/windows/qwindowsfontenginedirectwrite.h

index 3490ebf..48aae70 100644 (file)
@@ -242,9 +242,18 @@ void QWindowsFontEngineDirectWrite::collectMetrics()
         m_descent = DESIGN_TO_LOGICAL(metrics.descent);
         m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight);
         m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap);
+        m_underlinePosition = DESIGN_TO_LOGICAL(metrics.underlinePosition);
     }
 }
 
+QFixed QWindowsFontEngineDirectWrite::underlinePosition() const
+{
+    if (m_underlinePosition > 0)
+        return m_underlinePosition;
+    else
+        return QFontEngine::underlinePosition();
+}
+
 QFixed QWindowsFontEngineDirectWrite::lineThickness() const
 {
     if (m_lineThickness > 0)
index 32444c7..195748a 100644 (file)
@@ -69,6 +69,7 @@ public:
     void initFontInfo(const QFontDef &request, int dpi, IDWriteFont *font);
 
     QFixed lineThickness() const;
+    QFixed underlinePosition() const;
     bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
     QFixed emSquareSize() const;
 
@@ -115,6 +116,7 @@ private:
     IDWriteBitmapRenderTarget *m_directWriteBitmapRenderTarget;
 
     QFixed m_lineThickness;
+    QFixed m_underlinePosition;
     int m_unitsPerEm;
     QFixed m_ascent;
     QFixed m_descent;