Skip to content

Commit

Permalink
Always load unifont as a fallback
Browse files Browse the repository at this point in the history
This prevents users from shooting themselves in the foot by selecting a
different font and removing unifont from their font list
  • Loading branch information
ifreund committed Jan 31, 2020
1 parent bab7781 commit 3deaec3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/font_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifndef FONT_LOADER_H
#define FONT_LOADER_H

#include <algorithm>
#include <fstream>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -51,6 +52,17 @@ class font_loader
} else {
config.read( "overmap_typeface", overmap_typeface );
}

// Ensure that unifont is always loaded as a fallback font to prevent users from shooting themselves in the foot
auto ensure_unifont_loaded = []( std::vector<std::string> &font_list ) {
if( std::find( std::begin( font_list ), std::end( font_list ), "unifont" ) == font_list.end() ) {
font_list.emplace_back( "unifont" );
}
};
ensure_unifont_loaded( typeface );
ensure_unifont_loaded( map_typeface );
ensure_unifont_loaded( overmap_typeface );

} catch( const std::exception &err ) {
throw std::runtime_error( std::string( "loading font settings from " ) + path + " failed: " +
err.what() );
Expand Down

0 comments on commit 3deaec3

Please sign in to comment.