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() );