diff --git a/src/gui/dialogs/title_screen.cpp b/src/gui/dialogs/title_screen.cpp index 3e78ee707a5..8fd2a0749a8 100644 --- a/src/gui/dialogs/title_screen.cpp +++ b/src/gui/dialogs/title_screen.cpp @@ -19,6 +19,7 @@ #include "addon/manager_ui.hpp" #include "filesystem.hpp" +#include "font/font_config.hpp" #include "formula/string_utils.hpp" #include "game_config.hpp" #include "game_config_manager.hpp" @@ -53,6 +54,7 @@ #include "gui/widgets/window.hpp" #include "help/help.hpp" #include "sdl/surface.hpp" +#include "serialization/unicode.hpp" #include "video.hpp" #include @@ -204,26 +206,23 @@ void title_screen::init_callbacks() widget["use_markup"] = "true"; - // // Use pango markup to insert drop cap - // - if (tip.text().str().substr(0,1) != "<") { - // Example: Lawful units -> Lawful units - widget["label"] = "" + tip.text().str().substr(0,1) + "" + tip.text().str().substr(1); - } else { - // Tip starts with a tag, so we need to insert the after it - // then insert the tag after the first character of the text - // after markup. Example: - // Lawful units -> Lawful units - std::size_t id = tip.text().str().find_first_of(">") + 1; - std::stringstream tip_text; - tip_text << tip.text().str().substr(0,id) // existing start tag - << "" // span start tag - << tip.text().str().substr(id,1) // first character - << "" // span end tag - << tip.text().str().substr(id+1); // rest of the text - widget["label"] = tip_text.str(); + // Example: Lawful units -> Lawful units + // If tip starts with a tag, we need to insert the after it + // then insert the tag after the first character of the text + // after markup. Assumes that the tags themselves don't + // contain non-ASCII characters. + // Example: Lawful units -> Lawful units + const std::string& script_font = font::get_font_families(font::FONT_SCRIPT); + std::string tip_text = tip.text().str(); + std::size_t pos = 0; + while (pos < tip_text.size() && tip_text.at(pos) == '<') { + pos = tip_text.find_first_of(">", pos) + 1; } + utf8::insert(tip_text, pos+1, ""); + utf8::insert(tip_text, pos, ""); + + widget["label"] = tip_text; page.emplace("tip", widget);