diff --git a/src/data/font.cpp b/src/data/font.cpp index d5c34b7c..db81e41b 100644 --- a/src/data/font.cpp +++ b/src/data/font.cpp @@ -50,7 +50,7 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const { shadow_color.initDependencies(ctx, dep); } -FontP Font::make(int add_flags, String const* other_family, Color const* other_color, double const* other_size) const { +FontP Font::make(int add_flags, bool add_underline, String const* other_family, Color const* other_color, double const* other_size) const { FontP f(new Font(*this)); f->flags |= add_flags; if (add_flags & FONT_CODE_STRING) { @@ -66,6 +66,9 @@ FontP Font::make(int add_flags, String const* other_family, Color const* other_c if (add_flags & FONT_SOFT) { f->color = f->separator_color; f->shadow_displacement = RealSize(0,0); // no shadow + } + if (add_underline) { + f->underline = true; } if (other_color) { f->color = *other_color; diff --git a/src/data/font.hpp b/src/data/font.hpp index 13a055a4..cc030f92 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -60,7 +60,7 @@ public: } /// Add style to a font, and optionally change the font family, color and size - FontP make(int add_flags, String const* other_family, Color const* other_color, double const* other_size) const; + FontP make(int add_flags, bool add_underline, String const* other_family, Color const* other_color, double const* other_size) const; /// Convert this font to a wxFont wxFont toWxFont(double scale) const; diff --git a/src/render/text/element.cpp b/src/render/text/element.cpp index 8cde8d88..fcc09fd9 100644 --- a/src/render/text/element.cpp +++ b/src/render/text/element.cpp @@ -34,7 +34,7 @@ struct Margins { // Helper class for TextElements::fromString, to allow persistent formating state accross recusive calls struct TextElementsFromString { // What formatting is enabled? - int bold = 0, italic = 0, symbol = 0; + int bold = 0, italic = 0, underline = 0, symbol = 0; int soft = 0, kwpph = 0, param = 0, line = 0, soft_line = 0; int code = 0, code_kw = 0, code_string = 0, param_ref = 0; int param_id = 0, li = 0; @@ -78,7 +78,9 @@ private: if (is_tag(text, tag_start, _( " 0 ? FONT_SOFT : FONT_NORMAL) | (code > 0 ? FONT_CODE : FONT_NORMAL) | (code_kw > 0 ? FONT_CODE_KW : FONT_NORMAL) | - (code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL), + (code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL), + underline > 0, fonts.empty() ? nullptr : &fonts.back(), param > 0 || param_ref > 0 ? ¶m_colors[(param_id++) % param_colors_count] diff --git a/src/util/tagged_string.cpp b/src/util/tagged_string.cpp index 0da2669f..9ad82a81 100644 --- a/src/util/tagged_string.cpp +++ b/src/util/tagged_string.cpp @@ -645,7 +645,7 @@ String simplify_tagged(const String& str) { // (where is the negation of tag) bool add_or_cancel_tag(const String& tag, String& stack, bool all = false) { if (all || starts_with(tag, _("/")) || - starts_with(tag, _("b")) || starts_with(tag, _("i")) || starts_with(tag, _("sym"))) { + starts_with(tag, _("b")) || starts_with(tag, _("i")) || starts_with(tag, _("sym")) || starts_with(tag, _("u"))) { // cancel out all close tags, but not all open tags, // so is always removed // but is not @@ -692,8 +692,8 @@ String simplify_tagged_overlap(const String& str) { Char c = str.GetChar(i); if (c == _('<')) { String tag = tag_at(str, i); - if (starts_with(tag, _("b")) || starts_with(tag, _("i")) || starts_with(tag, _("sym")) || - starts_with(tag, _("/b")) || starts_with(tag, _("/i")) || starts_with(tag, _("/sym"))) { + if (starts_with(tag, _("b")) || starts_with(tag, _("i")) || starts_with(tag, _("sym")) || starts_with(tag, _("u")) || + starts_with(tag, _("/b")) || starts_with(tag, _("/i")) || starts_with(tag, _("/sym")) || starts_with(tag, _("/u"))) { // optimize this tag if (open_tags.find(_("<") + tag + _(">")) == String::npos) { // we are not already inside this tag