summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm34
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h12
2 files changed, 24 insertions, 22 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 38c44e3f35..1b468b3eff 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -491,7 +491,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
bool success = CTFontManagerRegisterGraphicsFont(cgFont, &error);
if (success) {
font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
- m_applicationGraphicsFonts.append(QCFType<CGFontRef>::constructFromGet(cgFont));
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
} else {
NSLog(@"Unable to register font: %@", error);
CFRelease(error);
@@ -509,7 +509,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
- m_applicationURLFonts.append(QCFType<CFURLRef>::constructFromGet(fontURL));
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CFURLRef>::constructFromGet(fontURL)));
} else {
NSLog(@"Unable to register font: %@", error);
CFRelease(error);
@@ -564,7 +564,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
families.append(QCFString(CTFontCopyFamilyName(font)));
}
- m_applicationFonts.append(fontContainer);
+ m_applicationFonts.append(QVariant::fromValue(fontContainer));
return families;
}
}
@@ -597,24 +597,24 @@ QList<int> QCoreTextFontDatabase::standardSizes() const
void QCoreTextFontDatabase::removeApplicationFonts()
{
#ifdef Q_OS_MACX
+ foreach (const QVariant &font, m_applicationFonts) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- CFErrorRef error;
- for (int i = 0; i < m_applicationGraphicsFonts.count(); ++i)
- CTFontManagerUnregisterGraphicsFont(m_applicationGraphicsFonts[i], &error);
- m_applicationGraphicsFonts.clear();
-
- for (int i = 0; i < m_applicationURLFonts.count(); ++i)
- CTFontManagerUnregisterFontsForURL(m_applicationURLFonts[i], kCTFontManagerScopeProcess, &error);
- m_applicationURLFonts.clear();
- } else
+ if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
+ CFErrorRef error;
+ if (font.canConvert(qMetaTypeId<QCFType<CGFontRef>>())) {
+ CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef>>(), &error);
+ } else if (font.canConvert(qMetaTypeId<QCFType<CFURLRef>>())) {
+ CTFontManagerUnregisterFontsForURL(font.value<QCFType<CFURLRef>>(), kCTFontManagerScopeProcess, &error);
+ }
+ } else
#endif
- {
- for (int i = 0; i < m_applicationFonts.count(); ++i)
- ATSFontDeactivate(m_applicationFonts[i], 0, kATSOptionFlagsDoNotNotify);
+ if (font.canConvert(qMetaTypeId<ATSFontContainerRef>())) {
+ ATSFontDeactivate(font.value<ATSFontContainerRef>(), 0, kATSOptionFlagsDoNotNotify);
+ }
+ }
+
m_applicationFonts.clear();
ATSFontNotify(kATSFontNotifyActionFontsChanged, 0);
- }
#endif
}
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index ee1016509b..da0c1d338b 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -52,6 +52,12 @@
#include <CoreGraphics/CoreGraphics.h>
#endif
+#ifdef Q_OS_MACX
+Q_DECLARE_METATYPE(QCFType<CGFontRef>);
+Q_DECLARE_METATYPE(QCFType<CFURLRef>);
+Q_DECLARE_METATYPE(ATSFontContainerRef);
+#endif
+
QT_BEGIN_NAMESPACE
class QCoreTextFontDatabase : public QPlatformFontDatabase
@@ -79,11 +85,7 @@ private:
void removeApplicationFonts();
#ifdef Q_OS_MACX
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- QVector<QCFType<CGFontRef> > m_applicationGraphicsFonts;
- QVector<QCFType<CFURLRef> > m_applicationURLFonts;
-#endif
- QVector<ATSFontContainerRef> m_applicationFonts;
+ QVector<QVariant> m_applicationFonts;
#endif
};