Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
elide: cut whole UTF-8 characters (the lead byte was left behind: a clipped Chinese status line ended in "?")
islandmed0bafe83d1126
diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex 863e0985..454c937a 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -67,9 +67,9 @@ std::string elide(const std::string& text, float width) {if (ImGui::CalcTextSize(text.c_str()).x <= width) return text;std::string s = text;while (!s.empty() && ImGui::CalcTextSize((s + "...").c_str()).x > width) {- s.pop_back();- while (!s.empty() && (static_cast<unsigned char>(s.back()) & 0xC0) == 0x80)- s.pop_back(); // whole UTF-8 chars+ // One whole UTF-8 character: its continuation bytes, then its lead byte.+ while (!s.empty() && (static_cast<unsigned char>(s.back()) & 0xC0) == 0x80) s.pop_back();+ if (!s.empty()) s.pop_back();}return s + "...";}diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 11fa73cb..75a66994 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -234,7 +234,11 @@ void centredText(ImDrawList* dl, ImFont* font, ImVec2 a, ImVec2 b, ImU32 col, costd::string elide(ImFont* font, const std::string& text, float width) {if (font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, text.c_str()).x <= width) return text;std::string s = text;- while (!s.empty() && font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, (s + "...").c_str()).x > width) s.pop_back();+ while (!s.empty() && font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, (s + "...").c_str()).x > width) {+ // One whole UTF-8 character: its continuation bytes, then its lead byte (half a Chinese character drew as "?").+ while (!s.empty() && (static_cast<unsigned char>(s.back()) & 0xC0) == 0x80) s.pop_back();+ if (!s.empty()) s.pop_back();+ }return s + "...";}