mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-14 10:00:36 +00:00
Font: make family_class a scoped enum
This commit is contained in:
parent
87a4b55b31
commit
72a4ec9270
|
@ -1425,7 +1425,7 @@ void display::draw_label(const theme::label& label)
|
|||
} else if(text.empty() == false) {
|
||||
font::pango_text& renderer = font::get_text_renderer();
|
||||
renderer.set_text(text, false);
|
||||
renderer.set_family_class(font::FONT_SANS_SERIF);
|
||||
renderer.set_family_class(font::family_class::sans_serif);
|
||||
renderer.set_font_size(label.font_size());
|
||||
renderer.set_font_style(font::pango_text::STYLE_NORMAL);
|
||||
renderer.set_foreground_color(text_color);
|
||||
|
@ -2960,7 +2960,7 @@ void display::draw_report(const std::string& report_name, bool tooltip_test)
|
|||
}
|
||||
text.set_link_aware(false)
|
||||
.set_text(t, true);
|
||||
text.set_family_class(font::FONT_SANS_SERIF)
|
||||
text.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(item->font_size())
|
||||
.set_font_style(font::pango_text::STYLE_NORMAL)
|
||||
.set_alignment(PANGO_ALIGN_LEFT)
|
||||
|
|
|
@ -123,7 +123,7 @@ bool floating_label::create_texture()
|
|||
font::pango_text& text = font::get_text_renderer();
|
||||
|
||||
text.set_link_aware(false)
|
||||
.set_family_class(font::FONT_SANS_SERIF)
|
||||
.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(font_size_)
|
||||
.set_font_style(font::pango_text::STYLE_NORMAL)
|
||||
.set_alignment(PANGO_ALIGN_LEFT)
|
||||
|
|
|
@ -166,7 +166,6 @@ void add_attribute_font_family(attribute_list& list, unsigned offset_start, unsi
|
|||
|
||||
DBG_GUI_D << "attribute: font family";
|
||||
DBG_GUI_D << "attribute start: " << offset_start << " end : " << offset_end;
|
||||
DBG_GUI_D << "font family: " << family;
|
||||
|
||||
attr.add_to(list);
|
||||
}
|
||||
|
|
|
@ -95,9 +95,9 @@ bool load_font_config()
|
|||
const t_string& get_font_families(family_class fclass)
|
||||
{
|
||||
switch(fclass) {
|
||||
case FONT_MONOSPACE:
|
||||
case family_class::monospace:
|
||||
return family_order_mono;
|
||||
case FONT_SCRIPT:
|
||||
case family_class::script:
|
||||
return family_order_script;
|
||||
default:
|
||||
return family_order_sans;
|
||||
|
|
|
@ -51,6 +51,6 @@ struct manager {
|
|||
bool load_font_config();
|
||||
|
||||
/** Returns the currently defined fonts. */
|
||||
const t_string& get_font_families(family_class fclass = FONT_SANS_SERIF);
|
||||
const t_string& get_font_families(family_class fclass);
|
||||
|
||||
} // end namespace font
|
||||
|
|
|
@ -20,25 +20,22 @@
|
|||
namespace font
|
||||
{
|
||||
|
||||
/**
|
||||
* Font classes for get_font_families().
|
||||
*/
|
||||
enum family_class
|
||||
enum class family_class
|
||||
{
|
||||
FONT_SANS_SERIF,
|
||||
FONT_MONOSPACE,
|
||||
FONT_SCRIPT,
|
||||
sans_serif,
|
||||
monospace,
|
||||
script,
|
||||
};
|
||||
|
||||
inline family_class str_to_family_class(const std::string& str)
|
||||
inline family_class decode_family_class(const std::string& str)
|
||||
{
|
||||
if(str == "monospace") {
|
||||
return FONT_MONOSPACE;
|
||||
return family_class::monospace;
|
||||
} else if(str == "script") {
|
||||
return FONT_SCRIPT;
|
||||
return family_class::script;
|
||||
} else {
|
||||
return family_class::sans_serif;
|
||||
}
|
||||
|
||||
return FONT_SANS_SERIF;
|
||||
}
|
||||
|
||||
} // end namespace font
|
||||
|
|
|
@ -46,7 +46,7 @@ texture pango_render_text(const std::string& text, int size, const color_t& colo
|
|||
auto& ptext = private_renderer();
|
||||
|
||||
ptext.set_text(text, use_markup);
|
||||
ptext.set_family_class(font::FONT_SANS_SERIF)
|
||||
ptext.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(size)
|
||||
.set_font_style(style)
|
||||
.set_maximum_height(-1, false)
|
||||
|
@ -62,7 +62,7 @@ std::pair<int, int> pango_line_size(const std::string& line, int font_size, font
|
|||
auto& ptext = private_renderer();
|
||||
|
||||
ptext.set_text(line, false);
|
||||
ptext.set_family_class(font::FONT_SANS_SERIF)
|
||||
ptext.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(font_size)
|
||||
.set_font_style(font_style)
|
||||
.set_maximum_height(-1, false)
|
||||
|
@ -84,7 +84,7 @@ std::string pango_word_wrap(const std::string& unwrapped_text, int font_size, in
|
|||
auto& ptext = private_renderer();
|
||||
|
||||
ptext.set_text(unwrapped_text, false);
|
||||
ptext.set_family_class(font::FONT_SANS_SERIF)
|
||||
ptext.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(font_size)
|
||||
.set_font_style(font::pango_text::STYLE_NORMAL)
|
||||
.set_maximum_height(max_height, true)
|
||||
|
@ -110,7 +110,7 @@ rect pango_draw_text(bool actually_draw, const rect& area, int size, const color
|
|||
auto& ptext = private_renderer();
|
||||
|
||||
ptext.set_text(text, false);
|
||||
ptext.set_family_class(font::FONT_SANS_SERIF)
|
||||
ptext.set_family_class(font::family_class::sans_serif)
|
||||
.set_font_size(size)
|
||||
.set_font_style(style)
|
||||
.set_maximum_width(-1)
|
||||
|
|
|
@ -51,7 +51,7 @@ pango_text::pango_text()
|
|||
, markedup_text_(false)
|
||||
, link_aware_(false)
|
||||
, link_color_()
|
||||
, font_class_(font::FONT_SANS_SERIF)
|
||||
, font_class_(font::family_class::sans_serif)
|
||||
, font_size_(14)
|
||||
, font_style_(STYLE_NORMAL)
|
||||
, foreground_color_() // solid white
|
||||
|
|
|
@ -534,7 +534,7 @@ pango_text& get_text_renderer();
|
|||
* font. More specifically, the result is the sum of the maximum
|
||||
* ascent and descent lengths.
|
||||
*/
|
||||
int get_max_height(unsigned size, font::family_class fclass = font::FONT_SANS_SERIF, pango_text::FONT_STYLE style = pango_text::STYLE_NORMAL);
|
||||
int get_max_height(unsigned size, font::family_class fclass = font::family_class::sans_serif, pango_text::FONT_STYLE style = pango_text::STYLE_NORMAL);
|
||||
|
||||
/* Returns the default line spacing factor
|
||||
* For now hardcoded here */
|
||||
|
|
|
@ -415,7 +415,7 @@ auto parse_attributes(const config::const_child_itors& range)
|
|||
} else if (name == "font_size" || name == "size") {
|
||||
add_attribute_size(text_attributes, start, end, attr["value"].to_int(font::SIZE_NORMAL));
|
||||
} else if (name == "font_family" || name == "face") {
|
||||
add_attribute_font_family(text_attributes, start, end, font::str_to_family_class(attr["value"]));
|
||||
add_attribute_font_family(text_attributes, start, end, font::decode_family_class(attr["value"]));
|
||||
} else if (name == "weight") {
|
||||
add_attribute_weight(text_attributes, start, end, decode_text_weight(attr["value"]));
|
||||
} else if (name == "style") {
|
||||
|
@ -440,7 +440,7 @@ auto parse_attributes(const config::const_child_itors& range)
|
|||
|
||||
text_shape::text_shape(const config& cfg, wfl::action_function_symbol_table& functions)
|
||||
: rect_bounded_shape(cfg)
|
||||
, font_family_(font::str_to_family_class(cfg["font_family"]))
|
||||
, font_family_(font::decode_family_class(cfg["font_family"]))
|
||||
, font_size_(cfg["font_size"], font::SIZE_NORMAL)
|
||||
, font_style_(decode_font_style(cfg["font_style"]))
|
||||
, text_alignment_(cfg["text_alignment"])
|
||||
|
|
|
@ -42,7 +42,7 @@ resolution_definition::resolution_definition(const config& cfg)
|
|||
, text_extra_width(cfg["text_extra_width"].to_unsigned())
|
||||
, text_extra_height(cfg["text_extra_height"].to_unsigned())
|
||||
, text_font_size(cfg["text_font_size"])
|
||||
, text_font_family(font::str_to_family_class(cfg["text_font_family"]))
|
||||
, text_font_family(font::decode_family_class(cfg["text_font_family"]))
|
||||
, text_font_style(decode_font_style(cfg["text_font_style"]))
|
||||
, state()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user