Skip to content

Commit e214241

Browse files
committed
Qt: Use Roboto for cover placeholder text
Consistency across platforms.
1 parent 17aa588 commit e214241

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/duckstation-qt/gamelistwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ void GameListModel::createPlaceholderImage(QImage& image, const QImage& placehol
333333
{
334334
QFont font;
335335
font.setPixelSize(std::max(static_cast<int>(64.0f * scale), 1));
336+
font.setFamilies(QtHost::GetRobotoFontFamilies());
336337
painter.setFont(font);
337338

338339
const int margin = static_cast<int>(30.0f * scale);

src/duckstation-qt/qthost.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ struct State
141141
std::unique_ptr<QTimer> settings_save_timer;
142142
std::vector<QTranslator*> translators;
143143
QLocale app_locale;
144+
std::once_flag roboto_font_once_flag;
145+
QStringList roboto_font_families;
144146
bool batch_mode = false;
145147
bool nogui_mode = false;
146148
bool start_fullscreen_ui = false;
@@ -2731,6 +2733,28 @@ std::string QtHost::GetResourcePath(std::string_view filename, bool allow_overri
27312733
Path::Combine(EmuFolders::Resources, filename);
27322734
}
27332735

2736+
const QStringList& QtHost::GetRobotoFontFamilies()
2737+
{
2738+
std::call_once(s_state.roboto_font_once_flag, []() {
2739+
const int font_id = QFontDatabase::addApplicationFont(
2740+
QString::fromStdString(Path::Combine(EmuFolders::Resources, "fonts/Roboto-VariableFont_wdth,wght.ttf")));
2741+
if (font_id < 0)
2742+
{
2743+
ERROR_LOG("Failed to load Roboto font.");
2744+
return;
2745+
}
2746+
2747+
s_state.roboto_font_families = QFontDatabase::applicationFontFamilies(font_id);
2748+
if (s_state.roboto_font_families.isEmpty())
2749+
{
2750+
ERROR_LOG("Failed to get Roboto font family.");
2751+
return;
2752+
}
2753+
});
2754+
2755+
return s_state.roboto_font_families;
2756+
}
2757+
27342758
bool Host::ResourceFileExists(std::string_view filename, bool allow_override)
27352759
{
27362760
const std::string path = QtHost::GetResourcePath(filename, allow_override);

src/duckstation-qt/qthost.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ QString GetResourcesBasePath();
379379
/// Returns the path to the specified resource.
380380
std::string GetResourcePath(std::string_view name, bool allow_override);
381381

382+
/// Returns the font family for the bundled Roboto font.
383+
const QStringList& GetRobotoFontFamilies();
384+
382385
/// Returns the base settings interface. Should lock before manipulating.
383386
INISettingsInterface* GetBaseSettingsInterface();
384387

0 commit comments

Comments
 (0)