diff --git a/changelog/next.md b/changelog/next.md index 95de5dc..d6dc60e 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -43,7 +43,7 @@ set shell id. - Added `QS_DISABLE_CRASH_HANDLER` environment variable to disable crash handling. - Added `QS_CRASHREPORT_URL` environment variable to allow overriding the crash reporter link. - Added `AppId` pragma and `QS_APP_ID` environment variable to allow overriding the desktop application ID. -- Added `DropExpensiveFonts` pragma which avoids loading fonts which may cause lag and excessive memory usage if many variants are used. +- Added `DropExpensiveFonts` pragma and `QS_DROP_EXPENSIVE_FONTS` environment variable which avoids loading fonts which may cause lag and excessive memory usage if many variants are used. - Unrecognized pragmas are no longer a hard error for future backward compatibility. ## Bug Fixes diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index de85956..dcdefa7 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -169,6 +169,17 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio Common::INITIAL_ENVIRONMENT = QProcessEnvironment::systemEnvironment(); + if (!pragmas.useSystemStyle) { + qunsetenv("QT_STYLE_OVERRIDE"); + qputenv("QT_QUICK_CONTROLS_STYLE", "Fusion"); + } + + for (auto [var, val]: pragmas.envOverrides.asKeyValueRange()) { + qputenv(var.toUtf8(), val.toUtf8()); + } + + pragmas.dropExpensiveFonts |= qEnvironmentVariableIntValue("QS_DROP_EXPENSIVE_FONTS") == 1; + if (pragmas.dropExpensiveFonts) { if (auto* runDir = QsPaths::instance()->instanceRunDir()) { auto baseConfigPath = qEnvironmentVariable("FONTCONFIG_FILE"); @@ -209,15 +220,6 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio } } - if (!pragmas.useSystemStyle) { - qunsetenv("QT_STYLE_OVERRIDE"); - qputenv("QT_QUICK_CONTROLS_STYLE", "Fusion"); - } - - for (auto [var, val]: pragmas.envOverrides.asKeyValueRange()) { - qputenv(var.toUtf8(), val.toUtf8()); - } - // The qml engine currently refuses to cache non file (qsintercept) paths. // if (auto* cacheDir = QsPaths::instance()->cacheDir()) {