Add a cheat code to enable freetype on Windows and macOS
This commit is contained in:
		
							parent
							
								
									c9553c2d4c
								
							
						
					
					
						commit
						7409d615a3
					
				
					 6 changed files with 69 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -518,6 +518,21 @@ void Application::switchTestMode() {
 | 
			
		|||
	App::restart();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Application::switchFreeType() {
 | 
			
		||||
	if (cUseFreeType()) {
 | 
			
		||||
		QFile(cWorkingDir() + qsl("tdata/withfreetype")).remove();
 | 
			
		||||
		cSetUseFreeType(false);
 | 
			
		||||
	} else {
 | 
			
		||||
		QFile f(cWorkingDir() + qsl("tdata/withfreetype"));
 | 
			
		||||
		if (f.open(QIODevice::WriteOnly)) {
 | 
			
		||||
			f.write("1");
 | 
			
		||||
			f.close();
 | 
			
		||||
		}
 | 
			
		||||
		cSetUseFreeType(true);
 | 
			
		||||
	}
 | 
			
		||||
	App::restart();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Application::writeInstallBetaVersionsSetting() {
 | 
			
		||||
	_launcher->writeInstallBetaVersionsSetting();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -215,6 +215,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	void switchDebugMode();
 | 
			
		||||
	void switchTestMode();
 | 
			
		||||
	void switchFreeType();
 | 
			
		||||
	void writeInstallBetaVersionsSetting();
 | 
			
		||||
 | 
			
		||||
	void call_handleUnreadCounterUpdate();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,26 +34,47 @@ private:
 | 
			
		|||
	static constexpr auto kForwardArgumentCount = 1;
 | 
			
		||||
 | 
			
		||||
	int _count = 0;
 | 
			
		||||
	char *_arguments[kForwardArgumentCount + 1] = { nullptr };
 | 
			
		||||
	std::vector<QByteArray> _owned;
 | 
			
		||||
	std::vector<char*> _arguments;
 | 
			
		||||
 | 
			
		||||
	void pushArgument(const char *text);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
FilteredCommandLineArguments::FilteredCommandLineArguments(
 | 
			
		||||
	int argc,
 | 
			
		||||
	char **argv)
 | 
			
		||||
: _count(std::clamp(argc, 0, kForwardArgumentCount)) {
 | 
			
		||||
	char **argv) {
 | 
			
		||||
	// For now just pass only the first argument, the executable path.
 | 
			
		||||
	for (auto i = 0; i != _count; ++i) {
 | 
			
		||||
		_arguments[i] = argv[i];
 | 
			
		||||
	for (auto i = 0; i != kForwardArgumentCount; ++i) {
 | 
			
		||||
		pushArgument(argv[i]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#if defined Q_OS_WIN || defined Q_OS_MAC
 | 
			
		||||
	if (cUseFreeType()) {
 | 
			
		||||
		pushArgument("-platform");
 | 
			
		||||
#ifdef Q_OS_WIN
 | 
			
		||||
		pushArgument("windows:fontengine=freetype");
 | 
			
		||||
#else // Q_OS_WIN
 | 
			
		||||
		pushArgument("cocoa:fontengine=freetype");
 | 
			
		||||
#endif // !Q_OS_WIN
 | 
			
		||||
	}
 | 
			
		||||
#endif // Q_OS_WIN || Q_OS_MAC
 | 
			
		||||
 | 
			
		||||
	pushArgument(nullptr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int &FilteredCommandLineArguments::count() {
 | 
			
		||||
	_count = _arguments.size() - 1;
 | 
			
		||||
	return _count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char **FilteredCommandLineArguments::values() {
 | 
			
		||||
	return _arguments;
 | 
			
		||||
	return _arguments.data();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FilteredCommandLineArguments::pushArgument(const char *text) {
 | 
			
		||||
	_owned.emplace_back(text);
 | 
			
		||||
	_arguments.push_back(_owned.back().data());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DebugModeSettingPath() {
 | 
			
		||||
| 
						 | 
				
			
			@ -82,6 +103,12 @@ void ComputeTestMode() {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ComputeFreeType() {
 | 
			
		||||
	if (QFile(cWorkingDir() + qsl("tdata/withfreetype")).exists()) {
 | 
			
		||||
		cSetUseFreeType(true);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString InstallBetaVersionsSettingPath() {
 | 
			
		||||
	return cWorkingDir() + qsl("tdata/devversion");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -301,6 +328,7 @@ void Launcher::workingFolderReady() {
 | 
			
		|||
 | 
			
		||||
	ComputeTestMode();
 | 
			
		||||
	ComputeDebugMode();
 | 
			
		||||
	ComputeFreeType();
 | 
			
		||||
	ComputeInstallBetaVersions();
 | 
			
		||||
	ComputeInstallationTag();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -382,6 +410,7 @@ void Launcher::processArguments() {
 | 
			
		|||
	auto parseMap = std::map<QByteArray, KeyFormat> {
 | 
			
		||||
		{ "-testmode"       , KeyFormat::NoValues },
 | 
			
		||||
		{ "-debug"          , KeyFormat::NoValues },
 | 
			
		||||
		{ "-freetype"       , KeyFormat::NoValues },
 | 
			
		||||
		{ "-many"           , KeyFormat::NoValues },
 | 
			
		||||
		{ "-key"            , KeyFormat::OneValue },
 | 
			
		||||
		{ "-autostart"      , KeyFormat::NoValues },
 | 
			
		||||
| 
						 | 
				
			
			@ -423,6 +452,7 @@ void Launcher::processArguments() {
 | 
			
		|||
		SetUpdaterDisabledAtStartup();
 | 
			
		||||
	}
 | 
			
		||||
	gTestMode = parseResult.contains("-testmode");
 | 
			
		||||
	gUseFreeType = parseResult.contains("-freetype");
 | 
			
		||||
	Logs::SetDebugEnabled(parseResult.contains("-debug"));
 | 
			
		||||
	gManyInstance = parseResult.contains("-many");
 | 
			
		||||
	gKeyFile = parseResult.value("-key", {}).join(QString()).toLower();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ bool gStartInTray = false;
 | 
			
		|||
bool gAutoStart = false;
 | 
			
		||||
bool gSendToMenu = false;
 | 
			
		||||
bool gUseExternalVideoPlayer = false;
 | 
			
		||||
bool gUseFreeType = false;
 | 
			
		||||
bool gAutoUpdate = true;
 | 
			
		||||
TWindowPos gWindowPos;
 | 
			
		||||
LaunchMode gLaunchMode = LaunchModeNormal;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@ DeclareSetting(bool, StartMinimized);
 | 
			
		|||
DeclareSetting(bool, StartInTray);
 | 
			
		||||
DeclareSetting(bool, SendToMenu);
 | 
			
		||||
DeclareSetting(bool, UseExternalVideoPlayer);
 | 
			
		||||
DeclareSetting(bool, UseFreeType);
 | 
			
		||||
enum LaunchMode {
 | 
			
		||||
	LaunchModeNormal = 0,
 | 
			
		||||
	LaunchModeAutoStart,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,6 +126,21 @@ auto GenerateCodes() {
 | 
			
		|||
	codes.emplace(qsl("export"), [](SessionController *window) {
 | 
			
		||||
		window->session().data().startExport();
 | 
			
		||||
	});
 | 
			
		||||
#if defined Q_OS_WIN || defined Q_OS_MAC
 | 
			
		||||
	codes.emplace(qsl("freetype"), [](SessionController *window) {
 | 
			
		||||
		auto text = cUseFreeType()
 | 
			
		||||
#ifdef Q_OS_WIN
 | 
			
		||||
			? qsl("Switch font engine to GDI?")
 | 
			
		||||
#else // Q_OS_WIN
 | 
			
		||||
			? qsl("Switch font engine to Cocoa?")
 | 
			
		||||
#endif // !Q_OS_WIN
 | 
			
		||||
			: qsl("Switch font engine to FreeType?");
 | 
			
		||||
 | 
			
		||||
		Ui::show(Box<ConfirmBox>(text, [] {
 | 
			
		||||
			Core::App().switchFreeType();
 | 
			
		||||
		}));
 | 
			
		||||
	});
 | 
			
		||||
#endif // Q_OS_WIN || Q_OS_MAC
 | 
			
		||||
 | 
			
		||||
	auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
 | 
			
		||||
	auto audioKeys = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue