Introduce QFontDatabase::isPrivateFamily()

Some platforms have the concept of private fonts (e.g., OS X and
iOS) which are generally used as system UI fonts. Since 909d3f5c7,
the platform font database has a similar but private API.

[ChangeLog][QtGui][Fonts] Added QFontDatabase::isPrivateFamily()

Change-Id: Ibdce9de534fadbbc3965be8a942c8012edeed209
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Gabriel de Dietrich 2014-08-07 17:07:35 +02:00 committed by Tor Arne Vestbø
parent b45db5480d
commit c87566bf9e
4 changed files with 22 additions and 13 deletions

View File

@ -1935,6 +1935,24 @@ bool QFontDatabase::hasFamily(const QString &family) const
}
/*!
\since 5.5
Returns \c true if and only if the \a family font family is private.
This happens, for instance, on OS X and iOS, where the system UI fonts are not
accessible to the user. For completeness, QFontDatabase::families() returns all
font families, including the private ones. You should use this function if you
are developing a font selection control in order to keep private fonts hidden.
\sa families()
*/
bool QFontDatabase::isPrivateFamily(const QString &family) const
{
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
}
/*!
Returns the names the \a writingSystem (e.g. for displaying to the
user in a dialog).

View File

@ -132,6 +132,7 @@ public:
int weight(const QString &family, const QString &style) const;
bool hasFamily(const QString &family) const;
bool isPrivateFamily(const QString &family) const;
static QString writingSystemName(WritingSystem writingSystem);
static QString writingSystemSample(WritingSystem writingSystem);

View File

@ -57,10 +57,6 @@
#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
@ -482,11 +478,11 @@ void QFontDialogPrivate::updateFamilies()
const QFontDialog::FontDialogOptions spacingMask = (QFontDialog::ProportionalFonts | QFontDialog::MonospacedFonts);
const QFontDialog::FontDialogOptions options = q->options();
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontDatabase fdb;
QStringList familyNames;
foreach (const QString &family, fdb.families(writingSystem)) {
if (pfdb->isPrivateFontFamily(family))
if (fdb.isPrivateFamily(family))
continue;
if ((options & scalableMask) && (options & scalableMask) != scalableMask) {

View File

@ -45,10 +45,6 @@
#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)
@ -324,10 +320,8 @@ 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)))
if (fdb.isPrivateFamily(list.at(i)))
continue;
if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) {