From a7fe6ab8915d0a52c130a46817a16f89717eee9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 30 Mar 2017 16:25:41 +0200 Subject: [PATCH] macOS: Use shared code path for creating FreeType font engine for QRawFont The round trip via a CGFontRef to a CTFontRef so that we could pull out the kCTFontURLAttribute of the font makes no sense, as the input is just raw font data. None of the tst_QRawFont tests are able to pull out a URL, and none of the other platforms where FreeType is available resolve a filename from raw fonts. Without this change the tst_QRawFont test has 13 failed test cases and spits out 1250 QWARNs. With the patch all tests pass without warnings. Change-Id: I17965e7405d7161958ff0870825ce8190598288f Reviewed-by: Simon Hausmann --- .../mac/qcoretextfontdatabase.mm | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index fcc94c40b3..d40636e7d7 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -468,27 +468,7 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine template <> QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { - QByteArray *fontDataCopy = new QByteArray(fontData); - QCFType dataProvider = CGDataProviderCreateWithData(fontDataCopy, - fontDataCopy->constData(), fontDataCopy->size(), releaseFontData); - QCFType cgFont(CGFontCreateWithDataProvider(dataProvider)); - - if (!cgFont) { - qWarning("QCoreTextFontDatabase::fontEngine: CGFontCreateWithDataProvider failed"); - return Q_NULLPTR; - } - - QFontDef fontDef; - fontDef.pixelSize = pixelSize; - fontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi(); - fontDef.hintingPreference = hintingPreference; - CGAffineTransform transform = qt_transform_from_fontdef(fontDef); - QCFType ctFont(CTFontCreateWithGraphicsFont(cgFont, fontDef.pixelSize, &transform, Q_NULLPTR)); - QCFType url(static_cast(CTFontCopyAttribute(ctFont, kCTFontURLAttribute))); - - QFontEngine::FaceId faceId; - faceId.filename = filenameForCFUrl(url); - return QFontEngineFT::create(fontDef, faceId, fontData); + return QFontEngineFT::create(fontData, pixelSize, hintingPreference); } #endif