Fix regression causing synthesized oblique glyphs to clip
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Mon, 19 Sep 2011 13:55:39 +0000 (15:55 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 14:37:51 +0000 (16:37 +0200)
In 20009ed797fb30952a889df5716aa2399102be58 I introduced a new
approach to synthesized oblique. However, while the embolden
function in FT alters the glyph metrics accordingly, the
oblique function does not, so the glyphs would be clipped to the
original, unslanted metrics. So I've implemented the same matrix
in the loadGlyph() function and we now apply this to the metrics
manually. This will only work as long as the underlying algorithm
doesn't change significantly.

Task-number: QTBUG-21202
Change-Id: Ic20b2a0fdeac5ce833e95fd06efa12b3b70feee5
Reviewed-on: http://codereview.qt-project.org/5156
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
src/gui/text/qfontengine_ft.cpp

index 6a65aad..1e7c3a2 100644 (file)
@@ -892,7 +892,21 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
 
     FT_GlyphSlot slot = face->glyph;
     if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(slot);
-    if (obliquen) Q_FT_GLYPHSLOT_OBLIQUE(slot);
+    if (obliquen) {
+        Q_FT_GLYPHSLOT_OBLIQUE(slot);
+
+        // While Embolden alters the metrics of the slot, oblique does not, so we need
+        // to fix this ourselves.
+        transform = true;
+        FT_Matrix m;
+        m.xx = 0x10000;
+        m.yx = 0x0;
+        m.xy = 0x6000;
+        m.yy = 0x10000;
+
+        FT_Matrix_Multiply(&m, &matrix);
+    }
+
     FT_Library library = qt_getFreetype();
 
     info.xOff = TRUNC(ROUND(slot->advance.x));