GUI2/Canvas: accept the standard values for the family/face attribute

Ie, "script", "monospace", etc, instead of a specific font name.
This commit is contained in:
Charles Dang 2025-02-09 23:57:06 -05:00
parent 85f47f0a7e
commit 96f8e7604f
3 changed files with 5 additions and 4 deletions

View File

@ -436,13 +436,14 @@ void pango_text::add_attribute_fg_color(const unsigned start_offset, const unsig
}
}
void pango_text::add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, const std::string& family)
void pango_text::add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, font::family_class family)
{
attribute_start_offset_ = start_offset;
attribute_end_offset_ = end_offset;
if (attribute_start_offset_ != attribute_end_offset_) {
PangoAttribute *attr = pango_attr_family_new(family.c_str());
const t_string& family_name = get_font_families(family);
PangoAttribute *attr = pango_attr_family_new(family_name.c_str());
attr->start_index = attribute_start_offset_;
attr->end_index = attribute_end_offset_;

View File

@ -382,7 +382,7 @@ public:
* @param end_offset Byte index of the cursor where size change ends
* @param family The font family
*/
void add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, const std::string& family);
void add_attribute_font_family(const unsigned start_offset, const unsigned end_offset, font::family_class family);
/** Clears all attributes from the global attribute list */
void clear_attribute_list();

View File

@ -473,7 +473,7 @@ void text_shape::draw(wfl::map_formula_callable& variables)
} else if (name == "font_size"||name == "size") {
text_renderer.add_attribute_size(start, end, attr["value"].to_int(font::SIZE_NORMAL));
} else if (name == "font_family"||name == "face") {
text_renderer.add_attribute_font_family(start, end, attr["value"].str(font::get_font_families(font::FONT_SANS_SERIF)));
text_renderer.add_attribute_font_family(start, end, font::str_to_family_class(attr["value"]));
} else if (name == "weight") {
text_renderer.add_attribute_weight(start, end, decode_text_weight(attr["value"]));
} else if (name == "style") {