diff --git a/data/hardwired/fonts.cfg b/data/hardwired/fonts.cfg index bf193e5fcc64..74cc3ea2f2fd 100644 --- a/data/hardwired/fonts.cfg +++ b/data/hardwired/fonts.cfg @@ -1,15 +1,38 @@ #textdomain wesnoth [fonts] - # This is marked as translatable, to allow translators to - # provide different font orders: one just has to install the - # missing fonts without needing to change the gmo files - order=_ "Lato-Regular.ttf,DejaVuSans.ttf,Andagii.ttf,DroidSansJapanese.ttf,DroidSansFallbackFull.ttf,Junicode-Regular.ttf" - family_order=_ "Lato" + # NOTE: font order keys are marked as translatable to allow translators to + # provide different font orders: one just has to install the missing fonts + # or add them to wesnoth/fonts. - # Used by GUI2 only, hence no [font] blocks for these. The font files are - # also automatically determined. - family_order_monospace=_ "DejaVu Sans Mono" + # + # Pango text-related keys. + # + # All respective font files are automatically loaded. + # + # NOTE: these are technically supposed to be lists to provide fallbacks + # like the SDL_TTF code does. However, there's a weird bug in Pango itself + # where a comma seperated list of fonts will result in newlines not being + # rendered and font space metrics being off on Windows. + # + # Additionally, despite what one might assume, "Lato" doesn't appear to + # load all Lato font variants (it has a bunch of different weight ones). + # I had thought one could specify different weights and Pango would + # automatically use the variant for that weight, but no dice. Instead, we + # need to set the weight variant we want as the distired font familt at + # render time. Right now we only have use of a "light" variant, but others + # could be added at some point. + # + # -- vultraz, 2018-02-14 + # + family_order= _ "Lato" + family_order_monospace= _ "DejaVu Sans Mono" + family_order_light= _ "Lato Light" + + # + # Legagy SDL_TTF stuff. + # + order= _ "Lato-Regular.ttf,DejaVuSans.ttf,Andagii.ttf,DroidSansJapanese.ttf,DroidSansFallbackFull.ttf,Junicode-Regular.ttf" [font] name="Lato-Regular.ttf" diff --git a/src/font/font_config.cpp b/src/font/font_config.cpp index d47bcb7cafdb..81bf942f0081 100644 --- a/src/font/font_config.cpp +++ b/src/font/font_config.cpp @@ -99,6 +99,7 @@ static bool add_font_to_fontlist(const config &fonts_config, t_string family_order_sans; t_string family_order_mono; +t_string family_order_light; /*** * Public interface @@ -141,12 +142,18 @@ 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"]; if(family_order_mono.empty()) { ERR_FT << "No monospace font family order defined, falling back to sans serif order\n"; family_order_mono = family_order_sans; } + if(family_order_light.empty()) { + ERR_FT << "No light font family order defined, falling back to sans serif order\n"; + family_order_light = family_order_sans; + } + std::vector fontlist; for(auto font : utils::split(fonts_config["order"])) { @@ -170,6 +177,8 @@ const t_string& get_font_families(family_class fclass) switch(fclass) { case FONT_MONOSPACE: return family_order_mono; + case FONT_LIGHT: + return family_order_light; default: return family_order_sans; } diff --git a/src/font/font_options.hpp b/src/font/font_options.hpp index 925aa97c355c..26d0ab001288 100644 --- a/src/font/font_options.hpp +++ b/src/font/font_options.hpp @@ -25,13 +25,16 @@ namespace font enum family_class { FONT_SANS_SERIF, - FONT_MONOSPACE + FONT_MONOSPACE, + FONT_LIGHT }; inline family_class str_to_family_class(const std::string& str) { if(str == "monospace") { return FONT_MONOSPACE; + } else if(str == "light") { + return FONT_LIGHT; } return FONT_SANS_SERIF; diff --git a/src/font/pango/font.hpp b/src/font/pango/font.hpp index aaf42921531f..29e3f2e6fbac 100644 --- a/src/font/pango/font.hpp +++ b/src/font/pango/font.hpp @@ -36,9 +36,6 @@ class p_font if(style & pango_text::STYLE_BOLD) { pango_font_description_set_weight(font_, PANGO_WEIGHT_BOLD); } - if(style & pango_text::STYLE_LIGHT) { - pango_font_description_set_weight(font_, PANGO_WEIGHT_LIGHT); - } if(style & pango_text::STYLE_UNDERLINE) { /* Do nothing here, underline is a property of the layout. */ } diff --git a/src/font/text.hpp b/src/font/text.hpp index ef338175bcb7..524262c40725 100644 --- a/src/font/text.hpp +++ b/src/font/text.hpp @@ -140,7 +140,6 @@ class pango_text STYLE_BOLD = 1, STYLE_ITALIC = 2, STYLE_UNDERLINE = 4, - STYLE_LIGHT = 8, }; /***** ***** ***** ***** Query details ***** ***** ***** *****/ diff --git a/src/gui/widgets/helper.cpp b/src/gui/widgets/helper.cpp index f3752724c27d..fda6a9574a98 100644 --- a/src/gui/widgets/helper.cpp +++ b/src/gui/widgets/helper.cpp @@ -41,7 +41,6 @@ font::pango_text::FONT_STYLE decode_font_style(const std::string& style) {"bold", font::pango_text::STYLE_BOLD}, {"italic", font::pango_text::STYLE_ITALIC}, {"underline", font::pango_text::STYLE_UNDERLINE}, - {"light", font::pango_text::STYLE_LIGHT}, }; if(style.empty()) {