From 534d22fd647f79b9fde08329a6b9e355c6611132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 30 Sep 2010 13:29:28 +0200 Subject: Lighthouse: Make application fonts work Reviewed-by:paul --- src/gui/text/qfontdatabase_qpa.cpp | 3 ++- src/gui/text/qplatformfontdatabase_qpa.cpp | 7 ++++++- src/gui/text/qplatformfontdatabase_qpa.h | 2 +- .../fontdatabases/basicunix/qbasicunixfontdatabase.cpp | 10 +++++++--- .../platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h | 4 ++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 53594aa..19ce1be 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -199,7 +199,8 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) { QFontDatabasePrivate *db = privateDb(); - QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); + fnt->families = QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); + db->reregisterAppFonts = true; } diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp index 7bb1f9a..26f4faa 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.cpp +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -165,12 +165,17 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, cons return QStringList(); } -void QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +/*! + Adds an application font. Returns a list of family names, or an empty list if the font could + not be added +*/ +QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { Q_UNUSED(fontData); Q_UNUSED(fileName); qWarning("This plugin does not support application fonts"); + return QStringList(); } void QPlatformFontDatabase::releaseHandle(void *handle) diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index a34033f..adaa4cb 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -46,7 +46,7 @@ public: virtual void populateFontDatabase(); virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; - virtual void addApplicationFont(const QByteArray &fontData, const QString &fileName); + virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); virtual void releaseHandle(void *handle); virtual QString fontDir() const; diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp index 5b8ca63..5b6f69a 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp @@ -204,9 +204,9 @@ QStringList QBasicUnixFontDatabase::fallbacksForFamily(const QString family, con return QStringList(); } -void QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +QStringList QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { - addTTFile(fontData,fileName.toLocal8Bit()); + return addTTFile(fontData,fileName.toLocal8Bit()); } void QBasicUnixFontDatabase::releaseHandle(void *handle) @@ -215,13 +215,14 @@ void QBasicUnixFontDatabase::releaseHandle(void *handle) delete file; } -void QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) +QStringList QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) { extern FT_Library qt_getFreetype(); FT_Library library = qt_getFreetype(); int index = 0; int numFaces = 0; + QStringList families; do { FT_Face face; FT_Error error; @@ -275,7 +276,10 @@ void QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteAr registerFont(family,"",weight,style,100,true,true,0,writingSystems,fontFile); + families.append(family); + FT_Done_Face(face); ++index; } while (index < numFaces); + return families; } diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h index 401a4aa..95015df 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h @@ -17,10 +17,10 @@ public: void populateFontDatabase(); QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; - void addApplicationFont(const QByteArray &fontData, const QString &fileName); + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); void releaseHandle(void *handle); - static void addTTFile(const QByteArray &fontData, const QByteArray &file); + static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file); }; #endif // QBASICUNIXFONTDATABASE_H -- cgit v0.12