From 762b4ebf45d2ecf608bc88328d5881d4a8b9e2e3 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 24 Apr 2023 12:26:43 -0400 Subject: [PATCH] [TD]handle escaped unicode annotation text - v0.19 (and earlier?) stored annotation text as escaped unicode, but v0.20 stores the text as utf8. - checks for "\x" in text to determine is text is escaped or utf8 --- src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp index 0872a488d0..3126051607 100644 --- a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -111,7 +112,21 @@ void QGIViewAnnotation::drawAnnotation() return; } - const std::vector& annoText = viewAnno->Text.getValues(); + const std::vector& annoRawText = viewAnno->Text.getValues(); + std::vector annoText; + // v0.19- stored text as escapedUnicode + // v0.20+ stores text as utf8 + for (auto& line : annoRawText) { + if (line.find("\\x") == std::string::npos) { + // not escaped + annoText.push_back(line); + } else { + // is escaped + std::string newLine = Base::Tools::escapedUnicodeToUtf8(line); + annoText.push_back(newLine); + } + } + int scaledSize = exactFontSize(viewAnno->Font.getValue(), viewAnno->TextSize.getValue()); //build HTML/CSS formatting around Text lines