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 <simon.hausmann@qt.io>bb10
parent
6c547142d5
commit
a7fe6ab891
|
|
@ -468,27 +468,7 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>::fontEngine
|
|||
template <>
|
||||
QFontEngine *QCoreTextFontDatabaseEngineFactory<QFontEngineFT>::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
|
||||
{
|
||||
QByteArray *fontDataCopy = new QByteArray(fontData);
|
||||
QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
|
||||
fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
|
||||
QCFType<CGFontRef> 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<CTFontRef> ctFont(CTFontCreateWithGraphicsFont(cgFont, fontDef.pixelSize, &transform, Q_NULLPTR));
|
||||
QCFType<CFURLRef> url(static_cast<CFURLRef>(CTFontCopyAttribute(ctFont, kCTFontURLAttribute)));
|
||||
|
||||
QFontEngine::FaceId faceId;
|
||||
faceId.filename = filenameForCFUrl(url);
|
||||
return QFontEngineFT::create(fontDef, faceId, fontData);
|
||||
return QFontEngineFT::create(fontData, pixelSize, hintingPreference);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue