diff options
author | Eskil Abrahamsen Blomfeldt <[email protected]> | 2012-11-21 09:58:12 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2012-11-23 08:11:06 +0100 |
commit | 96f17a061a73bdd19e2c5df221a191968d777123 (patch) | |
tree | 29b04106adb461496bdaac8485ca783d6b5c72d3 | |
parent | 3f936e9094f3a6e4d76791c1eff7ae92f91b61ae (diff) |
Fix transformed text on Mac OS X
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 <[email protected]>
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontengine_p.h | 2 | ||||
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 5 | ||||
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h | 2 |
5 files changed, 15 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index fec01afdee2..2841a583d53 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -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); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fa4e7a75bc0..400ce8366fe 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -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) diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 745e39ecf58..3321ca3b933 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -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; diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index d4137118282..1087d188910 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -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) diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index db1ebbaca1f..6c5c557b13f 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -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; } |