Fix transformed text on Mac OS X
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Wed, 21 Nov 2012 08:58:12 +0000 (09:58 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 23 Nov 2012 07:11:06 +0000 (08:11 +0100)
In change 1582407fc782c0befd0760633324dd5c206524a1, the Q_WS_MAC
code path which disabled drawing cached glyphs for any transform
was removed, as was the comment that scaling and rotation wasn't
supported by the Mac font engines. This obviously broke transformed
text on Mac, so we need to put it back.

I put it into the font engine itself where it belongs, and I kept
the somewhat confusing naming convention which is used in the
paint engine to minimize this patch. I'll clean up these function
names in a future commit.

Task-number: QTBUG-27362
Change-Id: I4fc6a503eedd4b1ebaf3ee659d948f997f433338
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/gui/painting/qpaintengine_raster.cpp
src/gui/text/qfontengine.cpp
src/gui/text/qfontengine_p.h
src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h

index fec01af..2841a58 100644 (file)
@@ -2992,7 +2992,7 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
     ensureRasterState();
 
     QFontEngine *fontEngine = textItem->fontEngine();
-    if (shouldDrawCachedGlyphs(fontEngine, state()->matrix)) {
+    if (!supportsTransformations(fontEngine)) {
         drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions,
                          fontEngine);
     } else if (state()->matrix.type() < QTransform::TxProject) {
@@ -3291,7 +3291,7 @@ bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine) const
 */
 bool QRasterPaintEngine::supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const
 {
-    if (m.type() >= QTransform::TxProject)
+    if (fontEngine->supportsTransformations(m))
         return true;
 
     return !shouldDrawCachedGlyphs(fontEngine, m);
index fa4e7a7..400ce83 100644 (file)
@@ -268,6 +268,10 @@ QFixed QFontEngine::averageCharWidth() const
     return bb.xoff;
 }
 
+bool QFontEngine::supportsTransformations(const QTransform &transform) const
+{
+    return (transform.type() >= QTransform::TxProject);
+}
 
 void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags,
                                     QVarLengthArray<glyph_t> &glyphs_out, QVarLengthArray<QFixedPoint> &positions)
index 745e39e..3321ca3 100644 (file)
@@ -241,6 +241,8 @@ public:
         return canRender(utf16, utf16len);
     }
 
+    virtual bool supportsTransformations(const QTransform &transform) const;
+
     virtual Type type() const = 0;
 
     virtual int glyphCount() const;
index d413711..1087d18 100644 (file)
@@ -600,6 +600,11 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
     return new QCoreTextFontEngine(cgFont, newFontDef);
 }
 
+bool QCoreTextFontEngine::supportsTransformations(const QTransform &transform) const
+{
+    return transform.type() > QTransform::TxTranslate;
+}
+
 QT_END_NAMESPACE
 
 #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
index db1ebba..6c5c557 100644 (file)
@@ -103,6 +103,8 @@ public:
     virtual qreal minLeftBearing() const;
     virtual QFixed emSquareSize() const;
 
+    bool supportsTransformations(const QTransform &transform) const;
+
     virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
     virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; }