From 2d716fcf571046c5049c2a640f692e7560e39098 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sat, 28 Sep 2024 17:37:45 +0700 Subject: [PATCH] Insure that the defautl text format font matches what we're passing through env. variables --- src/app/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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