diff --git a/src/cata_imgui.cpp b/src/cata_imgui.cpp index 578c9709730bb..6243488674d14 100644 --- a/src/cata_imgui.cpp +++ b/src/cata_imgui.cpp @@ -255,20 +255,21 @@ static int GetFallbackCharWidth( ImWchar c, const float scale ) return fontwidth * mk_wcwidth( c ) * scale; } -void cataimgui::client::load_fonts( const std::unique_ptr &cata_font, - const std::array::COLOR_NAMES_COUNT> &windowsPalette ) +void cataimgui::client::load_fonts( const Font_Ptr &cata_font, + const std::array::COLOR_NAMES_COUNT> &windowsPalette, + const std::vector &typefaces ) { ImGuiIO &io = ImGui::GetIO(); if( ImGui::GetIO().FontDefault == nullptr ) { - std::vector typefaces; - ensure_unifont_loaded( typefaces ); + std::vector io_typefaces{ typefaces }; + ensure_unifont_loaded( io_typefaces ); for( size_t index = 0; index < color_loader::COLOR_NAMES_COUNT; index++ ) { SDL_Color sdlCol = windowsPalette[index]; ImU32 rgb = sdlCol.b << 16 | sdlCol.g << 8 | sdlCol.r; sdlColorsToCata[rgb] = index; } - io.FontDefault = io.Fonts->AddFontFromFileTTF( typefaces[0].c_str(), fontheight, nullptr, + io.FontDefault = io.Fonts->AddFontFromFileTTF( io_typefaces[0].c_str(), fontheight, nullptr, io.Fonts->GetGlyphRangesDefault() ); io.Fonts->Fonts[0]->SetFallbackStrSizeCallback( GetFallbackStrWidth ); io.Fonts->Fonts[0]->SetFallbackCharSizeCallback( GetFallbackCharWidth ); diff --git a/src/cata_imgui.h b/src/cata_imgui.h index 3e23ef3af667c..c927d0ade6bd5 100644 --- a/src/cata_imgui.h +++ b/src/cata_imgui.h @@ -60,8 +60,9 @@ class client #else client( const SDL_Renderer_Ptr &sdl_renderer, const SDL_Window_Ptr &sdl_window, const GeometryRenderer_Ptr &sdl_geometry ); - void load_fonts( const std::unique_ptr &cata_font, - const std::array::COLOR_NAMES_COUNT> &windowsPalette ); + void load_fonts( const std::unique_ptr &cata_fonts, + const std::array::COLOR_NAMES_COUNT> &windowsPalette, + const std::vector &typeface ); #endif ~client(); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 44eb79bb479aa..ba782827c9ed9 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3728,7 +3728,7 @@ void catacurses::init_interface() windowsPalette, fl.overmap_typeface, fl.overmap_fontsize, fl.fontblending ); stdscr = newwin( get_terminal_height(), get_terminal_width(), point_zero ); //newwin calls `new WINDOW`, and that will throw, but not return nullptr. - imclient->load_fonts( font, windowsPalette ); + imclient->load_fonts( font, windowsPalette, fl.typeface ); #if defined(__ANDROID__) // Make sure we initialize preview_terminal_width/height to sensible values preview_terminal_width = TERMINAL_WIDTH * fontwidth;