Skip to content

Commit

Permalink
Fonts: added script font family
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Feb 14, 2018
1 parent 7ca648d commit f4a1abd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/hardwired/fonts.cfg
Expand Up @@ -28,6 +28,7 @@
family_order= _ "Lato"
family_order_monospace= _ "DejaVu Sans Mono"
family_order_light= _ "Lato Light"
family_order_script = _ "Oldania ADF Std"

#
# Legagy SDL_TTF stuff.
Expand Down
9 changes: 9 additions & 0 deletions src/font/font_config.cpp
Expand Up @@ -115,6 +115,7 @@ bool is_valid_font_file(const std::string& file)
t_string family_order_sans;
t_string family_order_mono;
t_string family_order_light;
t_string family_order_script;

} // end anon namespace

Expand Down Expand Up @@ -160,6 +161,7 @@ bool load_font_config()
family_order_sans = fonts_config["family_order"];
family_order_mono = fonts_config["family_order_monospace"];
family_order_light = fonts_config["family_order_light"];
family_order_script = fonts_config["family_order_script"];

if(family_order_mono.empty()) {
ERR_FT << "No monospace font family order defined, falling back to sans serif order\n";
Expand All @@ -171,6 +173,11 @@ bool load_font_config()
family_order_light = family_order_sans;
}

if(family_order_script.empty()) {
ERR_FT << "No script font family order defined, falling back to sans serif order\n";
family_order_script = family_order_sans;
}

std::vector<font::subset_descriptor> fontlist;

for(auto font : utils::split(fonts_config["order"])) {
Expand All @@ -196,6 +203,8 @@ const t_string& get_font_families(family_class fclass)
return family_order_mono;
case FONT_LIGHT:
return family_order_light;
case FONT_SCRIPT:
return family_order_script;
default:
return family_order_sans;
}
Expand Down
5 changes: 4 additions & 1 deletion src/font/font_options.hpp
Expand Up @@ -26,7 +26,8 @@ enum family_class
{
FONT_SANS_SERIF,
FONT_MONOSPACE,
FONT_LIGHT
FONT_LIGHT,
FONT_SCRIPT,
};

inline family_class str_to_family_class(const std::string& str)
Expand All @@ -35,6 +36,8 @@ inline family_class str_to_family_class(const std::string& str)
return FONT_MONOSPACE;
} else if(str == "light") {
return FONT_LIGHT;
} else if(str == "script") {
return FONT_SCRIPT;
}

return FONT_SANS_SERIF;
Expand Down

0 comments on commit f4a1abd

Please sign in to comment.