diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 874306f18b..825c35d562 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -1778,7 +1778,8 @@ void GLGizmoEmboss::draw_style_list() { std::string &trunc_name = m_style_manager.get_truncated_name(); if (trunc_name.empty()) { // generate trunc name - const std::string ¤t_name = actual_style.name; + std::string current_name = actual_style.name; + ImGuiWrapper::escape_double_hash(current_name); trunc_name = ImGuiWrapper::trunc(current_name, max_style_name_width); } diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 7846691d7c..79d8099473 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1365,6 +1365,16 @@ std::string ImGuiWrapper::trunc(const std::string &text, return std::string(result_text) + tail; } +void ImGuiWrapper::escape_double_hash(std::string &text) +{ + // add space between hashes + const std::string search = "##"; + const std::string replace = "# #"; + size_t pos = 0; + while ((pos = text.find(search, pos)) != std::string::npos) + text.replace(pos, search.length(), replace); +} + ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size, const Slic3r::Polygon &interest, const ImVec2 &canvas_size) diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index 2b770c2f94..dd5ceb991b 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -167,6 +167,13 @@ public: float width, const char *tail = " .."); + /// + /// Escape ## in data by add space between hashes + /// Needed when user written text is visualized by ImGui. + /// + /// In/Out text to be escaped + static void escape_double_hash(std::string &text); + /// /// Suggest loacation of dialog window, /// dependent on actual visible thing on platter diff --git a/src/slic3r/Utils/EmbossStyleManager.cpp b/src/slic3r/Utils/EmbossStyleManager.cpp index 0484d94b2e..841079d72b 100644 --- a/src/slic3r/Utils/EmbossStyleManager.cpp +++ b/src/slic3r/Utils/EmbossStyleManager.cpp @@ -278,8 +278,11 @@ void EmbossStyleManager::make_unique_name(std::string &name) void EmbossStyleManager::init_trunc_names(float max_width) { for (auto &s : m_style_items) - if (s.truncated_name.empty()) - s.truncated_name = ImGuiWrapper::trunc(s.style.name, max_width); + if (s.truncated_name.empty()) { + std::string name = s.style.name; + ImGuiWrapper::escape_double_hash(name); + s.truncated_name = ImGuiWrapper::trunc(name, max_width); + } } #include "slic3r/GUI/Jobs/CreateFontStyleImagesJob.hpp"