qskinny/support/SkinnyFont.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "SkinnyFont.h"
2017-07-21 18:21:34 +02:00
#include <QFontDatabase>
#include <QGuiApplication>
#include <QElapsedTimer>
#include <QDebug>
2017-07-21 18:21:34 +02:00
#define STRINGIFY(x) #x
#define STRING(x) STRINGIFY(x)
2017-07-21 18:21:34 +02:00
void SkinnyFont::init( QGuiApplication* )
{
#ifdef FONTCONFIG_FILE
const char env[] = "FONTCONFIG_FILE";
if ( !qEnvironmentVariableIsSet( env ) )
qputenv( env, STRING( FONTCONFIG_FILE ) );
#endif
2017-07-21 18:21:34 +02:00
QElapsedTimer timer;
timer.start();
2017-07-21 18:21:34 +02:00
QFontDatabase();
const auto elapsed = timer.elapsed();
2017-07-21 18:21:34 +02:00
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
with using the application font for the default font role.
*/
QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) );
2017-07-21 18:21:34 +02:00
}