Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insure that the defautl text format font matches what we're passing through env. variables #5685

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading