summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-07-02 13:18:50 +0200
committerGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-08-11 10:46:13 +0200
commit909d3f5c733dde02074a737a5f1dbe3e51dbef32 (patch)
tree9707cd00cd97215df12724df79597f74f3c2ed44 /src
parent3924805d595f18820f127ab33486d076102afec6 (diff)
Font Database: Add support for private, system UI font families
We introduce QPlatformFontDatabase::isPrivateFontFamily() to allow testing for private, system UI font families. Both QFontComboBox and QFontDialog need to filter out those private font families which, by definition, should be hidden from the end user. (The textedit example had to be updated to fix the issue where the default font would be private. In 5.4, we will be adding an equivalent, public API in QFontDatabase, and a better solution for the textedit example and QTexEdit in general). In particular, on OS X and iOS, private fonts are used for the system UI font. Those have their font family name prefixed by a dot. QCoreTextFontDatabase knows about this, and makes sure those are tested positive as private font families. In order to have a cleaner layer separation, we moved the QPA theme font resolution from the platform theme classes into QCoreTextFontDatabase for both Cocoa and iOS QPA plugins. In both cases, we use CoreText's CTFontCreateUIFontForLanguage(), that nicely maps to the HITheme API we were using so far on Mac. That means one HITheme dependency less. We also cache the font descriptors we get for these font for each time QCTFD::populateFamilies() gets called. (While not common, this currently happens in auto-tests, like tst_QFontDatabase, and could happen in actual applications -- specially when adding and removing application fonts.) Change-Id: Ic6f0b60f9f597afee1a43596a669742dc546b97f Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp10
-rw-r--r--src/gui/text/qplatformfontdatabase.h1
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm183
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h11
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm44
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm7
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm19
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp9
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp9
10 files changed, 212 insertions, 82 deletions
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 33301005c6..2c3a1d7f70 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -402,6 +402,16 @@ QString QPlatformFontDatabase::fontDir() const
}
/*!
+ Returns true if the font family is private. For any given family name,
+ the result is platform dependent.
+*/
+bool QPlatformFontDatabase::isPrivateFontFamily(const QString &family) const
+{
+ Q_UNUSED(family);
+ return false;
+}
+
+/*!
Returns the default system font.
\sa QGuiApplication::font()
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index b200cf0e58..46ef5c0f46 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -110,6 +110,7 @@ public:
virtual QString fontDir() const;
virtual QFont defaultFont() const;
+ virtual bool isPrivateFontFamily(const QString &family) const;
virtual QString resolveFontFamilyAlias(const QString &family) const;
virtual bool fontsAlwaysScalable() const;
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 4aa4253773..cff90f420b 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -211,6 +211,13 @@ void QCoreTextFontDatabase::populateFontDatabase()
QPlatformFontDatabase::registerAliasToFontFamily(familyName, localizedFamilyName);
#endif
}
+
+ // Force creating the theme fonts to get the descriptors in m_systemFontDescriptors
+ if (m_themeFonts.isEmpty())
+ (void)themeFonts();
+
+ Q_FOREACH (CTFontDescriptorRef fontDesc, m_systemFontDescriptors)
+ populateFromDescriptor(fontDesc);
}
void QCoreTextFontDatabase::populateFamily(const QString &familyName)
@@ -231,16 +238,29 @@ void QCoreTextFontDatabase::populateFamily(const QString &familyName)
populateFromDescriptor(CTFontDescriptorRef(CFArrayGetValueAtIndex(matchingFonts, i)));
}
-void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font)
+struct FontDescription {
+ QCFString familyName;
+ QCFString styleName;
+ QString foundryName;
+ QFont::Weight weight;
+ QFont::Style style;
+ QFont::Stretch stretch;
+ int pixelSize;
+ bool fixedPitch;
+ QSupportedWritingSystems writingSystems;
+};
+
+static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
{
- QString foundryName = QStringLiteral("CoreText");
- QCFString familyName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
- QCFString styleName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
QCFType<CFDictionaryRef> styles = (CFDictionaryRef) CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute);
- QFont::Weight weight = QFont::Normal;
- QFont::Style style = QFont::StyleNormal;
- QFont::Stretch stretch = QFont::Unstretched;
- bool fixedPitch = false;
+
+ fd->foundryName = QStringLiteral("CoreText");
+ fd->familyName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ fd->styleName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
+ fd->weight = QFont::Normal;
+ fd->style = QFont::StyleNormal;
+ fd->stretch = QFont::Unstretched;
+ fd->fixedPitch = false;
if (styles) {
if (CFNumberRef weightValue = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
@@ -248,15 +268,15 @@ void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font)
double normalizedWeight;
if (CFNumberGetValue(weightValue, kCFNumberDoubleType, &normalizedWeight)) {
if (normalizedWeight >= 0.62)
- weight = QFont::Black;
+ fd->weight = QFont::Black;
else if (normalizedWeight >= 0.4)
- weight = QFont::Bold;
+ fd->weight = QFont::Bold;
else if (normalizedWeight >= 0.3)
- weight = QFont::DemiBold;
+ fd->weight = QFont::DemiBold;
else if (normalizedWeight == 0.0)
- weight = QFont::Normal;
+ fd->weight = QFont::Normal;
else if (normalizedWeight <= -0.4)
- weight = QFont::Light;
+ fd->weight = QFont::Light;
}
}
if (CFNumberRef italic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
@@ -264,34 +284,32 @@ void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font)
double d;
if (CFNumberGetValue(italic, kCFNumberDoubleType, &d)) {
if (d > 0.0)
- style = QFont::StyleItalic;
+ fd->style = QFont::StyleItalic;
}
}
if (CFNumberRef symbolic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSymbolicTrait)) {
int d;
if (CFNumberGetValue(symbolic, kCFNumberSInt32Type, &d)) {
if (d & kCTFontMonoSpaceTrait)
- fixedPitch = true;
+ fd->fixedPitch = true;
if (d & kCTFontExpandedTrait)
- stretch = QFont::Expanded;
+ fd->stretch = QFont::Expanded;
else if (d & kCTFontCondensedTrait)
- stretch = QFont::Condensed;
+ fd->stretch = QFont::Condensed;
}
}
}
- int pixelSize = 0;
if (QCFType<CFNumberRef> size = (CFNumberRef) CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute)) {
if (CFNumberIsFloatType(size)) {
double d;
CFNumberGetValue(size, kCFNumberDoubleType, &d);
- pixelSize = d;
+ fd->pixelSize = d;
} else {
- CFNumberGetValue(size, kCFNumberIntType, &pixelSize);
+ CFNumberGetValue(size, kCFNumberIntType, &fd->pixelSize);
}
}
- QSupportedWritingSystems writingSystems;
if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
CFIndex length = CFArrayGetCount(languages);
for (int i = 1; i < LanguageCount; ++i) {
@@ -299,14 +317,24 @@ void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font)
continue;
QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII);
if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang))
- writingSystems.setSupported(QFontDatabase::WritingSystem(i));
+ fd->writingSystems.setSupported(QFontDatabase::WritingSystem(i));
}
}
+}
+void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font)
+{
+ FontDescription fd;
+ getFontDescription(font, &fd);
+ populateFromFontDescription(font, fd);
+}
+
+void QCoreTextFontDatabase::populateFromFontDescription(CTFontDescriptorRef font, const FontDescription &fd)
+{
CFRetain(font);
- QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch,
+ QPlatformFontDatabase::registerFont(fd.familyName, fd.styleName, fd.foundryName, fd.weight, fd.style, fd.stretch,
true /* antialiased */, true /* scalable */,
- pixelSize, fixedPitch, writingSystems, (void *) font);
+ fd.pixelSize, fd.fixedPitch, fd.writingSystems, (void *) font);
}
void QCoreTextFontDatabase::releaseHandle(void *handle)
@@ -612,6 +640,113 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
return families;
}
+bool QCoreTextFontDatabase::isPrivateFontFamily(const QString &family) const
+{
+ if (family.startsWith(QLatin1Char('.')))
+ return true;
+
+ return QPlatformFontDatabase::isPrivateFontFamily(family);
+}
+
+static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f)
+{
+ switch (f) {
+ case QPlatformTheme::SystemFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::MenuFont:
+ case QPlatformTheme::MenuBarFont:
+ case QPlatformTheme::MenuItemFont:
+ return kCTFontMenuItemFontType;
+
+ case QPlatformTheme::MessageBoxFont:
+ return kCTFontEmphasizedSystemFontType;
+
+ case QPlatformTheme::LabelFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::TipLabelFont:
+ return kCTFontToolTipFontType;
+
+ case QPlatformTheme::StatusBarFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::TitleBarFont:
+ return kCTFontWindowTitleFontType;
+
+ case QPlatformTheme::MdiSubWindowTitleFont:
+ case QPlatformTheme::DockWidgetTitleFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::PushButtonFont:
+ return kCTFontPushButtonFontType;
+
+ case QPlatformTheme::CheckBoxFont:
+ case QPlatformTheme::RadioButtonFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::ToolButtonFont:
+ return kCTFontSmallToolbarFontType;
+
+ case QPlatformTheme::ItemViewFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::ListViewFont:
+ return kCTFontViewsFontType;
+
+ case QPlatformTheme::HeaderViewFont:
+ return kCTFontSmallSystemFontType;
+
+ case QPlatformTheme::ListBoxFont:
+ return kCTFontViewsFontType;
+
+ case QPlatformTheme::ComboMenuItemFont:
+ return kCTFontSystemFontType;
+
+ case QPlatformTheme::ComboLineEditFont:
+ return kCTFontViewsFontType;
+
+ case QPlatformTheme::SmallFont:
+ return kCTFontSmallSystemFontType;
+
+ case QPlatformTheme::MiniFont:
+ return kCTFontMiniSystemFontType;
+
+ case QPlatformTheme::FixedFont:
+ return kCTFontUserFixedPitchFontType;
+
+ default:
+ return kCTFontSystemFontType;
+ }
+}
+
+const QHash<QPlatformTheme::Font, QFont *> &QCoreTextFontDatabase::themeFonts() const
+{
+ if (m_themeFonts.isEmpty()) {
+ for (long f = QPlatformTheme::SystemFont; f < QPlatformTheme::NFonts; f++) {
+ QPlatformTheme::Font ft = static_cast<QPlatformTheme::Font>(f);
+ m_themeFonts.insert(ft, themeFont(ft));
+ }
+ }
+
+ return m_themeFonts;
+}
+
+QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const
+{
+ CTFontUIFontType fontType = fontTypeFromTheme(f);
+
+ QCFType<CTFontRef> ctFont = CTFontCreateUIFontForLanguage(fontType, 0.0, NULL);
+ CTFontDescriptorRef fontDesc = CTFontCopyFontDescriptor(ctFont);
+
+ FontDescription fd;
+ getFontDescription(fontDesc, &fd);
+ m_systemFontDescriptors.insert(fontDesc);
+
+ QFont *font = new QFont(fd.familyName, fd.pixelSize, fd.weight, fd.style == QFont::StyleItalic);
+ return font;
+}
+
QFont QCoreTextFontDatabase::defaultFont() const
{
if (defaultFontName.isEmpty()) {
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index c73f4a32ca..a3da27b28d 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -47,6 +47,7 @@
#define HAVE_ATS QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_5, __IPHONE_NA)
#include <qpa/qplatformfontdatabase.h>
+#include <qpa/qplatformtheme.h>
#include <private/qcore_mac_p.h>
#ifndef Q_OS_IOS
@@ -66,6 +67,8 @@ Q_DECLARE_METATYPE(ATSFontContainerRef);
QT_BEGIN_NAMESPACE
+struct FontDescription;
+
class QCoreTextFontDatabase : public QPlatformFontDatabase
{
public:
@@ -79,17 +82,25 @@ public:
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
void releaseHandle(void *handle);
+ bool isPrivateFontFamily(const QString &family) const;
QFont defaultFont() const;
QList<int> standardSizes() const;
+ // For iOS and OS X platform themes
+ QFont *themeFont(QPlatformTheme::Font) const;
+ const QHash<QPlatformTheme::Font, QFont *> &themeFonts() const;
+
private:
void populateFromDescriptor(CTFontDescriptorRef font);
+ void populateFromFontDescription(CTFontDescriptorRef font, const FontDescription &fd);
mutable QString defaultFontName;
void removeApplicationFonts();
QVector<QVariant> m_applicationFonts;
+ mutable QSet<CTFontDescriptorRef> m_systemFontDescriptors;
+ mutable QHash<QPlatformTheme::Font, QFont *> m_themeFonts;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/cocoa/qcocoasystemsettings.h
index 9ce301f7e7..3861da6230 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.h
@@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE
QPalette * qt_mac_createSystemPalette();
QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes();
-QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts();
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index f18be8b69c..67fa66ad63 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -230,48 +230,4 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
return palettes;
}
-QFont *qt_mac_qfontForThemeFont(ThemeFontID themeID)
-{
- CTFontUIFontType ctID = HIThemeGetUIFontType(themeID);
- QCFType<CTFontRef> ctfont = CTFontCreateUIFontForLanguage(ctID, 0, 0);
- QString familyName = QCFString(CTFontCopyFamilyName(ctfont));
- QCFType<CFDictionaryRef> dict = CTFontCopyTraits(ctfont);
- CFNumberRef num = static_cast<CFNumberRef>(CFDictionaryGetValue(dict, kCTFontWeightTrait));
- float fW;
- CFNumberGetValue(num, kCFNumberFloat32Type, &fW);
- QFont::Weight wght = fW > 0. ? QFont::Bold : QFont::Normal;
- num = static_cast<CFNumberRef>(CFDictionaryGetValue(dict, kCTFontSlantTrait));
- CFNumberGetValue(num, kCFNumberFloatType, &fW);
- bool italic = (fW != 0.0);
- return new QFont(familyName, CTFontGetSize(ctfont), wght, italic);
-}
-
-QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts()
-{
- QHash<QPlatformTheme::Font, QFont *> fonts;
-
- fonts.insert(QPlatformTheme::SystemFont, qt_mac_qfontForThemeFont(kThemeApplicationFont));
- fonts.insert(QPlatformTheme::PushButtonFont, qt_mac_qfontForThemeFont(kThemePushButtonFont));
- fonts.insert(QPlatformTheme::ListViewFont, qt_mac_qfontForThemeFont(kThemeViewsFont));
- fonts.insert(QPlatformTheme::ListBoxFont, qt_mac_qfontForThemeFont(kThemeViewsFont));
- fonts.insert(QPlatformTheme::TitleBarFont, qt_mac_qfontForThemeFont(kThemeWindowTitleFont));
- fonts.insert(QPlatformTheme::MenuFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont));
- fonts.insert(QPlatformTheme::MenuBarFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont));
- fonts.insert(QPlatformTheme::ComboMenuItemFont, qt_mac_qfontForThemeFont(kThemeSystemFont));
- fonts.insert(QPlatformTheme::HeaderViewFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont));
- fonts.insert(QPlatformTheme::TipLabelFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont));
- fonts.insert(QPlatformTheme::LabelFont, qt_mac_qfontForThemeFont(kThemeSystemFont));
- fonts.insert(QPlatformTheme::ToolButtonFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont));
- fonts.insert(QPlatformTheme::MenuItemFont, qt_mac_qfontForThemeFont(kThemeMenuItemFont));
- fonts.insert(QPlatformTheme::ComboLineEditFont, qt_mac_qfontForThemeFont(kThemeViewsFont));
- fonts.insert(QPlatformTheme::SmallFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont));
- fonts.insert(QPlatformTheme::MiniFont, qt_mac_qfontForThemeFont(kThemeMiniSystemFont));
-
- QFont* fixedFont = new QFont(QStringLiteral("Monaco"), fonts[QPlatformTheme::SystemFont]->pointSize());
- fixedFont->setStyleHint(QFont::TypeWriter);
- fonts.insert(QPlatformTheme::FixedFont, fixedFont);
-
- return fonts;
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index dce1671800..ae42fee82c 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -60,6 +60,7 @@
#include <QtCore/qfileinfo.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpainter.h>
+#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
@@ -134,6 +135,12 @@ const QPalette *QCocoaTheme::palette(Palette type) const
return 0;
}
+QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts()
+{
+ QCoreTextFontDatabase *ctfd = static_cast<QCoreTextFontDatabase *>(QGuiApplicationPrivate::platformIntegration()->fontDatabase());
+ return ctfd->themeFonts();
+}
+
const QFont *QCocoaTheme::font(Font type) const
{
if (m_fonts.isEmpty()) {
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index e7093185aa..e51e97bd5a 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -46,6 +46,10 @@
#include <QtGui/QFont>
+#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
#include <UIKit/UIFont.h>
#include <UIKit/UIInterface.h>
@@ -75,19 +79,8 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const
const QFont *QIOSTheme::font(Font type) const
{
if (m_fonts.isEmpty()) {
- // The real system font on iOS is '.Helvetica Neue UI', as returned by both [UIFont systemFontOfSize]
- // and CTFontCreateUIFontForLanguage(kCTFontSystemFontType, ...), but this font is not included when
- // populating the available fonts in QCoreTextFontDatabase::populateFontDatabase(), since the font
- // is internal to iOS and not supposed to be used by applications. We could potentially add this
- // font to the font-database, but it would then show up when enumerating user fonts from Qt
- // applications since we don't have a flag in Qt to mark a font as a private system font.
- // For now we hard-code the font to Helvetica, which should be very close to the actual
- // system font.
- QLatin1String systemFontFamilyName("Helvetica");
- m_fonts.insert(QPlatformTheme::SystemFont, new QFont(systemFontFamilyName, [UIFont systemFontSize]));
- m_fonts.insert(QPlatformTheme::SmallFont, new QFont(systemFontFamilyName, [UIFont smallSystemFontSize]));
- m_fonts.insert(QPlatformTheme::LabelFont, new QFont(systemFontFamilyName, [UIFont labelFontSize]));
- m_fonts.insert(QPlatformTheme::PushButtonFont, new QFont(systemFontFamilyName, [UIFont buttonFontSize]));
+ QCoreTextFontDatabase *ctfd = static_cast<QCoreTextFontDatabase *>(QGuiApplicationPrivate::platformIntegration()->fontDatabase());
+ m_fonts = ctfd->themeFonts();
}
return m_fonts.value(type, 0);
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 5a68bfbc66..fc9f36f0c2 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -65,6 +65,10 @@
#include <private/qdialog_p.h>
#include <private/qfont_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformfontdatabase.h>
+
QT_BEGIN_NAMESPACE
class QFontListView : public QListView
@@ -485,8 +489,13 @@ void QFontDialogPrivate::updateFamilies()
const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
const QFontDialog::FontDialogOptions options = q->options();
+ QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
+
QStringList familyNames;
foreach (const QString &family, fdb.families(writingSystem)) {
+ if (pfdb->isPrivateFontFamily(family))
+ continue;
+
if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
if (bool(options & QFontDialog::ScalableFonts) != fdb.isSmoothlyScalable(family))
continue;
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index db01543629..bdf5092d9e 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -53,6 +53,10 @@
#include <QDesktopWidget>
#include <qdebug.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformfontdatabase.h>
+
QT_BEGIN_NAMESPACE
static QFontDatabase::WritingSystem writingSystemFromScript(QLocale::Script script)
@@ -328,7 +332,12 @@ void QFontComboBoxPrivate::_q_updateModel()
int offset = 0;
QFontInfo fi(currentFont);
+ QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
+
for (int i = 0; i < list.size(); ++i) {
+ if (pfdb->isPrivateFontFamily(list.at(i)))
+ continue;
+
if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) {
if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i)))
continue;