core: add QS_DROP_EXPENSIVE_FONTS env var

This commit is contained in:
outfoxxed 2026-04-08 01:35:15 -07:00
parent f0d0216b3d
commit 7208f68bb7
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 12 additions and 10 deletions

View file

@ -43,7 +43,7 @@ set shell id.
- Added `QS_DISABLE_CRASH_HANDLER` environment variable to disable crash handling. - 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 `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 `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. - Unrecognized pragmas are no longer a hard error for future backward compatibility.
## Bug Fixes ## Bug Fixes

View file

@ -169,6 +169,17 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
Common::INITIAL_ENVIRONMENT = QProcessEnvironment::systemEnvironment(); 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 (pragmas.dropExpensiveFonts) {
if (auto* runDir = QsPaths::instance()->instanceRunDir()) { if (auto* runDir = QsPaths::instance()->instanceRunDir()) {
auto baseConfigPath = qEnvironmentVariable("FONTCONFIG_FILE"); 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. // The qml engine currently refuses to cache non file (qsintercept) paths.
// if (auto* cacheDir = QsPaths::instance()->cacheDir()) { // if (auto* cacheDir = QsPaths::instance()->cacheDir()) {