diff --git a/src/app/main.cpp b/src/app/main.cpp index d7a21bea32..047a119891 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef WITH_SPIX #include @@ -144,10 +145,10 @@ int main( int argc, char **argv ) QgsApplication::setLocale( QLocale() ); } - const QString qfieldFont( qgetenv( "QFIELD_FONT_TTF" ) ); - if ( !qfieldFont.isEmpty() ) + const QString qfieldFontName( qgetenv( "QFIELD_FONT_NAME" ) ); + if ( !qfieldFontName.isEmpty() ) { - const QString qfieldFontName( qgetenv( "QFIELD_FONT_NAME" ) ); + const QString qfieldFont( qgetenv( "QFIELD_FONT_TTF" ) ); const int qfieldFontSize = QString( qgetenv( "QFIELD_FONT_SIZE" ) ).toInt(); QFontDatabase::addApplicationFont( qfieldFont ); app.setFont( QFont( qfieldFontName, qfieldFontSize ) ); @@ -196,6 +197,16 @@ int main( int argc, char **argv ) #endif app.createDatabase(); + if ( !qfieldFontName.isEmpty() ) + { + QgsStyle *defaultStyle = QgsStyle::defaultStyle(); + QgsTextFormat textFormat = defaultStyle->defaultTextFormat(); + QFont font = textFormat.font(); + font.setFamily( qfieldFontName ); + textFormat.setFont( font ); + defaultStyle->addTextFormat( QStringLiteral( "Default" ), textFormat, true ); + } + QSettings::setDefaultFormat( QSettings::NativeFormat ); // Set up the QSettings environment must be done after qapp is created