diff --git a/Telegram/SourceFiles/_other/updater_osx.m b/Telegram/SourceFiles/_other/updater_osx.m index 61de6a3f47..62aedabc32 100644 --- a/Telegram/SourceFiles/_other/updater_osx.m +++ b/Telegram/SourceFiles/_other/updater_osx.m @@ -92,7 +92,7 @@ int main(int argc, const char * argv[]) { openLog(); pid_t procId = 0; - BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO, freeType = NO; + BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO; BOOL customWorkingDir = NO; NSString *key = nil; for (int i = 0; i < argc; ++i) { @@ -116,8 +116,6 @@ int main(int argc, const char * argv[]) { _debug = YES; } else if ([@"-startintray" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { startInTray = YES; - } else if ([@"-freetype" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { - freeType = YES; } else if ([@"-workdir_custom" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { customWorkingDir = YES; } else if ([@"-key" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { @@ -254,7 +252,6 @@ int main(int argc, const char * argv[]) { if (toSettings) [args addObject:@"-tosettings"]; if (_debug) [args addObject:@"-debug"]; if (startInTray) [args addObject:@"-startintray"]; - if (freeType) [args addObject:@"-freetype"]; if (autoStart) [args addObject:@"-autostart"]; if (key) { [args addObject:@"-key"]; diff --git a/Telegram/SourceFiles/_other/updater_win.cpp b/Telegram/SourceFiles/_other/updater_win.cpp index 4a11657eaa..1873815ce8 100644 --- a/Telegram/SourceFiles/_other/updater_win.cpp +++ b/Telegram/SourceFiles/_other/updater_win.cpp @@ -343,7 +343,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara LPWSTR *args; int argsCount; - bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false, freetype = false; + bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false; args = CommandLineToArgvW(GetCommandLine(), &argsCount); if (args) { for (int i = 1; i < argsCount; ++i) { @@ -357,8 +357,6 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara openLog(); } else if (equal(args[i], L"-startintray")) { startintray = true; - } else if (equal(args[i], L"-freetype")) { - freetype = true; } else if (equal(args[i], L"-writeprotected") && ++i < argsCount) { writeLog(std::wstring(L"Argument: ") + args[i]); writeprotected = true; @@ -428,7 +426,6 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara if (autostart) targs += L" -autostart"; if (debug) targs += L" -debug"; if (startintray) targs += L" -startintray"; - if (freetype) targs += L" -freetype"; if (!customWorkingDir.empty()) { targs += L" -workdir \"" + customWorkingDir + L"\""; } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index f5c2951042..fb00ef4a09 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -910,21 +910,6 @@ void Application::switchDebugMode() { } } -void Application::switchFreeType() { - if (cUseFreeType()) { - QFile(cWorkingDir() + u"tdata/withfreetype"_q).remove(); - cSetUseFreeType(false); - } else { - QFile f(cWorkingDir() + u"tdata/withfreetype"_q); - if (f.open(QIODevice::WriteOnly)) { - f.write("1"); - f.close(); - } - cSetUseFreeType(true); - } - Restart(); -} - void Application::writeInstallBetaVersionsSetting() { _launcher->writeInstallBetaVersionsSetting(); } diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index cc6bcc143a..a698093754 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -305,7 +305,6 @@ public: [[nodiscard]] rpl::producer appDeactivatedValue() const; void switchDebugMode(); - void switchFreeType(); void writeInstallBetaVersionsSetting(); void preventOrInvoke(Fn &&callback); diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index 3a3688f357..c27eccbec2 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -26,6 +26,14 @@ namespace { uint64 InstallationTag = 0; +base::options::toggle OptionFreeType({ + .id = kOptionFreeType, + .name = "FreeType font engine", + .description = "Use the font engine from Linux instead of the system one.", + .scope = base::options::windows | base::options::macos, + .restartRequired = true, +}); + class FilteredCommandLineArguments { public: FilteredCommandLineArguments(int argc, char **argv); @@ -53,7 +61,7 @@ FilteredCommandLineArguments::FilteredCommandLineArguments( } #if defined Q_OS_WIN || defined Q_OS_MAC - if (cUseFreeType()) { + if (OptionFreeType.value()) { pushArgument("-platform"); #ifdef Q_OS_WIN pushArgument("windows:fontengine=freetype"); @@ -129,12 +137,6 @@ void ComputeExternalUpdater() { } } -void ComputeFreeType() { - if (QFile::exists(cWorkingDir() + u"tdata/withfreetype"_q)) { - cSetUseFreeType(true); - } -} - QString InstallBetaVersionsSettingPath() { return cWorkingDir() + u"tdata/devversion"_q; } @@ -284,6 +286,7 @@ base::options::toggle OptionFractionalScalingEnabled({ } // namespace const char kOptionFractionalScalingEnabled[] = "fractional-scaling-enabled"; +const char kOptionFreeType[] = "freetype"; std::unique_ptr Launcher::Create(int argc, char *argv[]) { return std::make_unique(argc, argv); @@ -398,7 +401,6 @@ void Launcher::workingFolderReady() { ComputeDebugMode(); ComputeExternalUpdater(); - ComputeFreeType(); ComputeInstallBetaVersions(); ComputeInstallationTag(); } @@ -497,7 +499,6 @@ void Launcher::processArguments() { }; auto parseMap = std::map { { "-debug" , KeyFormat::NoValues }, - { "-freetype" , KeyFormat::NoValues }, { "-key" , KeyFormat::OneValue }, { "-autostart" , KeyFormat::NoValues }, { "-fixprevious" , KeyFormat::NoValues }, @@ -534,7 +535,6 @@ void Launcher::processArguments() { } } - gUseFreeType = parseResult.contains("-freetype"); gDebugMode = parseResult.contains("-debug"); gKeyFile = parseResult.value("-key", {}).join(QString()).toLower(); gKeyFile = gKeyFile.replace(QRegularExpression("[^a-z0-9\\-_]"), {}); diff --git a/Telegram/SourceFiles/core/launcher.h b/Telegram/SourceFiles/core/launcher.h index 06e135630d..0472189513 100644 --- a/Telegram/SourceFiles/core/launcher.h +++ b/Telegram/SourceFiles/core/launcher.h @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Core { extern const char kOptionFractionalScalingEnabled[]; +extern const char kOptionFreeType[]; class Launcher { public: diff --git a/Telegram/SourceFiles/platform/mac/launcher_mac.mm b/Telegram/SourceFiles/platform/mac/launcher_mac.mm index f16420eee7..8fecc6bfc5 100644 --- a/Telegram/SourceFiles/platform/mac/launcher_mac.mm +++ b/Telegram/SourceFiles/platform/mac/launcher_mac.mm @@ -60,7 +60,6 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { if (cLaunchMode() == LaunchModeAutoStart) [args addObject:@"-autostart"]; if (Logs::DebugEnabled()) [args addObject:@"-debug"]; if (cStartInTray()) [args addObject:@"-startintray"]; - if (cUseFreeType()) [args addObject:@"-freetype"]; if (cDataFile() != u"data"_q) { [args addObject:@"-key"]; [args addObject:Q2NSString(cDataFile())]; diff --git a/Telegram/SourceFiles/platform/win/launcher_win.cpp b/Telegram/SourceFiles/platform/win/launcher_win.cpp index e105c8932b..5b19892bfe 100644 --- a/Telegram/SourceFiles/platform/win/launcher_win.cpp +++ b/Telegram/SourceFiles/platform/win/launcher_win.cpp @@ -67,9 +67,6 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { if (cStartInTray()) { pushArgument(u"-startintray"_q); } - if (cUseFreeType()) { - pushArgument(u"-freetype"_q); - } if (customWorkingDir()) { pushArgument(u"-workdir"_q); pushArgument('"' + cWorkingDir() + '"'); diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index 8dee2d7255..c4b11a7262 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -30,7 +30,6 @@ bool gStartInTray = false; bool gAutoStart = false; bool gSendToMenu = false; bool gUseExternalVideoPlayer = false; -bool gUseFreeType = false; bool gAutoUpdate = true; LaunchMode gLaunchMode = LaunchModeNormal; bool gSeenTrayTooltip = false; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index bca8a1248f..28ca676e4b 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -39,7 +39,6 @@ DeclareSetting(bool, StartMinimized); DeclareSetting(bool, StartInTray); DeclareSetting(bool, SendToMenu); DeclareSetting(bool, UseExternalVideoPlayer); -DeclareSetting(bool, UseFreeType); enum LaunchMode { LaunchModeNormal = 0, LaunchModeAutoStart, diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp index 62fba5c96b..d1333b2bcc 100644 --- a/Telegram/SourceFiles/settings/settings_codes.cpp +++ b/Telegram/SourceFiles/settings/settings_codes.cpp @@ -180,22 +180,6 @@ auto GenerateCodes() { Ui::Toast::Show("Forced custom scheme register."); }); -#if defined Q_OS_WIN || defined Q_OS_MAC - codes.emplace(u"freetype"_q, [](SessionController *window) { - auto text = cUseFreeType() -#ifdef Q_OS_WIN - ? u"Switch font engine to GDI?"_q -#else // Q_OS_WIN - ? u"Switch font engine to Cocoa?"_q -#endif // !Q_OS_WIN - : u"Switch font engine to FreeType?"_q; - - Ui::show(Ui::MakeConfirmBox({ text, [] { - Core::App().switchFreeType(); - } })); - }); -#endif // Q_OS_WIN || Q_OS_MAC - auto audioFilters = u"Audio files (*.wav *.mp3);;"_q + FileDialog::AllFilesFilter(); auto audioKeys = { u"msg_incoming"_q, diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 8359cf2331..e0266e7a3a 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -147,6 +147,7 @@ void SetupExperimental( addToggle(Webview::kOptionWebviewDebugEnabled); addToggle(kOptionAutoScrollInactiveChat); addToggle(Window::Notifications::kOptionGNotification); + addToggle(Core::kOptionFreeType); } } // namespace