Skip to content

Commit

Permalink
Insure that the defautl text format font matches what we're passing t…
Browse files Browse the repository at this point in the history
…hrough env. variables
  • Loading branch information
nirvn authored and github-actions[bot] committed Sep 28, 2024
1 parent ae92f70 commit cb97adf
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <qgsapplication.h>
#include <qgslogger.h>
#include <qgsprojutils.h>
#include <qgsstyle.h>

#ifdef WITH_SPIX
#include <Spix/AnyRpcServer.h>
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cb97adf

Please sign in to comment.