2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Fixed font updating after restart

This commit is contained in:
RadRussianRus
2019-10-03 22:13:48 +03:00
parent 5f6d189f90
commit 3dfd65ceda
3 changed files with 76 additions and 3 deletions

View File

@@ -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;

View File

@@ -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<char*>();
for (auto &arg : values) {

View File

@@ -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) {