Skip to content

Commit

Permalink
Fix versions-old regression on project file fonts loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed May 15, 2022
1 parent 6f2b0b5 commit 4967924
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,23 @@ void QgisMobileapp::readProjectFile()

mTrackingModel->reset();

// load project file fonts if present
QDir fontDir = QDir::cleanPath( QFileInfo( mProjectFilePath ).absoluteDir().path() + QDir::separator() + ".fonts" );
QStringList fontExts = QStringList() << "*.ttf"
<< "*.TTF"
<< "*.otf"
<< "*.OTF";
const QStringList fontFiles = fontDir.entryList( fontExts, QDir::Files );
for ( const QString &fontFile : fontFiles )
{
int id = QFontDatabase::addApplicationFont( QDir::cleanPath( fontDir.path() + QDir::separator() + fontFile ) );
qDebug() << QDir::cleanPath( fontDir.path() + QDir::separator() + fontFile );
if ( id == -1 )
{
QgsMessageLog::logMessage( tr( "Could not load font %1" ).arg( fontFile ) );
}
}

// Load project file
bool projectLoaded = false;
if ( SUPPORTED_PROJECT_EXTENSIONS.contains( suffix ) )
Expand All @@ -706,25 +723,6 @@ void QgisMobileapp::readProjectFile()
}
}

if ( projectLoaded )
{
// load fonts in same directory
QDir fontDir = QDir::cleanPath( QFileInfo( mProjectFilePath ).absoluteDir().path() + QDir::separator() + ".fonts" );
QStringList fontExts = QStringList() << "*.ttf"
<< "*.TTF"
<< "*.otf"
<< "*.OTF";
const QStringList fontFiles = fontDir.entryList( fontExts, QDir::Files );
for ( const QString &fontFile : fontFiles )
{
int id = QFontDatabase::addApplicationFont( QDir::cleanPath( fontDir.path() + QDir::separator() + fontFile ) );
if ( id < 0 )
QgsMessageLog::logMessage( tr( "Could not load font %1" ).arg( fontFile ) );
else
QgsMessageLog::logMessage( tr( "Loading font %1" ).arg( fontFile ) );
}
}

QList<QPair<QString, QString>> projects = recentProjects();
QString title;
if ( mProject->fileName().startsWith( QFieldCloudUtils::localCloudDirectory() ) )
Expand Down

0 comments on commit 4967924

Please sign in to comment.