Noto fonts added needed for Chinese symbols + fontconfig setup changed
to use a fontconfig cache
This commit is contained in:
parent
ee3ac13e36
commit
5b17788768
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,5 +6,6 @@ rcc
|
||||
lib
|
||||
bin
|
||||
plugins
|
||||
fontconfig
|
||||
qvg
|
||||
*.swp
|
||||
|
@ -4,44 +4,35 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkinnyFont.h"
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QTemporaryDir>
|
||||
#include <QFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QElapsedTimer>
|
||||
#include <QDebug>
|
||||
|
||||
static void foolFontconfig()
|
||||
{
|
||||
// as the examples are always using the same fonts, we can disable
|
||||
// everything, that has to do with system fonts
|
||||
|
||||
static QTemporaryDir dir;
|
||||
|
||||
QString fontConfig =
|
||||
"<?xml version=\"1.0\"?>\n"
|
||||
"<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n"
|
||||
"<fontconfig>\n"
|
||||
"\t<dir>%1</dir>\n"
|
||||
"\t<cachedir>%2/cache</cachedir>\n"
|
||||
"</fontconfig>\n";
|
||||
fontConfig = fontConfig.arg( dir.path(), dir.path() );
|
||||
|
||||
QFile f( dir.path() + "/fonts.conf" );
|
||||
f.open( QIODevice::WriteOnly );
|
||||
f.write( fontConfig.toUtf8() );
|
||||
f.close();
|
||||
|
||||
qputenv( "FONTCONFIG_FILE", f.fileName().toUtf8() );
|
||||
|
||||
QFontDatabase();
|
||||
}
|
||||
#define STRINGIFY(x) #x
|
||||
#define STRING(x) STRINGIFY(x)
|
||||
|
||||
void SkinnyFont::init( QGuiApplication* )
|
||||
{
|
||||
foolFontconfig();
|
||||
#ifdef FONTCONFIG_FILE
|
||||
const char env[] = "FONTCONFIG_FILE";
|
||||
if ( !qEnvironmentVariableIsSet( env ) )
|
||||
qputenv( env, STRING( FONTCONFIG_FILE ) );
|
||||
#endif
|
||||
|
||||
QFontDatabase::addApplicationFont( ":/fonts/Roboto-Regular.ttf" );
|
||||
QFontDatabase::addApplicationFont( ":/fonts/DejaVuSans.ttf" );
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
QFontDatabase();
|
||||
|
||||
const auto elapsed = timer.elapsed();
|
||||
|
||||
if ( elapsed > 20 )
|
||||
{
|
||||
qWarning() << "Loading fonts needed" << elapsed << "ms.";
|
||||
qWarning() << "Probably because of creating a font cache.";
|
||||
}
|
||||
|
||||
/*
|
||||
The default initialization in QskSkin sets up its font table
|
||||
|
9
support/fonts.conf.in
Normal file
9
support/fonts.conf.in
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
|
||||
<fontconfig>
|
||||
|
||||
<dir>FONTDIR</dir>
|
||||
<cachedir>FONTCACHEDIR/cache</cachedir>
|
||||
|
||||
</fontconfig>
|
@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>fonts/DejaVuSans.ttf</file>
|
||||
<file>fonts/Roboto-Regular.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
support/fonts/NotoSansCJKsc-Regular.otf
Normal file
BIN
support/fonts/NotoSansCJKsc-Regular.otf
Normal file
Binary file not shown.
@ -10,7 +10,9 @@ TARGET = qsktestsupport
|
||||
DESTDIR = $${QSK_OUT_ROOT}/lib
|
||||
|
||||
QT += quick
|
||||
|
||||
CONFIG += ensure_skins
|
||||
CONFIG += fontconfig
|
||||
|
||||
contains(QSK_CONFIG, QskDll) {
|
||||
|
||||
@ -43,9 +45,6 @@ SOURCES += \
|
||||
SkinnyShapeProvider.cpp \
|
||||
SkinnyShortcut.cpp
|
||||
|
||||
RESOURCES += \
|
||||
fonts.qrc
|
||||
|
||||
DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_PLUGIN_DIR )
|
||||
|
||||
ensure_skins {
|
||||
@ -62,3 +61,26 @@ ensure_skins {
|
||||
LIBS *= -L$${QSK_PLUGIN_DIR}/skins -lsquiekskin -lmaterialskin
|
||||
}
|
||||
|
||||
fontconfig {
|
||||
|
||||
QSK_FONTDIR=$${PWD}/fonts
|
||||
QSK_FONTCACHEDIR=$${OUT_PWD}/fontconfig
|
||||
QSK_FONTCONF_FILE=$${QSK_FONTCACHEDIR}/fonts.conf
|
||||
|
||||
QSK_FONTCONF_DATA = "$$cat( $${PWD}/fonts.conf.in, false )"
|
||||
QSK_FONTCONF_DATA = $$replace(QSK_FONTCONF_DATA, FONTCACHEDIR, $${QSK_FONTCACHEDIR} )
|
||||
QSK_FONTCONF_DATA = $$replace(QSK_FONTCONF_DATA, FONTDIR, $${QSK_FONTDIR} )
|
||||
write_file( $${QSK_FONTCONF_FILE}, QSK_FONTCONF_DATA )
|
||||
|
||||
DEFINES += FONTCONFIG_FILE=$$clean_path( $$QSK_FONTCONF_FILE )
|
||||
|
||||
linux {
|
||||
|
||||
fontcache.target = $${QSK_FONTCACHEDIR}/cache
|
||||
fontcache.depends = $${QSK_FONTCONF_FILE}
|
||||
fontcache.commands = FONTCONFIG_FILE=$${QSK_FONTCONF_FILE} fc-cache -v
|
||||
|
||||
QMAKE_EXTRA_TARGETS += fontcache
|
||||
PRE_TARGETDEPS += $${QSK_FONTCACHEDIR}/cache
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user