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 committed Sep 29, 2024
1 parent ae92f70 commit 889591c
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

1 comment on commit 889591c

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.