Add <font:$family> tag, closes #24

This commit is contained in:
Twan van Laarhoven
2020-05-12 22:27:57 +02:00
parent 41ed84e678
commit dbb6d34bb3
6 changed files with 22 additions and 5 deletions
+10
View File
@@ -78,6 +78,7 @@ struct TextElementsFromString {
int param_id;
vector<Color> colors;
vector<double> sizes;
vector<String> fonts;
/// put angle brackets around the text?
bool bracket;
@@ -138,6 +139,14 @@ struct TextElementsFromString {
} else if (is_substr(text, tag_start, _("</color"))) {
if (!colors.empty()) colors.pop_back();
}
else if (is_substr(text, tag_start, _( "<font"))) {
size_t colon = text.find_first_of(_(">:"), tag_start);
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
fonts.push_back(text.substr(colon+1, pos-colon-2));
}
} else if (is_substr(text, tag_start, _("</font"))) {
if (!fonts.empty()) fonts.pop_back();
}
else if (is_substr(text, tag_start, _( "<size"))) {
size_t colon = text.find_first_of(_(">:"), tag_start);
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
@@ -251,6 +260,7 @@ private:
(code > 0 ? FONT_CODE : FONT_NORMAL) |
(code_kw > 0 ? FONT_CODE_KW : FONT_NORMAL) |
(code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL),
fonts.empty() ? nullptr : &fonts.back(),
param > 0 || param_ref > 0
? &param_colors[(param_id++) % param_colors_count]
: !colors.empty()