From 3dfd65ceda12a6a3458fae6d1c59d866baf8890b Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Thu, 3 Oct 2019 22:13:48 +0300 Subject: [PATCH] Fixed font updating after restart --- Telegram/SourceFiles/_other/updater.cpp | 22 +++++++++++-- Telegram/SourceFiles/_other/updater_linux.cpp | 25 +++++++++++++++ Telegram/SourceFiles/_other/updater_osx.m | 32 ++++++++++++++++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/_other/updater.cpp b/Telegram/SourceFiles/_other/updater.cpp index 40f8ee248..c612941f1 100644 --- a/Telegram/SourceFiles/_other/updater.cpp +++ b/Telegram/SourceFiles/_other/updater.cpp @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL bool _debug = false; -wstring updaterName, updaterDir, updateTo, exeName, customWorkingDir, customKeyFile; +wstring updaterName, updaterDir, updateTo, exeName, customWorkingDir, customKeyFile, mainFont, semiboldFont, monospacedFont; bool equal(const wstring &a, const wstring &b) { return !_wcsicmp(a.c_str(), b.c_str()); @@ -339,7 +339,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, testmode = false, externalupdater = false; + bool needupdate = false, autostart = false, debug = false, writeprotected = false, startintray = false, testmode = false, externalupdater = false, semiboldisbold = false; args = CommandLineToArgvW(GetCommandLine(), &argsCount); if (args) { for (int i = 1; i < argsCount; ++i) { @@ -381,6 +381,14 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara break; } } + } else if (equal(args[i], L"-mainfont") && ++i < argsCount) { + mainFont = args[i]; + } else if (equal(args[i], L"-semiboldfont") && ++i < argsCount) { + semiboldFont = args[i]; + } else if (equal(args[i], L"-semiboldisbold")) { + semiboldisbold = true; + } else if (equal(args[i], L"-monospacefont") && ++i < argsCount) { + monospacedFont = args[i]; } } if (exeName.empty()) { @@ -434,6 +442,16 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdPara if (!customKeyFile.empty()) { targs += L" -key \"" + customKeyFile + L"\""; } + if (!mainFont.empty()) { + targs += L" -mainfont \"" + mainFont + L"\""; + } + if (!semiboldFont.empty()) { + targs += L" -semiboldfont \"" + semiboldFont + L"\""; + } + if (semiboldisbold) targs += L" -semiboldisbold"; + if (!monospacedFont.empty()) { + targs += L" -monospacefont \"" + monospacedFont + L"\""; + } writeLog(L"Result arguments: " + targs); bool executed = false; diff --git a/Telegram/SourceFiles/_other/updater_linux.cpp b/Telegram/SourceFiles/_other/updater_linux.cpp index d56478ba2..44135d51a 100644 --- a/Telegram/SourceFiles/_other/updater_linux.cpp +++ b/Telegram/SourceFiles/_other/updater_linux.cpp @@ -46,6 +46,9 @@ string updaterName; string workDir; string exeName; string exePath; +string mainFont; +string semiboldFont; +string monospacedFont; FILE *_logFile = 0; void openLog() { @@ -341,6 +344,7 @@ int main(int argc, char *argv[]) { bool testmode = false; bool externalupdater = false; bool customWorkingDir = false; + bool semiboldIsBold = false; char *key = 0; char *workdir = 0; @@ -369,6 +373,14 @@ int main(int argc, char *argv[]) { exeName = argv[i]; } else if (equal(argv[i], "-exepath") && ++i < argc) { exePath = argv[i]; + } else if (equal(argv[i], "-mainfont") && ++i < argc) { + mainFont = argv[i]; + } else if (equal(argv[i], "-semiboldfont") && ++i < argc) { + semiboldFont = argv[i]; + } else if (equal(argv[i], "-semiboldisbold")) { + semiboldIsBold = true; + } else if (equal(argv[i], "-monospacefont") && ++i < argc) { + mainFont = argv[i]; } } if (exeName.empty() || exeName.find('/') != string::npos) { @@ -465,6 +477,19 @@ int main(int argc, char *argv[]) { push("-workdir"); push(workdir); } + if (!mainFont.empty()) { + push("-mainfont"); + push(mainFont); + } + if (!semiboldFont.empty()) { + push("-semiboldfont"); + push(semiboldFont); + } + if (semiboldIsBold) push("-semiboldisbold"); + if (!monospacedFont.empty()) { + push("-monospacefont"); + push(monospacedFont); + } auto args = vector(); for (auto &arg : values) { diff --git a/Telegram/SourceFiles/_other/updater_osx.m b/Telegram/SourceFiles/_other/updater_osx.m index c93fba25a..7b1e9b6bc 100644 --- a/Telegram/SourceFiles/_other/updater_osx.m +++ b/Telegram/SourceFiles/_other/updater_osx.m @@ -11,6 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL NSString *appName = @"Telegram.app"; NSString *appDir = nil; NSString *workDir = nil; +NSString *mainFont = nil; +NSString *semiboldFont = nil; +NSString *monospacedFont = nil; #ifdef _DEBUG BOOL _debug = YES; @@ -90,7 +93,7 @@ int main(int argc, const char * argv[]) { openLog(); pid_t procId = 0; - BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO, testMode = NO, externalUpdater = NO; + BOOL update = YES, toSettings = NO, autoStart = NO, startInTray = NO, testMode = NO, externalUpdater = NO, semiboldIsBold = NO; BOOL customWorkingDir = NO; NSString *key = nil; for (int i = 0; i < argc; ++i) { @@ -122,6 +125,20 @@ int main(int argc, const char * argv[]) { customWorkingDir = YES; } else if ([@"-key" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { if (++i < argc) key = [NSString stringWithUTF8String:argv[i]]; + } else if ([@"-mainfont" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { + if (++i < argc) { + mainFont = [NSString stringWithUTF8String:argv[i]]; + } + } else if ([@"-semiboldfont" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { + if (++i < argc) { + semiboldFont = [NSString stringWithUTF8String:argv[i]]; + } + } else if ([@"-semiboldisbold" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { + semiboldIsBold = YES; + } else if ([@"-monospacefont" isEqualToString:[NSString stringWithUTF8String:argv[i]]]) { + if (++i < argc) { + monospacedFont = [NSString stringWithUTF8String:argv[i]]; + } } } if (!workDir) { @@ -265,6 +282,19 @@ int main(int argc, const char * argv[]) { [args addObject:@"-workdir"]; [args addObject:workDir]; } + if (mainFont) { + [args addObject:@"-mainfont"]; + [args addObject:mainFont]; + } + if (semiboldFont) { + [args addObject:@"-semiboldfont"]; + [args addObject:semiboldFont]; + } + if (semiboldIsBold) [args addObject:@"-semiboldisbold"]; + if (monospacedFont) { + [args addObject:@"-monospacefont"]; + [args addObject:monospacedFont]; + } writeLog([[NSArray arrayWithObjects:@"Running application '", appPath, @"' with args '", [args componentsJoinedByString:@"' '"], @"'..", nil] componentsJoinedByString:@""]); for (int i = 0; i < 5; ++i) {