Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Qt6: Port flake/text
Halla Rempt7823fca50d3c
diff --git a/libs/flake/text/KoCssTextUtils.cpp b/libs/flake/text/KoCssTextUtils.cppindex fc766b7af7..c9833df48c 100644--- a/libs/flake/text/KoCssTextUtils.cpp+++ b/libs/flake/text/KoCssTextUtils.cpp@@ -119,66 +119,66 @@ static QChar findSmallKanaToBigKana(const QChar &value, const QChar &defaultValustatic QMap<QChar, QChar> map = {// NOTE: these are not fully sequential!// clang-format off- {{0x3041}, {0x3042}},- {{0x3043}, {0x3044}},- {{0x3045}, {0x3046}},- {{0x3047}, {0x3048}},- {{0x3049}, {0x304A}},- {{0x3095}, {0x304B}},- {{0x3096}, {0x3051}},- {{0x1B132}, {0x3053}},- {{0x3063}, {0x3064}},- {{0x3083}, {0x3084}},- {{0x3085}, {0x3086}},- {{0x3087}, {0x3088}},- {{0x308E}, {0x308F}},- {{0x1B150}, {0x3090}},- {{0x1B151}, {0x3091}},- {{0x1B152}, {0x3092}},-- {{0x30A1}, {0x30A2}},- {{0x30A3}, {0x30A4}},- {{0x30A5}, {0x30A6}},- {{0x30A7}, {0x30A8}},- {{0x30A9}, {0x30AA}},- {{0x30F5}, {0x30AB}},- {{0x31F0}, {0x30AF}},- {{0x30F6}, {0x30B1}},- {{0x1B155}, {0x30B3}},- {{0x31F1}, {0x30B7}},- {{0x31F2}, {0x30B9}},- {{0x30C3}, {0x30C4}},- {{0x31F3}, {0x30C8}},- {{0x31F4}, {0x30CC}},- {{0x31F5}, {0x30CF}},- {{0x31F6}, {0x30D2}},- {{0x31F7}, {0x30D5}},- {{0x31F8}, {0x30D8}},- {{0x31F9}, {0x30DB}},- {{0x31FA}, {0x30E0}},- {{0x30E3}, {0x30E4}},- {{0x30E5}, {0x30E6}},- {{0x30E7}, {0x30E8}},- {{0x31FB}, {0x30E9}},- {{0x31FC}, {0x30EA}},- {{0x31FD}, {0x30EB}},- {{0x31FE}, {0x30EC}},- {{0x31FF}, {0x30ED}},- {{0x30EE}, {0x30EF}},- {{0x1B164}, {0x30F0}},- {{0x1B165}, {0x30F1}},- {{0x1B166}, {0x30F2}},- {{0x1B167}, {0x30F3}},-- {{0xFF67}, {0xFF71}},- {{0xFF68}, {0xFF72}},- {{0xFF69}, {0xFF73}},- {{0xFF6A}, {0xFF74}},- {{0xFF6B}, {0xFF75}},- {{0xFF6F}, {0xFF82}},- {{0xFF6C}, {0xFF94}},- {{0xFF6D}, {0xFF95}},- {{0xFF6E}, {0xFF96}},+ {QChar{0x3041}, QChar{0x3042}},+ {QChar{0x3043}, QChar{0x3044}},+ {QChar{0x3045}, QChar{0x3046}},+ {QChar{0x3047}, QChar{0x3048}},+ {QChar{0x3049}, QChar{0x304A}},+ {QChar{0x3095}, QChar{0x304B}},+ {QChar{0x3096}, QChar{0x3051}},+ {QChar{0x1B132}, QChar{0x3053}},+ {QChar{0x3063}, QChar{0x3064}},+ {QChar{0x3083}, QChar{0x3084}},+ {QChar{0x3085}, QChar{0x3086}},+ {QChar{0x3087}, QChar{0x3088}},+ {QChar{0x308E}, QChar{0x308F}},+ {QChar{0x1B150}, QChar{0x3090}},+ {QChar{0x1B151}, QChar{0x3091}},+ {QChar{0x1B152}, QChar{0x3092}},++ {QChar{0x30A1}, QChar{0x30A2}},+ {QChar{0x30A3}, QChar{0x30A4}},+ {QChar{0x30A5}, QChar{0x30A6}},+ {QChar{0x30A7}, QChar{0x30A8}},+ {QChar{0x30A9}, QChar{0x30AA}},+ {QChar{0x30F5}, QChar{0x30AB}},+ {QChar{0x31F0}, QChar{0x30AF}},+ {QChar{0x30F6}, QChar{0x30B1}},+ {QChar{0x1B155}, QChar{0x30B3}},+ {QChar{0x31F1}, QChar{0x30B7}},+ {QChar{0x31F2}, QChar{0x30B9}},+ {QChar{0x30C3}, QChar{0x30C4}},+ {QChar{0x31F3}, QChar{0x30C8}},+ {QChar{0x31F4}, QChar{0x30CC}},+ {QChar{0x31F5}, QChar{0x30CF}},+ {QChar{0x31F6}, QChar{0x30D2}},+ {QChar{0x31F7}, QChar{0x30D5}},+ {QChar{0x31F8}, QChar{0x30D8}},+ {QChar{0x31F9}, QChar{0x30DB}},+ {QChar{0x31FA}, QChar{0x30E0}},+ {QChar{0x30E3}, QChar{0x30E4}},+ {QChar{0x30E5}, QChar{0x30E6}},+ {QChar{0x30E7}, QChar{0x30E8}},+ {QChar{0x31FB}, QChar{0x30E9}},+ {QChar{0x31FC}, QChar{0x30EA}},+ {QChar{0x31FD}, QChar{0x30EB}},+ {QChar{0x31FE}, QChar{0x30EC}},+ {QChar{0x31FF}, QChar{0x30ED}},+ {QChar{0x30EE}, QChar{0x30EF}},+ {QChar{0x1B164}, QChar{0x30F0}},+ {QChar{0x1B165}, QChar{0x30F1}},+ {QChar{0x1B166}, QChar{0x30F2}},+ {QChar{0x1B167}, QChar{0x30F3}},++ {QChar{0xFF67}, QChar{0xFF71}},+ {QChar{0xFF68}, QChar{0xFF72}},+ {QChar{0xFF69}, QChar{0xFF73}},+ {QChar{0xFF6A}, QChar{0xFF74}},+ {QChar{0xFF6B}, QChar{0xFF75}},+ {QChar{0xFF6F}, QChar{0xFF82}},+ {QChar{0xFF6C}, QChar{0xFF94}},+ {QChar{0xFF6D}, QChar{0xFF95}},+ {QChar{0xFF6E}, QChar{0xFF96}},// clang-format on};@@ -433,7 +433,7 @@ const QString BIDI_CONTROL_PDI = "\u2069";const QString UNICODE_BIDI_ISOLATE_OVERRIDE_LR_START = "\u2068\u202d";const QString UNICODE_BIDI_ISOLATE_OVERRIDE_RL_START = "\u2068\u202e";const QString UNICODE_BIDI_ISOLATE_OVERRIDE_END = "\u202c\u2069";-const QChar ZERO_WIDTH_JOINER = 0x200d;+const QChar ZERO_WIDTH_JOINER = QChar{0x200d};QString KoCssTextUtils::getBidiOpening(bool ltr, KoSvgText::UnicodeBidi bidi){diff --git a/libs/flake/text/KoSvgTextContentElement.cpp b/libs/flake/text/KoSvgTextContentElement.cppindex 7be44042d7..d114789817 100644--- a/libs/flake/text/KoSvgTextContentElement.cpp+++ b/libs/flake/text/KoSvgTextContentElement.cpp@@ -170,9 +170,10 @@ bool KoSvgTextContentElement::loadSvg(const QDomElement &e, SvgLoadingContext &cKoSvgTextProperties::PaintOrder,KoSvgTextProperties::Opacity,KoSvgTextProperties::Visiblity};- for (auto it = generic.begin(); it != generic.end(); it++) {- if (properties.hasProperty(*it.i)) {- props.setProperty(*it.i, properties.property(*it.i));+ for (int i = 0; i < generic.size(); i++) {+ auto id = generic[i];+ if (properties.hasProperty(id)) {+ props.setProperty(id, properties.property(id));}}properties = props;diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex 53d36cc2f2..386b9b3e38 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -1368,7 +1368,7 @@ void KoSvgTextShape::debugParsing()qDebug() << QString(spaces + "| Opacity: ") << it->properties.property(KoSvgTextProperties::Opacity);qDebug() << QString(spaces + "| PaintOrder: ") << it->properties.hasProperty(KoSvgTextProperties::PaintOrder);qDebug() << QString(spaces + "| Visibility set: ") << it->properties.hasProperty(KoSvgTextProperties::Visiblity);- qDebug() << QString(spaces + "| TextPath set: ") << (it->textPath);+ qDebug() << QString(spaces + "| TextPath set: ") << (!it->textPath.isNull());qDebug() << QString(spaces + "| Transforms set: ") << it->localTransformations;spaces.append(" ");}diff --git a/libs/flake/text/KoSvgTextShapeMarkupConverter.cpp b/libs/flake/text/KoSvgTextShapeMarkupConverter.cppindex a5b641c575..9d68bc7b70 100644--- a/libs/flake/text/KoSvgTextShapeMarkupConverter.cpp+++ b/libs/flake/text/KoSvgTextShapeMarkupConverter.cpp@@ -28,6 +28,12 @@#include <QStack>+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))+#include <QStringRef>+#else+#include <QStringView>+#endif+#include <KoSvgTextShape.h>#include <KoXmlWriter.h>#include <KoDocumentResourceManager.h>@@ -198,8 +204,11 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QStQXmlStreamWriter svgWriter(&svgBuffer);svgWriter.setAutoFormatting(false);-+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))QStringRef elementName;+#else+ QStringView elementName;+#endifbool newLine = false;int lineCount = 0;@@ -221,7 +230,11 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QStif (htmlReader.name() == "br") {debugFlake << "\tdoing br";svgWriter.writeEndElement();+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))elementName = QStringRef(&p);+#else+ elementName = QStringView(p);+#endifem = bodyEm;appendStyle = previousStyleString;}@@ -1621,7 +1634,7 @@ QVector<QTextFormat> KoSvgTextShapeMarkupConverter::stylesFromString(QStringList// Note: Percentage line-height behaves differently than// unitless number in case of nested descendant elements,// but here we pretend they are the same.- lineHeightPercent = value.leftRef(value.length() - 1).toDouble(&ok);+ lineHeightPercent = value.left(value.length() - 1).toDouble(&ok);if (!ok) {lineHeightPercent = -1.0;}diff --git a/libs/flake/text/KoSvgTextShape_p_glyphs.cpp b/libs/flake/text/KoSvgTextShape_p_glyphs.cppindex 6916c09490..2ca5e78971 100644--- a/libs/flake/text/KoSvgTextShape_p_glyphs.cpp+++ b/libs/flake/text/KoSvgTextShape_p_glyphs.cpp@@ -42,10 +42,10 @@ static QString glyphFormatToStr(const FT_Glyph_Format _v){const unsigned int v = _v;QString s;- s += (v >> 24) & 0xFF;- s += (v >> 16) & 0xFF;- s += (v >> 8) & 0xFF;- s += (v >> 0) & 0xFF;+ s += QChar((v >> 24) & 0xFF);+ s += QChar((v >> 16) & 0xFF);+ s += QChar((v >> 8) & 0xFF);+ s += QChar((v >> 0) & 0xFF);return s;}