Skip to content
Snippets Groups Projects

dialog-ui: Try to load fonts provided by Steam

Merged Simon McVittie requested to merge wip/task462 into main
1 file
+ 1
0
Compare changes
  • Side-by-side
  • Inline
+ 34
6
@@ -453,6 +453,8 @@ dialog_new(const char *title)
unsigned flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
int width;
int height;
int message_font_size;
int title_font_size;
if (global_sdl_init() < 0)
return NULL;
@@ -501,13 +503,33 @@ dialog_new(const char *title)
}
SDL_GetRendererOutputSize(self->renderer, &self->w, &self->h);
title_font_size = (24.0 * self->h) / 480.0;
message_font_size = (18.0 * self->h) / 480.0;
self->title_font = ttf_load_font("sans-serif", "bold",
(24.0 * self->h) / 480.0);
self->title_font = ttf_load_steam_ui_font("GoNotoKurrent-Bold.ttf",
title_font_size);
if (self->title_font == NULL) {
self->title_font = ttf_load_font("sans-serif", NULL,
(24.0 * self->h) / 480.0);
debug("%s, falling back to GoNotoKurrent-Regular with artificial bold", SDL_GetError());
self->title_font = ttf_load_steam_ui_font("GoNotoKurrent-Regular.ttf",
title_font_size);
if (self->title_font != NULL) {
TTF_SetFontStyle(self->title_font, TTF_STYLE_BOLD);
}
}
if (self->title_font == NULL) {
debug("%s, falling back to sans-serif bold", SDL_GetError());
self->title_font = ttf_load_font_family("sans-serif", "bold",
title_font_size);
}
if (self->title_font == NULL) {
debug("%s, falling back to sans-serif with artificial bold", SDL_GetError());
self->title_font = ttf_load_font_family("sans-serif", NULL,
title_font_size);
if (self->title_font != NULL) {
TTF_SetFontStyle(self->title_font, TTF_STYLE_BOLD);
}
}
if (self->title_font == NULL) {
@@ -519,4+541,4 @@
return NULL;
}
self->message_font = ttf_load_font("sans-serif", NULL,
(18.0 * self->h) / 480.0);
self->message_font = ttf_load_steam_ui_font("GoNotoKurrent-Regular.ttf",
title_font_size);
if (self->message_font == NULL) {
debug("%s, falling back to sans-serif", SDL_GetError());
self->message_font = ttf_load_font_family("sans-serif", NULL,
message_font_size);
}
if (self->message_font == NULL) {
prefix_sdl_error ("Failed to load message font");
Loading