Skip to content

Commit

Permalink
Adds font fallback support for map and overmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox committed Jan 29, 2020
1 parent bfee67a commit 2c6e834
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
16 changes: 12 additions & 4 deletions src/font_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class font_loader
public:
bool fontblending = false;
std::vector<std::string> typeface;
std::string map_typeface;
std::string overmap_typeface;
std::vector<std::string> map_typeface;
std::vector<std::string> overmap_typeface;
int fontwidth = 8;
int fontheight = 16;
int fontsize = 16;
Expand All @@ -41,8 +41,16 @@ class font_loader
} else {
config.read( "typeface", typeface );
}
config.read( "map_typeface", map_typeface );
config.read( "overmap_typeface", overmap_typeface );
if( config.has_string( "map_typeface" ) ) {
map_typeface.emplace_back( config.get_string( "map_typeface" ) );
} else {
config.read( "map_typeface", map_typeface );
}
if( config.has_string( "overmap_typeface" ) ) {
overmap_typeface.emplace_back( config.get_string( "overmap_typeface" ) );
} else {
config.read( "overmap_typeface", overmap_typeface );
}
} catch( const std::exception &err ) {
throw std::runtime_error( std::string( "loading font settings from " ) + path + " failed: " +
err.what() );
Expand Down
12 changes: 6 additions & 6 deletions src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class FontFallbackList : public Font
};

static std::unique_ptr<FontFallbackList> font;
static std::unique_ptr<Font> map_font;
static std::unique_ptr<Font> overmap_font;
static std::unique_ptr<FontFallbackList> map_font;
static std::unique_ptr<FontFallbackList> overmap_font;

static SDL_Window_Ptr window;
static SDL_Renderer_Ptr renderer;
Expand Down Expand Up @@ -3555,10 +3555,10 @@ void catacurses::init_interface()
// Reset the font pointer
font = std::make_unique<FontFallbackList>( fl.fontwidth, fl.fontheight,
fl.typeface, fl.fontsize, fl.fontblending );
map_font = Font::load_font( fl.map_typeface, fl.map_fontsize, fl.map_fontwidth, fl.map_fontheight,
fl.fontblending );
overmap_font = Font::load_font( fl.overmap_typeface, fl.overmap_fontsize,
fl.overmap_fontwidth, fl.overmap_fontheight, fl.fontblending );
map_font = std::make_unique<FontFallbackList>( fl.map_fontwidth, fl.map_fontheight,
fl.map_typeface, fl.map_fontsize, fl.fontblending );
overmap_font = std::make_unique<FontFallbackList>( fl.overmap_fontwidth, fl.overmap_fontheight,
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.

Expand Down

0 comments on commit 2c6e834

Please sign in to comment.