summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-03-30 18:48:39 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-04 15:14:22 +0000
commit5b41b34958792931b910859fd8ad812d8959d60f (patch)
tree10a078f37865a74c64c69e466f39d71e3ef8284e /src/platformsupport/fontdatabases
parenta7fe6ab8915d0a52c130a46817a16f89717eee9d (diff)
macOS: Use NSURL to resolve FreeType font names instead of CoreFoundation
Change-Id: I4b397361c483fa07e4e95288f66d7f7ea2df8d9f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/platformsupport/fontdatabases')
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index d40636e7d7..ea0aab17a0 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -363,30 +363,6 @@ void QCoreTextFontDatabase::releaseHandle(void *handle)
CFRelease(CTFontDescriptorRef(handle));
}
-#ifndef QT_NO_FREETYPE
-static QByteArray filenameForCFUrl(CFURLRef url)
-{
- // The on-stack buffer prevents that a QByteArray allocated for the worst case (MAXPATHLEN)
- // stays around for the lifetime of the font. Additionally, it helps to move the char
- // signedness cast to an acceptable place.
- uchar buffer[MAXPATHLEN];
- QByteArray filename;
-
- if (!CFURLGetFileSystemRepresentation(url, true, buffer, sizeof(buffer))) {
- qWarning("QCoreTextFontDatabase::filenameForCFUrl: could not resolve file for URL %s",
- url ? qPrintable(QString::fromCFString(CFURLGetString(url))) : "(null)");
- } else {
- QCFType<CFStringRef> scheme = CFURLCopyScheme(url);
- if (QString::fromCFString(scheme) == QLatin1String("qrc"))
- filename = ":";
-
- filename += reinterpret_cast<char *>(buffer);
- }
-
- return filename;
-}
-#endif
-
extern CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
template <>
@@ -420,11 +396,16 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QFontEngineFT>::fontEngine(const
{
CTFontDescriptorRef descriptor = static_cast<CTFontDescriptorRef>(usrPtr);
- QCFType<CFURLRef> url(static_cast<CFURLRef>(CTFontDescriptorCopyAttribute(descriptor, kCTFontURLAttribute)));
-
QByteArray filename;
- if (url)
- filename = filenameForCFUrl(url);
+ if (NSURL *url = [static_cast<NSURL *>(CTFontDescriptorCopyAttribute(descriptor, kCTFontURLAttribute)) autorelease]) {
+ if ([url.scheme isEqual:@"qrc"])
+ filename = ":";
+ else if (!url.fileURL)
+ qWarning() << "QFontDatabase: Unknown scheme" << url.scheme << "in font descriptor URL";
+
+ filename += QString::fromNSString(url.path).toUtf8();
+ }
+ Q_ASSERT(!filename.isEmpty());
QFontEngine::FaceId faceId;
faceId.filename = filename;