Skip to content

Commit

Permalink
Revert "load all of the user’s chosen font files as fallbacks for img…
Browse files Browse the repository at this point in the history
…ui to use"

This reverts commit d4ff850.
  • Loading branch information
SurFlurer committed Jan 12, 2025
1 parent fcc1a72 commit e31b491
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/cata_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,31 +366,30 @@ 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<font_config> &typefaces,
const ImWchar *ranges )
{
std::vector<font_config> 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 )
Expand Down

0 comments on commit e31b491

Please sign in to comment.