summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/text/qfontengine_coretext.mm10
-rw-r--r--src/gui/text/qfontengine_coretext_p.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 153451e74b..154c44ff54 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -97,6 +97,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const
if (fontDef.stretch != 100) {
transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
}
+ transformAdvances = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7;
QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform);
@@ -225,6 +226,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
CFRange stringRange = CTRunGetStringRange(run);
+ CGAffineTransform textMatrix = CTRunGetTextMatrix(run);
int prepend = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5
UniChar beginGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location);
@@ -319,9 +321,13 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
for (CFIndex i = 0; i < glyphCount - 1; ++i) {
int idx = rtlOffset + rtlSign * i;
outGlyphs[idx] = tmpGlyphs[i] | fontIndex;
- outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
+ CGSize advance = CGSizeMake(tmpPoints[i + 1].x - tmpPoints[i].x, tmpPoints[i].y - tmpPoints[i + 1].y);
+ if (transformAdvances)
+ advance = CGSizeApplyAffineTransform(advance, textMatrix);
+
+ outAdvances_x[idx] = QFixed::fromReal(advance.width);
// Use negative y advance for flipped coordinate system
- outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y);
+ outAdvances_y[idx] = QFixed::fromReal(advance.height);
if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
outAdvances_x[idx] = outAdvances_x[idx].round();
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
index 4bd80beb00..495e6387fc 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -146,6 +146,7 @@ private:
mutable QCFType<CFMutableDictionaryRef> attributeDict;
CGAffineTransform transform;
friend class QFontDialogPrivate;
+ bool transformAdvances;
};
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);