From ed91c07f992410fd5a50005006ecd1997eb1bfca Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 9 Apr 2020 16:04:09 +0400 Subject: [PATCH] Restore the old behavior with fallback fontconfig configuration With current code fallback works only through time and replaces the config even if it is changed by the user. This commit fixes that. --- .../platform/linux/specific_linux.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 49e07bff7..0bb396342 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -130,7 +130,7 @@ bool RunShellCommand(const QByteArray &command) { LOG(("Fontconfig version: %1.").arg(version.toString())); if (version < QVersionNumber::fromString("2.13")) { - if (qgetenv("TDESKTOP_FORCE_CUSTOM_FONTCONFIG").isEmpty()) { + if (!qEnvironmentVariableIsSet("TDESKTOP_FORCE_CUSTOM_FONTCONFIG")) { return false; } } @@ -138,13 +138,24 @@ bool RunShellCommand(const QByteArray &command) { } void FallbackFontConfig() { - if (BadFontConfigVersion()) { - const auto custom = cWorkingDir() + "tdata/fc-custom-1.conf"; - QFile(":/fc/fc-custom.conf").copy(custom); + const auto custom = cWorkingDir() + "tdata/fc-custom-1.conf"; + + auto doFallback = [&] { if (QFile(custom).exists()) { LOG(("Custom FONTCONFIG_FILE: ") + custom); qputenv("FONTCONFIG_FILE", QFile::encodeName(custom)); + return true; } + return false; + }; + + if (doFallback()) { + return; + } + + if (BadFontConfigVersion()) { + QFile(":/fc/fc-custom.conf").copy(custom); + doFallback(); } } @@ -696,7 +707,7 @@ void psAutoStart(bool start, bool silent) { if (InSandbox()) { #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION SandboxAutostart(start, silent); -#endif // !DESKTOP_APP_USE_PACKAGED +#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION } else { const auto autostart = [&] { if (InSnap()) {