minimal QPA: Make font DB creation more flexible
Prioritize CoreText over Fontconfig since the former is the native one on macOS, and any other native font DB on its respective platform. We introduce a new 'fontconfig' option to allow using Fontconfig instead. This works similarly to 'freetype' overriding the default font engine on Windows. A propos of which, 'freetype' now does the same on macOS. Change-Id: Ic8168820d1d01fddc2f26e046abb65b8ab765f89 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
parent
e6aae7df04
commit
8d5842a2d8
@ -14,6 +14,8 @@ HEADERS = qminimalintegration.h \
|
||||
|
||||
OTHER_FILES += minimal.json
|
||||
|
||||
qtConfig(freetype): QMAKE_USE_PRIVATE += freetype
|
||||
|
||||
PLUGIN_TYPE = platforms
|
||||
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
|
||||
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
|
||||
|
@ -54,11 +54,17 @@
|
||||
# endif
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
# include <QtFontDatabaseSupport/private/qcoretextfontdatabase_p.h>
|
||||
#elif QT_CONFIG(fontconfig)
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(fontconfig)
|
||||
# include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
|
||||
# include <qpa/qplatformfontdatabase.h>
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(freetype)
|
||||
#include <QtFontDatabaseSupport/private/qfontengine_ft_p.h>
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h>
|
||||
#elif defined(Q_OS_WINRT)
|
||||
@ -81,6 +87,8 @@ static inline unsigned parseOptions(const QStringList ¶mList)
|
||||
options |= QMinimalIntegration::EnableFonts;
|
||||
else if (param == QLatin1String("freetype"))
|
||||
options |= QMinimalIntegration::FreeTypeFontDatabase;
|
||||
else if (param == QLatin1String("fontconfig"))
|
||||
options |= QMinimalIntegration::FontconfigDatabase;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
@ -129,9 +137,7 @@ public:
|
||||
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
|
||||
{
|
||||
if (!m_fontDatabase && (m_options & EnableFonts)) {
|
||||
#if QT_CONFIG(fontconfig)
|
||||
m_fontDatabase = new QGenericUnixFontDatabase;
|
||||
#elif defined(Q_OS_WINRT)
|
||||
#if defined(Q_OS_WINRT)
|
||||
m_fontDatabase = new QWinRTFontDatabase;
|
||||
#elif defined(Q_OS_WIN)
|
||||
if (m_options & FreeTypeFontDatabase) {
|
||||
@ -142,10 +148,24 @@ QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
|
||||
m_fontDatabase = new QWindowsFontDatabase;
|
||||
}
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
m_fontDatabase = new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
|
||||
#else
|
||||
m_fontDatabase = QPlatformIntegration::fontDatabase();
|
||||
if (!(m_options & FontconfigDatabase)) {
|
||||
if (m_options & FreeTypeFontDatabase) {
|
||||
# if QT_CONFIG(freetype)
|
||||
m_fontDatabase = new QCoreTextFontDatabaseEngineFactory<QFontEngineFT>;
|
||||
# endif // freetype
|
||||
} else {
|
||||
m_fontDatabase = new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!m_fontDatabase) {
|
||||
#if QT_CONFIG(fontconfig)
|
||||
m_fontDatabase = new QGenericUnixFontDatabase;
|
||||
#else
|
||||
m_fontDatabase = QPlatformIntegration::fontDatabase();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (!m_fontDatabase)
|
||||
m_fontDatabase = new DummyFontDatabase;
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
enum Options { // Options to be passed on command line or determined from environment
|
||||
DebugBackingStore = 0x1,
|
||||
EnableFonts = 0x2,
|
||||
FreeTypeFontDatabase = 0x4
|
||||
FreeTypeFontDatabase = 0x4,
|
||||
FontconfigDatabase = 0x8
|
||||
};
|
||||
|
||||
explicit QMinimalIntegration(const QStringList ¶meters);
|
||||
|
Loading…
Reference in New Issue
Block a user