Qt: Add runtime downloading of CJK OSD fonts

This commit is contained in:
Stenzek 2024-01-07 15:27:39 +10:00 committed by Connor McLaughlin
parent 7a045d837b
commit 46e1e3d904
8 changed files with 127 additions and 73 deletions

7
.gitignore vendored
View File

@ -85,6 +85,13 @@ oprofile_data/
/bin/textures /bin/textures
/bin/translations /bin/translations
/bin/inputprofiles /bin/inputprofiles
# Resources that are runtime downloaded.
/bin/resources/NotoSansJP-Regular.ttf
/bin/resources/NotoSansKR-Regular.ttf
/bin/resources/NotoSansSC-Regular.ttf
/bin/resources/NotoSansTC-Regular.ttf
/deps /deps
/ipch /ipch

View File

@ -1644,7 +1644,10 @@ void MainWindow::reloadThemeSpecificImages()
void MainWindow::updateLanguage() void MainWindow::updateLanguage()
{ {
QtHost::InstallTranslator(); // Remove the settings window, so it doesn't mess with any popups that happen (e.g. font download).
destroySubWindows();
QtHost::InstallTranslator(this);
recreate(); recreate();
} }
@ -2885,6 +2888,12 @@ MainWindow::VMLock MainWindow::pauseAndLockVM()
// Now we'll either have a borderless window, or a regular window (if we were exclusive fullscreen). // Now we'll either have a borderless window, or a regular window (if we were exclusive fullscreen).
QWidget* dialog_parent = getDisplayContainer(); QWidget* dialog_parent = getDisplayContainer();
// Ensure main window is visible.
if (!g_main_window->isVisible())
g_main_window->show();
g_main_window->raise();
g_main_window->activateWindow();
return VMLock(dialog_parent, was_paused, was_fullscreen); return VMLock(dialog_parent, was_paused, was_fullscreen);
} }
@ -2922,6 +2931,19 @@ MainWindow::VMLock::~VMLock()
g_emu_thread->setVMPaused(false); g_emu_thread->setVMPaused(false);
} }
MainWindow::VMLock& MainWindow::VMLock::operator=(VMLock&& lock)
{
m_dialog_parent = lock.m_dialog_parent;
m_was_paused = lock.m_was_paused;
m_was_fullscreen = lock.m_was_fullscreen;
lock.m_dialog_parent = nullptr;
lock.m_was_paused = true;
lock.m_was_fullscreen = false;
return *this;
}
void MainWindow::VMLock::cancelResume() void MainWindow::VMLock::cancelResume()
{ {
m_was_paused = true; m_was_paused = true;

View File

@ -54,6 +54,9 @@ public:
VMLock(const VMLock&) = delete; VMLock(const VMLock&) = delete;
~VMLock(); ~VMLock();
VMLock& operator=(VMLock&& lock);
VMLock& operator=(const VMLock&) = delete;
/// Returns the parent widget, which can be used for any popup dialogs. /// Returns the parent widget, which can be used for any popup dialogs.
__fi QWidget* getDialogParent() const { return m_dialog_parent; } __fi QWidget* getDialogParent() const { return m_dialog_parent; }

View File

@ -1242,7 +1242,7 @@ bool QtHost::InitializeConfig()
LogSink::SetBlockSystemConsole(QtHost::InNoGUIMode()); LogSink::SetBlockSystemConsole(QtHost::InNoGUIMode());
VMManager::Internal::LoadStartupSettings(); VMManager::Internal::LoadStartupSettings();
InstallTranslator(); InstallTranslator(nullptr);
return true; return true;
} }

View File

@ -259,7 +259,7 @@ namespace QtHost
std::vector<std::pair<QString, QString>> GetAvailableLanguageList(); std::vector<std::pair<QString, QString>> GetAvailableLanguageList();
/// Call when the language changes. /// Call when the language changes.
void InstallTranslator(); void InstallTranslator(QWidget* dialog_parent);
/// Returns the application name and version, optionally including debug/devel config indicator. /// Returns the application name and version, optionally including debug/devel config indicator.
QString GetAppNameAndVersion(); QString GetAppNameAndVersion();

View File

@ -203,7 +203,7 @@ void SetupWizardDialog::themeChanged()
void SetupWizardDialog::languageChanged() void SetupWizardDialog::languageChanged()
{ {
// Skip the recreation, since we don't have many dynamic UI elements. // Skip the recreation, since we don't have many dynamic UI elements.
QtHost::InstallTranslator(); QtHost::InstallTranslator(this);
m_ui.retranslateUi(this); m_ui.retranslateUi(this);
} }

File diff suppressed because one or more lines are too long

View File

@ -393,10 +393,8 @@ bool ImGuiManager::LoadFontData()
{ {
if (s_standard_font_data.empty()) if (s_standard_font_data.empty())
{ {
std::optional<std::vector<u8>> font_data = pxAssertRel(!s_font_path.empty(), "Font path has not been set.");
s_font_path.empty() ? FileSystem::ReadBinaryFile( std::optional<std::vector<u8>> font_data = FileSystem::ReadBinaryFile(s_font_path.c_str());
EmuFolders::GetOverridableResourcePath("fonts" FS_OSPATH_SEPARATOR_STR "Roboto-Regular.ttf").c_str()) :
FileSystem::ReadBinaryFile(s_font_path.c_str());
if (!font_data.has_value()) if (!font_data.has_value())
return false; return false;