39 #include <cairo-features.h> 41 #include <fontconfig/fontconfig.h> 44 #define DBG_FT LOG_STREAM(debug, log_font) 45 #define LOG_FT LOG_STREAM(info, log_font) 46 #define WRN_FT LOG_STREAM(warn, log_font) 47 #define ERR_FT LOG_STREAM(err, log_font) 57 WRN_FT <<
"Failed opening font file '" << name <<
"': No such file or directory";
65 WRN_FT <<
"Failed opening font file '" << name <<
"': No such file or directory";
94 if(cfg_path.empty()) {
95 ERR_FT <<
"could not resolve path to fonts.cfg, file not found";
110 family_order_sans = fonts_config[
"family_order"];
111 family_order_mono = fonts_config[
"family_order_monospace"];
112 family_order_light = fonts_config[
"family_order_light"];
113 family_order_script = fonts_config[
"family_order_script"];
115 if(family_order_mono.empty()) {
116 ERR_FT <<
"No monospace font family order defined, falling back to sans serif order";
117 family_order_mono = family_order_sans;
120 if(family_order_light.empty()) {
121 ERR_FT <<
"No light font family order defined, falling back to sans serif order";
122 family_order_light = family_order_sans;
125 if(family_order_script.empty()) {
126 ERR_FT <<
"No script font family order defined, falling back to sans serif order";
127 family_order_script = family_order_sans;
137 return family_order_mono;
139 return family_order_light;
141 return family_order_script;
143 return family_order_sans;
154 if (!FcConfigAppFontAddDir(FcConfigGetCurrent(),
155 reinterpret_cast<const FcChar8 *>(font_path.c_str())))
157 ERR_FT <<
"Could not load the true type fonts";
158 throw font::error(
"font config lib failed to add the font path: '" + font_path +
"'");
161 std::string font_file = font_path +
"/fonts.conf";
162 if(!FcConfigParseAndLoad(FcConfigGetCurrent(),
163 reinterpret_cast<const FcChar8*>(font_file.c_str()),
166 ERR_FT <<
"Could not load local font configuration";
167 throw font::error(
"font config lib failed to find font.conf: '" + font_file +
"'");
171 LOG_FT <<
"Local font configuration loaded";
177 FcConfigAppFontClear(FcConfigGetCurrent());
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
family_class
Font classes for get_font_families().
bool check_font_file(std::string name)
Test if a font file exists.
Collection of helper functions relating to Pango formatting.
static bool file_exists(const bfs::path &fpath)
Definitions for the interface to Wesnoth Markup Language (WML).
const t_string & get_font_families(family_class fclass)
Returns the currently defined fonts.
void read(config &cfg, std::istream &in, abstract_validator *validator)
std::unique_ptr< std::istream > scoped_istream
static lg::log_domain log_font("font")
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir)
Returns a complete path to the actual WML file or directory or an empty string if the file isn't pres...
Declarations for File-IO.
Standard logging facilities (interface).
A config object defines a single node in a WML file, with access to child nodes.
filesystem::scoped_istream preprocess_file(const std::string &fname, preproc_map *defines)
Function to use the WML preprocessor on a file.