mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-14 18:34:32 +00:00
Qt: Use Roboto for cover placeholder text
Consistency across platforms.
This commit is contained in:
@@ -333,6 +333,7 @@ void GameListModel::createPlaceholderImage(QImage& image, const QImage& placehol
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(std::max(static_cast<int>(64.0f * scale), 1));
|
||||
font.setFamilies(QtHost::GetRobotoFontFamilies());
|
||||
painter.setFont(font);
|
||||
|
||||
const int margin = static_cast<int>(30.0f * scale);
|
||||
|
||||
@@ -141,6 +141,8 @@ struct State
|
||||
std::unique_ptr<QTimer> settings_save_timer;
|
||||
std::vector<QTranslator*> translators;
|
||||
QLocale app_locale;
|
||||
std::once_flag roboto_font_once_flag;
|
||||
QStringList roboto_font_families;
|
||||
bool batch_mode = false;
|
||||
bool nogui_mode = false;
|
||||
bool start_fullscreen_ui = false;
|
||||
@@ -2731,6 +2733,28 @@ std::string QtHost::GetResourcePath(std::string_view filename, bool allow_overri
|
||||
Path::Combine(EmuFolders::Resources, filename);
|
||||
}
|
||||
|
||||
const QStringList& QtHost::GetRobotoFontFamilies()
|
||||
{
|
||||
std::call_once(s_state.roboto_font_once_flag, []() {
|
||||
const int font_id = QFontDatabase::addApplicationFont(
|
||||
QString::fromStdString(Path::Combine(EmuFolders::Resources, "fonts/Roboto-VariableFont_wdth,wght.ttf")));
|
||||
if (font_id < 0)
|
||||
{
|
||||
ERROR_LOG("Failed to load Roboto font.");
|
||||
return;
|
||||
}
|
||||
|
||||
s_state.roboto_font_families = QFontDatabase::applicationFontFamilies(font_id);
|
||||
if (s_state.roboto_font_families.isEmpty())
|
||||
{
|
||||
ERROR_LOG("Failed to get Roboto font family.");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
return s_state.roboto_font_families;
|
||||
}
|
||||
|
||||
bool Host::ResourceFileExists(std::string_view filename, bool allow_override)
|
||||
{
|
||||
const std::string path = QtHost::GetResourcePath(filename, allow_override);
|
||||
|
||||
@@ -379,6 +379,9 @@ QString GetResourcesBasePath();
|
||||
/// Returns the path to the specified resource.
|
||||
std::string GetResourcePath(std::string_view name, bool allow_override);
|
||||
|
||||
/// Returns the font family for the bundled Roboto font.
|
||||
const QStringList& GetRobotoFontFamilies();
|
||||
|
||||
/// Returns the base settings interface. Should lock before manipulating.
|
||||
INISettingsInterface* GetBaseSettingsInterface();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user