[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
This commit is contained in:
wandererfan
2023-04-24 12:26:43 -04:00
committed by WandererFan
parent f77d67ad28
commit 73b986d6a5

View File

@@ -39,6 +39,7 @@
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/MainWindow.h>
#include <Gui/Widgets.h>
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
@@ -111,7 +112,21 @@ void QGIViewAnnotation::drawAnnotation()
return;
}
const std::vector<std::string>& annoText = viewAnno->Text.getValues();
const std::vector<std::string>& annoRawText = viewAnno->Text.getValues();
std::vector<std::string> 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