diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index b69689b05cb97..34f92db75a81d 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -366,7 +366,8 @@ static void AddGlyphRangesMisc( UNUSED ImFontGlyphRangesBuilder *b ) } -// Load all fonts that exist in typefaces list +// Load the first font that exists in typefaces, falling back to unifont +// if none of them exist. // - typefaces is a list of paths. static void load_font( ImGuiIO &io, const std::vector &typefaces, const ImWchar *ranges ) @@ -374,23 +375,21 @@ static void load_font( ImGuiIO &io, const std::vector &typefaces, std::vector io_typefaces{ typefaces }; ensure_unifont_loaded( io_typefaces ); - ImFontConfig config = ImFontConfig(); - - bool first = true; auto it = std::begin( io_typefaces ); for( ; it != std::end( io_typefaces ); ++it ) { if( !file_exist( it->path ) ) { debugmsg( "Font file '%s' does not exist.", it->path ); - } else { - config.MergeMode = !first; - config.FontBuilderFlags = it->imgui_config(); - io.Fonts->AddFontFromFileTTF( it->path.c_str(), fontheight, &config, ranges ); - first = false; } + break; } - if( first ) { + if( it == std::end( io_typefaces ) ) { debugmsg( "No fonts were found in the fontdata file." ); } + + ImFontConfig config = ImFontConfig(); + config.FontBuilderFlags = it->imgui_config(); + + io.Fonts->AddFontFromFileTTF( it->path.c_str(), fontheight, &config, ranges ); } static void check_font( const ImFont *font )