From 305387989e9c9f559d896357b83ebb1fe9186765 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 3 Aug 2025 18:22:01 -0500 Subject: [PATCH] apply substitutions when calculating line wrapping --- src/gfx/render_text.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gfx/render_text.cpp b/src/gfx/render_text.cpp index a72c2558..611325b3 100644 --- a/src/gfx/render_text.cpp +++ b/src/gfx/render_text.cpp @@ -108,10 +108,18 @@ static void push_snippets(size_t start, size_t end, text_params_t& options, size } while(start < upper_bound); } +std::map substitutions = { + {"–", "--"} +}; + break_info_t calculate_line_wrapping(rectangle dest_rect, std::string str, TextStyle style) { break_info_t break_info; if(str.empty()) return break_info; // Nothing to do! + for(auto it : substitutions){ + boost::replace_all(str, it.first, it.second); + } + sf::Text str_to_draw; style.applyTo(str_to_draw); short str_len = str.length(); @@ -241,10 +249,6 @@ std::string truncate_with_ellipsis(std::string str, const TextStyle& style, int return str; } -std::map substitutions = { - {"–", "--"} -}; - static void win_draw_string(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,text_params_t& options) { if(str.empty()) return; // Nothing to do! short line_height = options.style.lineHeight;