Skip to content

Commit

Permalink
Check the typeface file exists (CleverRaven#75937)
Browse files Browse the repository at this point in the history
* Check the typeface file exists

* Obey lint
  • Loading branch information
alef committed Aug 26, 2024
1 parent 982e957 commit ebcaf61
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cata_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ void cataimgui::client::load_fonts( const Font_Ptr &cata_font,
ImU32 rgb = sdlCol.b << 16 | sdlCol.g << 8 | sdlCol.r;
sdlColorsToCata[rgb] = index;
}
io.FontDefault = io.Fonts->AddFontFromFileTTF( io_typefaces[0].c_str(), fontheight, nullptr,
auto it = std::find_if( io_typefaces.begin(),
io_typefaces.end(), []( const std::string & io_typeface ) {
std::filesystem::path path( io_typeface );
return std::filesystem::exists( path );
} );
std::string existing_typeface = *it;
io.FontDefault = io.Fonts->AddFontFromFileTTF( existing_typeface.c_str(), fontheight, nullptr,
io.Fonts->GetGlyphRangesDefault() );
io.Fonts->Fonts[0]->SetFallbackStrSizeCallback( GetFallbackStrWidth );
io.Fonts->Fonts[0]->SetFallbackCharSizeCallback( GetFallbackCharWidth );
Expand Down

0 comments on commit ebcaf61

Please sign in to comment.