From 3deaec3b7b3f38aceefe3808ced053859d22981c Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 31 Jan 2020 02:15:48 +0100 Subject: [PATCH 1/2] Always load unifont as a fallback This prevents users from shooting themselves in the foot by selecting a different font and removing unifont from their font list --- src/font_loader.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/font_loader.h b/src/font_loader.h index 2f36ebb58957f..817b28f804cbf 100644 --- a/src/font_loader.h +++ b/src/font_loader.h @@ -2,6 +2,7 @@ #ifndef FONT_LOADER_H #define FONT_LOADER_H +#include #include #include #include @@ -51,6 +52,17 @@ class font_loader } else { config.read( "overmap_typeface", overmap_typeface ); } + + // Ensure that unifont is always loaded as a fallback font to prevent users from shooting themselves in the foot + auto ensure_unifont_loaded = []( std::vector &font_list ) { + if( std::find( std::begin( font_list ), std::end( font_list ), "unifont" ) == font_list.end() ) { + font_list.emplace_back( "unifont" ); + } + }; + ensure_unifont_loaded( typeface ); + ensure_unifont_loaded( map_typeface ); + ensure_unifont_loaded( overmap_typeface ); + } catch( const std::exception &err ) { throw std::runtime_error( std::string( "loading font settings from " ) + path + " failed: " + err.what() ); From 4d4dbef58260774e9d79ef07e2fb37f25cbff5bd Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 31 Jan 2020 02:41:22 +0100 Subject: [PATCH 2/2] Add better default font settings Return the default font to Terminus Make the (over)map font square --- data/fontdata.json | 27 ++++++++++++++------------- src/options.cpp | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/data/fontdata.json b/data/fontdata.json index 7b64e1b8f29d3..74c42c456a609 100644 --- a/data/fontdata.json +++ b/data/fontdata.json @@ -1,15 +1,16 @@ { - "fontblending": false, - "fontwidth": 8, - "fontheight": 16, - "fontsize": 16, - "typeface": "unifont", - "map_fontwidth": 8, - "map_fontheight": 16, - "map_fontsize": 16, - "map_typeface": "unifont", - "overmap_fontwidth": 8, - "overmap_fontheight": 16, - "overmap_fontsize": 16, - "overmap_typeface": "unifont" + "//1": "If more than one font is specified for a typeface the list is treated as a fallback order.", + "//2": "unifont will always be used as a 'last resort' fallback even if not listed here.", + "typeface": [ + "Terminus", + "unifont" + ], + "map_typeface": [ + "Terminus", + "unifont" + ], + "overmap_typeface": [ + "Terminus", + "unifont" + ] } diff --git a/src/options.cpp b/src/options.cpp index 805dcaaade941..351eaa3ec6636 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1681,7 +1681,7 @@ void options_manager::add_options_graphics() add( "MAP_FONT_WIDTH", "graphics", translate_marker( "Map font width" ), translate_marker( "Set the map font width. Requires restart." ), - 8, 100, 8, COPT_CURSES_HIDE + 8, 100, 16, COPT_CURSES_HIDE ); add( "MAP_FONT_HEIGHT", "graphics", translate_marker( "Map font height" ), @@ -1696,7 +1696,7 @@ void options_manager::add_options_graphics() add( "OVERMAP_FONT_WIDTH", "graphics", translate_marker( "Overmap font width" ), translate_marker( "Set the overmap font width. Requires restart." ), - 8, 100, 8, COPT_CURSES_HIDE + 8, 100, 16, COPT_CURSES_HIDE ); add( "OVERMAP_FONT_HEIGHT", "graphics", translate_marker( "Overmap font height" ),