diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-19 09:38:58 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-19 09:43:46 (GMT) |
commit | 8cbf269e14b372ee3174c2706dd0cc4df37eef1a (patch) | |
tree | a4266dcef8cf29cec50b662fb9416575d10e812a /src/gui/text/qfontengine_mac.mm | |
parent | 28b894f65c5aba01d5ee80c20f617478faaee7e7 (diff) | |
download | Qt-8cbf269e14b372ee3174c2706dd0cc4df37eef1a.zip Qt-8cbf269e14b372ee3174c2706dd0cc4df37eef1a.tar.gz Qt-8cbf269e14b372ee3174c2706dd0cc4df37eef1a.tar.bz2 |
Fix platform regression: Support QFont::setStretch() on Cocoa
QFont::setStretch() would previously have no effect on Mac OS X/Cocoa.
Task-number: QTBUG-10585
Reviewed-by: Eskil
Done-by: Andy
Diffstat (limited to 'src/gui/text/qfontengine_mac.mm')
-rw-r--r-- | src/gui/text/qfontengine_mac.mm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index a6510cb..3be6d28 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -162,9 +162,14 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con QCFString name; ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name); + transform = CGAffineTransformIdentity; + if (fontDef.stretch != 100) { + transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); + } + QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize); - QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, 0); - ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, 0, symbolicTraits, symbolicTraits); + QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform); + ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does // not exist for the given font. (for example italic) @@ -378,7 +383,10 @@ QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def, if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait)) { synthesisFlags |= SynthesizedItalic; } - + transform = CGAffineTransformIdentity; + if (fontDef.stretch != 100) { + transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1); + } QByteArray os2Table = getSfntTable(MAKE_TAG('O', 'S', '/', '2')); if (os2Table.size() >= 10) fsType = qFromBigEndian<quint16>(reinterpret_cast<const uchar *>(os2Table.constData() + 8)); @@ -503,7 +511,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0)); -// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + cgMatrix = CGAffineTransformConcat(cgMatrix, transform); CGContextSetTextMatrix(ctx, cgMatrix); @@ -626,7 +634,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0)); -// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + cgMatrix = CGAffineTransformConcat(cgMatrix, transform); CGContextSetTextMatrix(ctx, cgMatrix); CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); |