Switch freetype to experimental settings

This commit is contained in:
Ilya Fedin 2023-02-22 11:44:59 +04:00 committed by John Preston
parent c327fa0d45
commit 808cf119b8
12 changed files with 14 additions and 56 deletions

View File

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

View File

@ -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"\"";
}

View File

@ -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();
}

View File

@ -305,7 +305,6 @@ public:
[[nodiscard]] rpl::producer<bool> appDeactivatedValue() const;
void switchDebugMode();
void switchFreeType();
void writeInstallBetaVersionsSetting();
void preventOrInvoke(Fn<void()> &&callback);

View File

@ -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> Launcher::Create(int argc, char *argv[]) {
return std::make_unique<Platform::Launcher>(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<QByteArray, KeyFormat> {
{ "-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\\-_]"), {});

View File

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

View File

@ -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())];

View File

@ -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() + '"');

View File

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

View File

@ -39,7 +39,6 @@ DeclareSetting(bool, StartMinimized);
DeclareSetting(bool, StartInTray);
DeclareSetting(bool, SendToMenu);
DeclareSetting(bool, UseExternalVideoPlayer);
DeclareSetting(bool, UseFreeType);
enum LaunchMode {
LaunchModeNormal = 0,
LaunchModeAutoStart,

View File

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

View File

@ -147,6 +147,7 @@ void SetupExperimental(
addToggle(Webview::kOptionWebviewDebugEnabled);
addToggle(kOptionAutoScrollInactiveChat);
addToggle(Window::Notifications::kOptionGNotification);
addToggle(Core::kOptionFreeType);
}
} // namespace