From 580e6baee6148ff1758ee697463ae830e9b76e11 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 7 Aug 2020 10:07:43 +0400 Subject: [PATCH] Get rid of redudant fontconfig hack --- Telegram/SourceFiles/core/ui_integration.cpp | 2 - .../platform/linux/specific_linux.cpp | 86 ------------------- .../platform/linux/specific_linux.h | 3 - .../SourceFiles/platform/mac/specific_mac.h | 6 -- .../SourceFiles/platform/win/specific_win.h | 6 -- Telegram/cmake/telegram_options.cmake | 5 -- 6 files changed, 108 deletions(-) diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp index 5f05926e8..501491cdd 100644 --- a/Telegram/SourceFiles/core/ui_integration.cpp +++ b/Telegram/SourceFiles/core/ui_integration.cpp @@ -53,11 +53,9 @@ void UiIntegration::activationFromTopPanel() { } void UiIntegration::startFontsBegin() { - Platform::FallbackFontConfigCheckBegin(); } void UiIntegration::startFontsEnd() { - Platform::FallbackFontConfigCheckEnd(); } std::shared_ptr UiIntegration::createLinkHandler( diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index a9464b5d2..8cd8fc959 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -209,71 +209,6 @@ bool RunShellCommand(const QString &program, const QStringList &arguments) { return true; } -[[nodiscard]] bool CheckFontConfigCrash() { - return InSnap(); -} - -[[nodiscard]] QString FallbackFontConfigCheckPath() { - return cWorkingDir() + "tdata/fc-check"; -} - -#ifdef TDESKTOP_USE_FONTCONFIG_FALLBACK - -[[nodiscard]] bool BadFontConfigVersion() { - if (CheckFontConfigCrash()) { - return QFile(FallbackFontConfigCheckPath()).exists(); - } - QProcess process; - process.setProcessChannelMode(QProcess::MergedChannels); - process.start("fc-list", QStringList() << "--version"); - process.waitForFinished(); - if (process.exitCode() > 0) { - LOG(("App Error: Could not start fc-list. Process exited with code: %1.").arg(process.exitCode())); - return false; - } - - QString result(process.readAllStandardOutput()); - DEBUG_LOG(("Fontconfig version string: ") + result); - - QVersionNumber version = QVersionNumber::fromString(result.split("version ").last()); - if (version.isNull()) { - LOG(("App Error: Could not get version from fc-list output.")); - return false; - } - - LOG(("Fontconfig version: %1.").arg(version.toString())); - if (version < QVersionNumber::fromString("2.13")) { - if (!qEnvironmentVariableIsSet("TDESKTOP_FORCE_CUSTOM_FONTCONFIG")) { - return false; - } - } - return true; -} - -void FallbackFontConfig() { - 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(); - } -} - -#endif // TDESKTOP_USE_FONTCONFIG_FALLBACK - bool GenerateDesktopFile( const QString &targetPath, const QString &args, @@ -965,23 +900,6 @@ void SetTrayIconSupported(bool supported) { IsTrayIconSupported = supported; } -void FallbackFontConfigCheckBegin() { - if (!CheckFontConfigCrash()) { - return; - } - auto file = QFile(FallbackFontConfigCheckPath()); - if (file.open(QIODevice::WriteOnly)) { - file.write("1", 1); - } -} - -void FallbackFontConfigCheckEnd() { - if (!CheckFontConfigCrash()) { - return; - } - QFile(FallbackFontConfigCheckPath()).remove(); -} - bool StartSystemMove(QWindow *window) { if (IsWayland()) { return StartWaylandMove(window); @@ -1178,10 +1096,6 @@ void start() { LOG(("Launcher filename: %1").arg(GetLauncherFilename())); -#ifdef TDESKTOP_USE_FONTCONFIG_FALLBACK - FallbackFontConfig(); -#endif // TDESKTOP_USE_FONTCONFIG_FALLBACK - qputenv("PULSE_PROP_application.name", AppName.utf8()); qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1()); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 84bc068ed..b2e7797cf 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -42,9 +42,6 @@ QString GetIconName(); inline void IgnoreApplicationActivationRightNow() { } -void FallbackFontConfigCheckBegin(); -void FallbackFontConfigCheckEnd(); - bool GtkClipboardSupported(); void SetTrayIconSupported(bool supported); void InstallMainDesktopFile(); diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.h b/Telegram/SourceFiles/platform/mac/specific_mac.h index f74ad82e6..7db80f1a4 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.h +++ b/Telegram/SourceFiles/platform/mac/specific_mac.h @@ -20,12 +20,6 @@ void RemoveQuarantine(const QString &path); [[nodiscard]] bool IsDarkMenuBar(); -inline void FallbackFontConfigCheckBegin() { -} - -inline void FallbackFontConfigCheckEnd() { -} - inline QImage GetImageFromClipboard() { return {}; } diff --git a/Telegram/SourceFiles/platform/win/specific_win.h b/Telegram/SourceFiles/platform/win/specific_win.h index 430776e69..71a7ff30a 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.h +++ b/Telegram/SourceFiles/platform/win/specific_win.h @@ -22,12 +22,6 @@ inline void SetWatchingMediaKeys(bool watching) { inline void IgnoreApplicationActivationRightNow() { } -inline void FallbackFontConfigCheckBegin() { -} - -inline void FallbackFontConfigCheckEnd() { -} - inline QImage GetImageFromClipboard() { return {}; } diff --git a/Telegram/cmake/telegram_options.cmake b/Telegram/cmake/telegram_options.cmake index e10138ae9..4505b2ce1 100644 --- a/Telegram/cmake/telegram_options.cmake +++ b/Telegram/cmake/telegram_options.cmake @@ -4,7 +4,6 @@ # For license and copyright information please follow this link: # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -option(TDESKTOP_USE_FONTCONFIG_FALLBACK "Use custom fonts.conf (Linux only)." OFF) option(TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME "Disable automatic 'tg://' URL scheme handler registration." OFF) option(TDESKTOP_DISABLE_NETWORK_PROXY "Disable all code for working through Socks5 or MTProxy." OFF) option(TDESKTOP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF) @@ -56,10 +55,6 @@ if (DESKTOP_APP_SPECIAL_TARGET) target_compile_definitions(Telegram PRIVATE TDESKTOP_ALLOW_CLOSED_ALPHA) endif() -if (TDESKTOP_USE_FONTCONFIG_FALLBACK) - target_compile_definitions(Telegram PRIVATE TDESKTOP_USE_FONTCONFIG_FALLBACK) -endif() - if (TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) endif()