diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2010-09-14 13:12:16 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2010-09-14 13:41:10 (GMT) |
commit | 0ac41424ef143d00461e55087ccceb4b9dc11745 (patch) | |
tree | c66650e4de926a6e0a13890033b43ec4b35a1351 /src/gui/text | |
parent | cb6380beb81ab9571c547270c144988781fed465 (diff) | |
download | Qt-0ac41424ef143d00461e55087ccceb4b9dc11745.zip Qt-0ac41424ef143d00461e55087ccceb4b9dc11745.tar.gz Qt-0ac41424ef143d00461e55087ccceb4b9dc11745.tar.bz2 |
Fix crash in Mac font loading
Commit f2f6330d915cbe3d0989ad280738ed0a6954cd35 introduced an
extra CFRelease of QCFString, which will cause crash. Also,
since we are not refering to ATS font in Cocoa code anymore,
conversion of CTFontRef to CGFontRef should not rely on
platform fonts, we use CTFontCopyGraphicsFont to get the
corresponding CGFontRef directly.
Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase_mac.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontengine_mac.mm | 7 |
2 files changed, 3 insertions, 8 deletions
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 5c41e0a..712bdb4 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -309,11 +309,10 @@ void QFontDatabase::load(const QFontPrivate *d, int script) if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) { QByteArray family_name = db->families[k]->name.toUtf8(); #if defined(QT_MAC_USE_COCOA) - CTFontRef ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL); + QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL); if (ctFont) { fontName = CTFontCopyFullName(ctFont); familyName = CTFontCopyFamilyName(ctFont); - CFRelease(ctFont); goto FamilyFound; } #else @@ -337,7 +336,6 @@ FamilyFound: #ifdef QT_MAC_USE_COCOA fontDef.family = familyName; QFontEngine *engine = new QCoreTextFontEngineMulti(fontName, fontDef, d->kerning); - CFRelease(fontName); #else QCFString actualName; if (ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 894de44..6e524f6 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -419,8 +419,7 @@ QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def, synthesisFlags = 0; ctfont = font; CFRetain(ctfont); - ATSFontRef atsfont = CTFontGetPlatformFont(ctfont, 0); - cgFont = CGFontCreateWithPlatformFont(&atsfont); + cgFont = CTFontCopyGraphicsFont(ctfont, NULL); CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont); if (fontDef.weight >= QFont::Bold && !(traits & kCTFontBoldTrait)) { synthesisFlags |= SynthesizedBold; @@ -440,8 +439,8 @@ QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def, QCoreTextFontEngine::~QCoreTextFontEngine() { - CFRelease(ctfont); CFRelease(cgFont); + CFRelease(ctfont); } bool QCoreTextFontEngine::stringToCMap(const QChar *, int, QGlyphLayout *, int *, QTextEngine::ShaperFlags) const @@ -693,8 +692,6 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); CGContextSetTextDrawingMode(ctx, kCGTextFill); - ATSFontRef atsfont = CTFontGetPlatformFont(ctfont, 0); - QCFType<CGFontRef> cgFont = CGFontCreateWithPlatformFont(&atsfont); CGContextSetFont(ctx, cgFont); qreal pos_x = -br.x.toReal() + subPixelPosition.toReal(); |