Fonts: added script font family

This commit is contained in:
Charles Dang 2018-02-14 14:39:51 +11:00
parent 7ca648d0dd
commit f4a1abdb9b
3 changed files with 14 additions and 1 deletions

View file

@ -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.

View file

@ -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
@ -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";
@ -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"])) {
@ -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;
}

View file

@ -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)
@ -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;