Make QFontDatabase member functions static
QFontDatabase is a singleton and all instances would share a single, mutex-protected global data pointer. But some functions were implemented as non-static functions. This caused a lot of code on the form QFontDatabase().families(...) since there was no static access. Other functions were implemented as static. To consolidate, we make all functions static. This should be source-compatible, but not binary compatible. [ChangeLog][QtGui][Fonts] Some functions in QFontDatabase were in principle static, but previously not implemented as such. All member functions have now been made static, so that constructing objects of QFontDatabase is no longer necessary to access certain functionality. Fixes: QTBUG-83284 Change-Id: Ifd8c15016281c71f631b53387402c942cd9c43f6 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
b7a1bd3064
commit
76068d0114
@ -1253,12 +1253,6 @@ QString QFontDatabase::styleString(const QFontInfo &fontInfo)
|
|||||||
*/
|
*/
|
||||||
QFontDatabase::QFontDatabase()
|
QFontDatabase::QFontDatabase()
|
||||||
{
|
{
|
||||||
if (Q_UNLIKELY(!qApp || !QGuiApplicationPrivate::platformIntegration()))
|
|
||||||
qFatal("QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase");
|
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
|
||||||
createDatabase();
|
|
||||||
d = privateDb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1314,6 +1308,24 @@ QFontDatabase::QFontDatabase()
|
|||||||
\since 5.2
|
\since 5.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
|
||||||
|
Initializes the font database if necessary and returns its
|
||||||
|
pointer. Mutex lock must be held when calling this function.
|
||||||
|
*/
|
||||||
|
QFontDatabasePrivate *QFontDatabase::ensureFontDatabase()
|
||||||
|
{
|
||||||
|
QFontDatabasePrivate *d = privateDb();
|
||||||
|
if (d->count == 0) {
|
||||||
|
if (Q_UNLIKELY(qGuiApp == nullptr || QGuiApplicationPrivate::platformIntegration() == nullptr))
|
||||||
|
qFatal("QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase");
|
||||||
|
|
||||||
|
initializeDb();
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns a sorted list of the available writing systems. This is
|
Returns a sorted list of the available writing systems. This is
|
||||||
list generated from information about all installed fonts on the
|
list generated from information about all installed fonts on the
|
||||||
@ -1321,9 +1333,10 @@ QFontDatabase::QFontDatabase()
|
|||||||
|
|
||||||
\sa families()
|
\sa families()
|
||||||
*/
|
*/
|
||||||
QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const
|
QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)();
|
QT_PREPEND_NAMESPACE(load)();
|
||||||
|
|
||||||
@ -1361,12 +1374,13 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const
|
|||||||
|
|
||||||
\sa families()
|
\sa families()
|
||||||
*/
|
*/
|
||||||
QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems(const QString &family) const
|
QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems(const QString &family)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)();
|
QT_PREPEND_NAMESPACE(load)();
|
||||||
|
|
||||||
@ -1394,9 +1408,10 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems(const QString
|
|||||||
|
|
||||||
\sa writingSystems()
|
\sa writingSystems()
|
||||||
*/
|
*/
|
||||||
QStringList QFontDatabase::families(WritingSystem writingSystem) const
|
QStringList QFontDatabase::families(WritingSystem writingSystem)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)();
|
QT_PREPEND_NAMESPACE(load)();
|
||||||
|
|
||||||
@ -1435,12 +1450,13 @@ QStringList QFontDatabase::families(WritingSystem writingSystem) const
|
|||||||
|
|
||||||
\sa families()
|
\sa families()
|
||||||
*/
|
*/
|
||||||
QStringList QFontDatabase::styles(const QString &family) const
|
QStringList QFontDatabase::styles(const QString &family)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1477,7 +1493,7 @@ QStringList QFontDatabase::styles(const QString &family) const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool QFontDatabase::isFixedPitch(const QString &family,
|
bool QFontDatabase::isFixedPitch(const QString &family,
|
||||||
const QString &style) const
|
const QString &style)
|
||||||
{
|
{
|
||||||
Q_UNUSED(style);
|
Q_UNUSED(style);
|
||||||
|
|
||||||
@ -1485,6 +1501,7 @@ bool QFontDatabase::isFixedPitch(const QString &family,
|
|||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1503,13 +1520,14 @@ bool QFontDatabase::isFixedPitch(const QString &family,
|
|||||||
\sa isScalable(), isSmoothlyScalable()
|
\sa isScalable(), isSmoothlyScalable()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::isBitmapScalable(const QString &family,
|
bool QFontDatabase::isBitmapScalable(const QString &family,
|
||||||
const QString &style) const
|
const QString &style)
|
||||||
{
|
{
|
||||||
bool bitmapScalable = false;
|
bool bitmapScalable = false;
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1543,13 +1561,14 @@ bool QFontDatabase::isBitmapScalable(const QString &family,
|
|||||||
|
|
||||||
\sa isScalable(), isBitmapScalable()
|
\sa isScalable(), isBitmapScalable()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style) const
|
bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style)
|
||||||
{
|
{
|
||||||
bool smoothScalable = false;
|
bool smoothScalable = false;
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1589,7 +1608,7 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty
|
|||||||
\sa isBitmapScalable(), isSmoothlyScalable()
|
\sa isBitmapScalable(), isSmoothlyScalable()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::isScalable(const QString &family,
|
bool QFontDatabase::isScalable(const QString &family,
|
||||||
const QString &style) const
|
const QString &style)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
if (isSmoothlyScalable(family, style))
|
if (isSmoothlyScalable(family, style))
|
||||||
@ -1605,7 +1624,7 @@ bool QFontDatabase::isScalable(const QString &family,
|
|||||||
\sa smoothSizes(), standardSizes()
|
\sa smoothSizes(), standardSizes()
|
||||||
*/
|
*/
|
||||||
QList<int> QFontDatabase::pointSizes(const QString &family,
|
QList<int> QFontDatabase::pointSizes(const QString &family,
|
||||||
const QString &styleName)
|
const QString &styleName)
|
||||||
{
|
{
|
||||||
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
|
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
|
||||||
return standardSizes();
|
return standardSizes();
|
||||||
@ -1615,6 +1634,7 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
|
|||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1663,12 +1683,13 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
|
|||||||
returned.
|
returned.
|
||||||
*/
|
*/
|
||||||
QFont QFontDatabase::font(const QString &family, const QString &style,
|
QFont QFontDatabase::font(const QString &family, const QString &style,
|
||||||
int pointSize) const
|
int pointSize)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1717,6 +1738,7 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
|
|||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1776,12 +1798,13 @@ QList<int> QFontDatabase::standardSizes()
|
|||||||
|
|
||||||
\sa weight(), bold()
|
\sa weight(), bold()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::italic(const QString &family, const QString &style) const
|
bool QFontDatabase::italic(const QString &family, const QString &style)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1810,12 +1833,13 @@ bool QFontDatabase::italic(const QString &family, const QString &style) const
|
|||||||
\sa italic(), weight()
|
\sa italic(), weight()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::bold(const QString &family,
|
bool QFontDatabase::bold(const QString &family,
|
||||||
const QString &style) const
|
const QString &style)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1846,12 +1870,13 @@ bool QFontDatabase::bold(const QString &family,
|
|||||||
\sa italic(), bold()
|
\sa italic(), bold()
|
||||||
*/
|
*/
|
||||||
int QFontDatabase::weight(const QString &family,
|
int QFontDatabase::weight(const QString &family,
|
||||||
const QString &style) const
|
const QString &style)
|
||||||
{
|
{
|
||||||
QString familyName, foundryName;
|
QString familyName, foundryName;
|
||||||
parseFontName(family, foundryName, familyName);
|
parseFontName(family, foundryName, familyName);
|
||||||
|
|
||||||
QMutexLocker locker(fontDatabaseMutex());
|
QMutexLocker locker(fontDatabaseMutex());
|
||||||
|
QFontDatabasePrivate *d = ensureFontDatabase();
|
||||||
|
|
||||||
QT_PREPEND_NAMESPACE(load)(familyName);
|
QT_PREPEND_NAMESPACE(load)(familyName);
|
||||||
|
|
||||||
@ -1875,7 +1900,7 @@ int QFontDatabase::weight(const QString &family,
|
|||||||
|
|
||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
bool QFontDatabase::hasFamily(const QString &family) const
|
bool QFontDatabase::hasFamily(const QString &family)
|
||||||
{
|
{
|
||||||
QString parsedFamily, foundry;
|
QString parsedFamily, foundry;
|
||||||
parseFontName(family, foundry, parsedFamily);
|
parseFontName(family, foundry, parsedFamily);
|
||||||
@ -1896,7 +1921,7 @@ bool QFontDatabase::hasFamily(const QString &family) const
|
|||||||
|
|
||||||
\sa families()
|
\sa families()
|
||||||
*/
|
*/
|
||||||
bool QFontDatabase::isPrivateFamily(const QString &family) const
|
bool QFontDatabase::isPrivateFamily(const QString &family)
|
||||||
{
|
{
|
||||||
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
|
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->isPrivateFontFamily(family);
|
||||||
}
|
}
|
||||||
|
@ -116,29 +116,29 @@ public:
|
|||||||
|
|
||||||
QFontDatabase();
|
QFontDatabase();
|
||||||
|
|
||||||
QList<WritingSystem> writingSystems() const;
|
static QList<WritingSystem> writingSystems();
|
||||||
QList<WritingSystem> writingSystems(const QString &family) const;
|
static QList<WritingSystem> writingSystems(const QString &family);
|
||||||
|
|
||||||
QStringList families(WritingSystem writingSystem = Any) const;
|
static QStringList families(WritingSystem writingSystem = Any);
|
||||||
QStringList styles(const QString &family) const;
|
static QStringList styles(const QString &family);
|
||||||
QList<int> pointSizes(const QString &family, const QString &style = QString());
|
static QList<int> pointSizes(const QString &family, const QString &style = QString());
|
||||||
QList<int> smoothSizes(const QString &family, const QString &style);
|
static QList<int> smoothSizes(const QString &family, const QString &style);
|
||||||
QString styleString(const QFont &font);
|
static QString styleString(const QFont &font);
|
||||||
QString styleString(const QFontInfo &fontInfo);
|
static QString styleString(const QFontInfo &fontInfo);
|
||||||
|
|
||||||
QFont font(const QString &family, const QString &style, int pointSize) const;
|
static QFont font(const QString &family, const QString &style, int pointSize);
|
||||||
|
|
||||||
bool isBitmapScalable(const QString &family, const QString &style = QString()) const;
|
static bool isBitmapScalable(const QString &family, const QString &style = QString());
|
||||||
bool isSmoothlyScalable(const QString &family, const QString &style = QString()) const;
|
static bool isSmoothlyScalable(const QString &family, const QString &style = QString());
|
||||||
bool isScalable(const QString &family, const QString &style = QString()) const;
|
static bool isScalable(const QString &family, const QString &style = QString());
|
||||||
bool isFixedPitch(const QString &family, const QString &style = QString()) const;
|
static bool isFixedPitch(const QString &family, const QString &style = QString());
|
||||||
|
|
||||||
bool italic(const QString &family, const QString &style) const;
|
static bool italic(const QString &family, const QString &style);
|
||||||
bool bold(const QString &family, const QString &style) const;
|
static bool bold(const QString &family, const QString &style);
|
||||||
int weight(const QString &family, const QString &style) const;
|
static int weight(const QString &family, const QString &style);
|
||||||
|
|
||||||
bool hasFamily(const QString &family) const;
|
static bool hasFamily(const QString &family);
|
||||||
bool isPrivateFamily(const QString &family) const;
|
static bool isPrivateFamily(const QString &family);
|
||||||
|
|
||||||
static QString writingSystemName(WritingSystem writingSystem);
|
static QString writingSystemName(WritingSystem writingSystem);
|
||||||
static QString writingSystemSample(WritingSystem writingSystem);
|
static QString writingSystemSample(WritingSystem writingSystem);
|
||||||
@ -157,6 +157,7 @@ private:
|
|||||||
static QString resolveFontFamilyAlias(const QString &family);
|
static QString resolveFontFamilyAlias(const QString &family);
|
||||||
static QFontEngine *findFont(const QFontDef &request, int script /* QChar::Script */);
|
static QFontEngine *findFont(const QFontDef &request, int script /* QChar::Script */);
|
||||||
static void load(const QFontPrivate *d, int script /* QChar::Script */);
|
static void load(const QFontPrivate *d, int script /* QChar::Script */);
|
||||||
|
static QFontDatabasePrivate *ensureFontDatabase();
|
||||||
|
|
||||||
friend struct QFontDef;
|
friend struct QFontDef;
|
||||||
friend class QFontPrivate;
|
friend class QFontPrivate;
|
||||||
@ -164,8 +165,6 @@ private:
|
|||||||
friend class QFontDialogPrivate;
|
friend class QFontDialogPrivate;
|
||||||
friend class QFontEngineMulti;
|
friend class QFontEngineMulti;
|
||||||
friend class QRawFont;
|
friend class QRawFont;
|
||||||
|
|
||||||
QFontDatabasePrivate *d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -66,7 +66,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
|
|||||||
QString family(QCFString((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute)));
|
QString family(QCFString((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute)));
|
||||||
QString style(QCFString(((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute))));
|
QString style(QCFString(((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute))));
|
||||||
|
|
||||||
newFont = QFontDatabase().font(family, style, pSize);
|
newFont = QFontDatabase::font(family, style, pSize);
|
||||||
newFont.setUnderline(resolveFont.underline());
|
newFont.setUnderline(resolveFont.underline());
|
||||||
newFont.setStrikeOut(resolveFont.strikeOut());
|
newFont.setStrikeOut(resolveFont.strikeOut());
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ static QFontDatabase::WritingSystem writingSystemFromLocale()
|
|||||||
|
|
||||||
static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
|
static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
|
||||||
{
|
{
|
||||||
QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase().writingSystems(font.family());
|
QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase::writingSystems(font.family());
|
||||||
// qDebug() << font.family() << writingSystems;
|
// qDebug() << font.family() << writingSystems;
|
||||||
|
|
||||||
// this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
|
// this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
|
||||||
@ -231,7 +231,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QIcon *icon = &bitmap;
|
const QIcon *icon = &bitmap;
|
||||||
if (QFontDatabase().isSmoothlyScalable(text)) {
|
if (QFontDatabase::isSmoothlyScalable(text)) {
|
||||||
icon = &truetype;
|
icon = &truetype;
|
||||||
}
|
}
|
||||||
const QSize actualSize = icon->actualSize(r.size());
|
const QSize actualSize = icon->actualSize(r.size());
|
||||||
@ -267,7 +267,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
|
|||||||
if (system != QFontDatabase::Any) {
|
if (system != QFontDatabase::Any) {
|
||||||
int w = painter->fontMetrics().horizontalAdvance(text + QLatin1String(" "));
|
int w = painter->fontMetrics().horizontalAdvance(text + QLatin1String(" "));
|
||||||
painter->setFont(font2);
|
painter->setFont(font2);
|
||||||
QString sample = QFontDatabase().writingSystemSample(system);
|
QString sample = QFontDatabase::writingSystemSample(system);
|
||||||
if (option.direction == Qt::RightToLeft)
|
if (option.direction == Qt::RightToLeft)
|
||||||
r.setRight(r.right() - w);
|
r.setRight(r.right() - w);
|
||||||
else
|
else
|
||||||
|
@ -166,7 +166,7 @@ void tst_QFontDatabase::systemFixedFont() // QTBUG-54623
|
|||||||
{
|
{
|
||||||
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||||
QFontInfo fontInfo(font);
|
QFontInfo fontInfo(font);
|
||||||
bool fdbSaysFixed = QFontDatabase().isFixedPitch(fontInfo.family(), fontInfo.styleName());
|
bool fdbSaysFixed = QFontDatabase::isFixedPitch(fontInfo.family(), fontInfo.styleName());
|
||||||
qCDebug(lcTests) << "system fixed font is" << font << "really fixed?" << fdbSaysFixed << fontInfo.fixedPitch();
|
qCDebug(lcTests) << "system fixed font is" << font << "really fixed?" << fdbSaysFixed << fontInfo.fixedPitch();
|
||||||
QVERIFY(fdbSaysFixed);
|
QVERIFY(fdbSaysFixed);
|
||||||
QVERIFY(fontInfo.fixedPitch());
|
QVERIFY(fontInfo.fixedPitch());
|
||||||
@ -296,8 +296,8 @@ void tst_QFontDatabase::addTwoAppFontsFromFamily()
|
|||||||
QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
|
QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
|
||||||
QCOMPARE(regularFontName, italicFontName);
|
QCOMPARE(regularFontName, italicFontName);
|
||||||
|
|
||||||
QFont italicFont = QFontDatabase().font(italicFontName,
|
QFont italicFont = QFontDatabase::font(italicFontName,
|
||||||
QString::fromLatin1("Italic"), 14);
|
QString::fromLatin1("Italic"), 14);
|
||||||
QVERIFY(italicFont.italic());
|
QVERIFY(italicFont.italic());
|
||||||
|
|
||||||
QFontDatabase::removeApplicationFont(regularId);
|
QFontDatabase::removeApplicationFont(regularId);
|
||||||
@ -426,7 +426,7 @@ void tst_QFontDatabase::rasterFonts()
|
|||||||
if (fontInfo.family() != font.family())
|
if (fontInfo.family() != font.family())
|
||||||
QSKIP("Fixedsys font not available.");
|
QSKIP("Fixedsys font not available.");
|
||||||
|
|
||||||
QVERIFY(!QFontDatabase().isSmoothlyScalable(font.family()));
|
QVERIFY(!QFontDatabase::isSmoothlyScalable(font.family()));
|
||||||
QVERIFY(fontInfo.pointSize() != font.pointSize());
|
QVERIFY(fontInfo.pointSize() != font.pointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,8 +439,8 @@ void tst_QFontDatabase::smoothFonts()
|
|||||||
QSKIP("Arial font not available.");
|
QSKIP("Arial font not available.");
|
||||||
|
|
||||||
// Smooth and bitmap scaling are mutually exclusive
|
// Smooth and bitmap scaling are mutually exclusive
|
||||||
QVERIFY(QFontDatabase().isSmoothlyScalable(font.family()));
|
QVERIFY(QFontDatabase::isSmoothlyScalable(font.family()));
|
||||||
QVERIFY(!QFontDatabase().isBitmapScalable(font.family()));
|
QVERIFY(!QFontDatabase::isBitmapScalable(font.family()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QFontDatabase::registerOpenTypePreferredNamesSystem()
|
void tst_QFontDatabase::registerOpenTypePreferredNamesSystem()
|
||||||
|
@ -156,7 +156,7 @@ void tst_QRawFont::explicitRawFontNotLoadedInDatabase()
|
|||||||
QRawFont font(testFont, 10, hintingPreference);
|
QRawFont font(testFont, 10, hintingPreference);
|
||||||
QVERIFY(font.isValid());
|
QVERIFY(font.isValid());
|
||||||
|
|
||||||
QVERIFY(!QFontDatabase().families().contains(font.familyName()));
|
QVERIFY(!QFontDatabase::families().contains(font.familyName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QRawFont::explicitRawFontNotAvailableInSystem_data()
|
void tst_QRawFont::explicitRawFontNotAvailableInSystem_data()
|
||||||
|
@ -182,7 +182,7 @@ void tst_QTextScriptEngine::devanagari_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Devanagari).contains("Raghindi")) {
|
if (QFontDatabase::families(QFontDatabase::Devanagari).contains("Raghindi")) {
|
||||||
QFont f("Raghindi");
|
QFont f("Raghindi");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
// Ka
|
// Ka
|
||||||
@ -228,7 +228,7 @@ void tst_QTextScriptEngine::devanagari_data()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Devanagari).contains("Mangal")) {
|
if (QFontDatabase::families(QFontDatabase::Devanagari).contains("Mangal")) {
|
||||||
QFont f("Mangal");
|
QFont f("Mangal");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
// Ka
|
// Ka
|
||||||
@ -289,7 +289,7 @@ void tst_QTextScriptEngine::bengali_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Bengali).contains("Akaash")) {
|
if (QFontDatabase::families(QFontDatabase::Bengali).contains("Akaash")) {
|
||||||
QFont f("Akaash");
|
QFont f("Akaash");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
// Ka
|
// Ka
|
||||||
@ -392,7 +392,7 @@ void tst_QTextScriptEngine::bengali_data()
|
|||||||
QSKIP("couldn't find Akaash");
|
QSKIP("couldn't find Akaash");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Bengali).contains("Mukti Narrow")) {
|
if (QFontDatabase::families(QFontDatabase::Bengali).contains("Mukti Narrow")) {
|
||||||
QFont f("Mukti Narrow");
|
QFont f("Mukti Narrow");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
// Ka
|
// Ka
|
||||||
@ -490,7 +490,7 @@ void tst_QTextScriptEngine::bengali_data()
|
|||||||
QSKIP("couldn't find Mukti");
|
QSKIP("couldn't find Mukti");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Bengali).contains("Likhan")) {
|
if (QFontDatabase::families(QFontDatabase::Bengali).contains("Likhan")) {
|
||||||
QFont f("Likhan");
|
QFont f("Likhan");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x9a8, 0x9cd, 0x9af, 0x0 },
|
{ { 0x9a8, 0x9cd, 0x9af, 0x0 },
|
||||||
@ -527,7 +527,7 @@ void tst_QTextScriptEngine::gurmukhi_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Gurmukhi).contains("Lohit Punjabi")) {
|
if (QFontDatabase::families(QFontDatabase::Gurmukhi).contains("Lohit Punjabi")) {
|
||||||
QFont f("Lohit Punjabi");
|
QFont f("Lohit Punjabi");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xA15, 0xA4D, 0xa39, 0x0 },
|
{ { 0xA15, 0xA4D, 0xa39, 0x0 },
|
||||||
@ -555,7 +555,7 @@ void tst_QTextScriptEngine::oriya_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Oriya).contains("utkal")) {
|
if (QFontDatabase::families(QFontDatabase::Oriya).contains("utkal")) {
|
||||||
QFont f("utkal");
|
QFont f("utkal");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0x0 },
|
{ { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0x0 },
|
||||||
@ -596,7 +596,7 @@ void tst_QTextScriptEngine::tamil_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Tamil).contains("AkrutiTml1")) {
|
if (QFontDatabase::families(QFontDatabase::Tamil).contains("AkrutiTml1")) {
|
||||||
QFont f("AkrutiTml1");
|
QFont f("AkrutiTml1");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x0b95, 0x0bc2, 0x0 },
|
{ { 0x0b95, 0x0bc2, 0x0 },
|
||||||
@ -673,7 +673,7 @@ void tst_QTextScriptEngine::telugu_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Telugu).contains("Pothana2000")) {
|
if (QFontDatabase::families(QFontDatabase::Telugu).contains("Pothana2000")) {
|
||||||
QFont f("Pothana2000");
|
QFont f("Pothana2000");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xc15, 0xc4d, 0x0 },
|
{ { 0xc15, 0xc4d, 0x0 },
|
||||||
@ -722,7 +722,7 @@ void tst_QTextScriptEngine::kannada_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Kannada).contains("Sampige")) {
|
if (QFontDatabase::families(QFontDatabase::Kannada).contains("Sampige")) {
|
||||||
QFont f("Sampige");
|
QFont f("Sampige");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x0ca8, 0x0ccd, 0x0ca8, 0x0 },
|
{ { 0x0ca8, 0x0ccd, 0x0ca8, 0x0 },
|
||||||
@ -753,7 +753,7 @@ void tst_QTextScriptEngine::kannada_data()
|
|||||||
QSKIP("couldn't find Sampige");
|
QSKIP("couldn't find Sampige");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Kannada).contains("Tunga")) {
|
if (QFontDatabase::families(QFontDatabase::Kannada).contains("Tunga")) {
|
||||||
QFont f("Tunga");
|
QFont f("Tunga");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x0cb7, 0x0cc6, 0x0 },
|
{ { 0x0cb7, 0x0cc6, 0x0 },
|
||||||
@ -793,7 +793,7 @@ void tst_QTextScriptEngine::malayalam_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Malayalam).contains("AkrutiMal2")) {
|
if (QFontDatabase::families(QFontDatabase::Malayalam).contains("AkrutiMal2")) {
|
||||||
QFont f("AkrutiMal2");
|
QFont f("AkrutiMal2");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x0d15, 0x0d46, 0x0 },
|
{ { 0x0d15, 0x0d46, 0x0 },
|
||||||
@ -837,7 +837,7 @@ void tst_QTextScriptEngine::malayalam_data()
|
|||||||
QSKIP("couldn't find AkrutiMal2");
|
QSKIP("couldn't find AkrutiMal2");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Malayalam).contains("Rachana")) {
|
if (QFontDatabase::families(QFontDatabase::Malayalam).contains("Rachana")) {
|
||||||
QFont f("Rachana");
|
QFont f("Rachana");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0x0 },
|
{ { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0x0 },
|
||||||
@ -874,7 +874,7 @@ void tst_QTextScriptEngine::sinhala_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Sinhala).contains("Malithi Web")) {
|
if (QFontDatabase::families(QFontDatabase::Sinhala).contains("Malithi Web")) {
|
||||||
QFont f("Malithi Web");
|
QFont f("Malithi Web");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xd9a, 0xdd9, 0xdcf, 0x0 },
|
{ { 0xd9a, 0xdd9, 0xdcf, 0x0 },
|
||||||
@ -912,7 +912,7 @@ void tst_QTextScriptEngine::khmer_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Khmer).contains("Khmer OS")) {
|
if (QFontDatabase::families(QFontDatabase::Khmer).contains("Khmer OS")) {
|
||||||
QFont f("Khmer OS");
|
QFont f("Khmer OS");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0x179a, 0x17cd, 0x0 },
|
{ { 0x179a, 0x17cd, 0x0 },
|
||||||
@ -956,7 +956,7 @@ void tst_QTextScriptEngine::linearB_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Any).contains("Penuturesu")) {
|
if (QFontDatabase::families(QFontDatabase::Any).contains("Penuturesu")) {
|
||||||
QFont f("Penuturesu");
|
QFont f("Penuturesu");
|
||||||
const ShapeTable shape_table [] = {
|
const ShapeTable shape_table [] = {
|
||||||
{ { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 },
|
{ { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03, 0 },
|
||||||
@ -984,7 +984,7 @@ void tst_QTextScriptEngine::greek_data()
|
|||||||
QSKIP("Test fonts are not available");
|
QSKIP("Test fonts are not available");
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Any).contains("DejaVu Sans")) {
|
if (QFontDatabase::families(QFontDatabase::Any).contains("DejaVu Sans")) {
|
||||||
QFont f("DejaVu Sans");
|
QFont f("DejaVu Sans");
|
||||||
for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
|
for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
|
||||||
QString string;
|
QString string;
|
||||||
@ -997,7 +997,7 @@ void tst_QTextScriptEngine::greek_data()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if (QFontDatabase().families(QFontDatabase::Any).contains("SBL Greek")) {
|
if (QFontDatabase::families(QFontDatabase::Any).contains("SBL Greek")) {
|
||||||
QFont f("SBL Greek");
|
QFont f("SBL Greek");
|
||||||
for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
|
for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
|
||||||
QString string;
|
QString string;
|
||||||
|
@ -197,7 +197,7 @@ void tst_QFontDialog::task256466_wrongStyle()
|
|||||||
styleList->currentIndex().data().toString(), expectedSize);
|
styleList->currentIndex().data().toString(), expectedSize);
|
||||||
QCOMPARE(current.family(), expected.family());
|
QCOMPARE(current.family(), expected.family());
|
||||||
QCOMPARE(current.style(), expected.style());
|
QCOMPARE(current.style(), expected.style());
|
||||||
if (expectedSize == 0 && !QFontDatabase().isScalable(current.family(), current.styleName()))
|
if (expectedSize == 0 && !QFontDatabase::isScalable(current.family(), current.styleName()))
|
||||||
QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue);
|
QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue);
|
||||||
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
|
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public:
|
|||||||
{
|
{
|
||||||
static QStringList samples;
|
static QStringList samples;
|
||||||
if (samples.isEmpty()) {
|
if (samples.isEmpty()) {
|
||||||
foreach (const QFontDatabase::WritingSystem system, QFontDatabase().writingSystems())
|
foreach (const QFontDatabase::WritingSystem system, QFontDatabase::writingSystems())
|
||||||
if (system != QFontDatabase::Ogham && system != QFontDatabase::Runic)
|
if (system != QFontDatabase::Ogham && system != QFontDatabase::Runic)
|
||||||
samples.append(QFontDatabase::writingSystemSample(system));
|
samples.append(QFontDatabase::writingSystemSample(system));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user