120 static QMap<QChar, QChar> map = {
123 {QChar{0x3041}, QChar{0x3042}},
124 {QChar{0x3043}, QChar{0x3044}},
125 {QChar{0x3045}, QChar{0x3046}},
126 {QChar{0x3047}, QChar{0x3048}},
127 {QChar{0x3049}, QChar{0x304A}},
128 {QChar{0x3095}, QChar{0x304B}},
129 {QChar{0x3096}, QChar{0x3051}},
130 {QChar{0x1B132}, QChar{0x3053}},
131 {QChar{0x3063}, QChar{0x3064}},
132 {QChar{0x3083}, QChar{0x3084}},
133 {QChar{0x3085}, QChar{0x3086}},
134 {QChar{0x3087}, QChar{0x3088}},
135 {QChar{0x308E}, QChar{0x308F}},
136 {QChar{0x1B150}, QChar{0x3090}},
137 {QChar{0x1B151}, QChar{0x3091}},
138 {QChar{0x1B152}, QChar{0x3092}},
140 {QChar{0x30A1}, QChar{0x30A2}},
141 {QChar{0x30A3}, QChar{0x30A4}},
142 {QChar{0x30A5}, QChar{0x30A6}},
143 {QChar{0x30A7}, QChar{0x30A8}},
144 {QChar{0x30A9}, QChar{0x30AA}},
145 {QChar{0x30F5}, QChar{0x30AB}},
146 {QChar{0x31F0}, QChar{0x30AF}},
147 {QChar{0x30F6}, QChar{0x30B1}},
148 {QChar{0x1B155}, QChar{0x30B3}},
149 {QChar{0x31F1}, QChar{0x30B7}},
150 {QChar{0x31F2}, QChar{0x30B9}},
151 {QChar{0x30C3}, QChar{0x30C4}},
152 {QChar{0x31F3}, QChar{0x30C8}},
153 {QChar{0x31F4}, QChar{0x30CC}},
154 {QChar{0x31F5}, QChar{0x30CF}},
155 {QChar{0x31F6}, QChar{0x30D2}},
156 {QChar{0x31F7}, QChar{0x30D5}},
157 {QChar{0x31F8}, QChar{0x30D8}},
158 {QChar{0x31F9}, QChar{0x30DB}},
159 {QChar{0x31FA}, QChar{0x30E0}},
160 {QChar{0x30E3}, QChar{0x30E4}},
161 {QChar{0x30E5}, QChar{0x30E6}},
162 {QChar{0x30E7}, QChar{0x30E8}},
163 {QChar{0x31FB}, QChar{0x30E9}},
164 {QChar{0x31FC}, QChar{0x30EA}},
165 {QChar{0x31FD}, QChar{0x30EB}},
166 {QChar{0x31FE}, QChar{0x30EC}},
167 {QChar{0x31FF}, QChar{0x30ED}},
168 {QChar{0x30EE}, QChar{0x30EF}},
169 {QChar{0x1B164}, QChar{0x30F0}},
170 {QChar{0x1B165}, QChar{0x30F1}},
171 {QChar{0x1B166}, QChar{0x30F2}},
172 {QChar{0x1B167}, QChar{0x30F3}},
174 {QChar{0xFF67}, QChar{0xFF71}},
175 {QChar{0xFF68}, QChar{0xFF72}},
176 {QChar{0xFF69}, QChar{0xFF73}},
177 {QChar{0xFF6A}, QChar{0xFF74}},
178 {QChar{0xFF6B}, QChar{0xFF75}},
179 {QChar{0xFF6F}, QChar{0xFF82}},
180 {QChar{0xFF6C}, QChar{0xFF94}},
181 {QChar{0xFF6D}, QChar{0xFF95}},
182 {QChar{0xFF6E}, QChar{0xFF96}},
186 return map.value(
value, defaultValue);
202 QString modifiedText = *text;
204 collapseList.fill(
false);
205 int spaceSequenceCount = 0;
207 for (
int i = 0; i < modifiedText.size(); i++) {
208 bool firstOrLast = (i == 0 || i == modifiedText.size() - 1);
209 bool collapse =
false;
210 if (collapseMethods.contains(i)) {
212 if (collapseMethods.value(i) != collapseMethod) spaceSequenceCount = 0;
213 collapseMethod = collapseMethods.value(i);
215 const QChar c = modifiedText.at(i);
216 if (c == QChar::LineFeed || c == QChar::Tabulation) {
219 modifiedText[i] = QChar::Space;
220 spaceSequenceCount += 1;
221 collapseList[i] = spaceSequenceCount > 1 || firstOrLast?
true:
false;
226 bool isSegmentBreak = c == QChar::LineFeed;
227 bool isTab = c == QChar::Tabulation;
228 spaceSequenceCount += 1;
229 if (spaceSequenceCount > 1 || firstOrLast) {
230 switch (collapseMethod) {
241 collapse = !isSegmentBreak;
243 modifiedText[i] = QChar::Space;
249 spaceSequenceCount = 0;
251 collapseList[i] = collapse;
254 for (
int i = modifiedText.size()-1; i>=0; i--) {
255 if (collapseMethods.contains(i)) {
256 int pos = collapseMethods.keys().indexOf(i);
257 collapseMethod = collapseMethods.value(collapseMethods.keys().value(pos-1, 0),
KoSvgText::Collapse);
260 if (modifiedText.at(i).isSpace()) {
262 collapseList[i] =
true;
268 *text = modifiedText;
static QVector< bool > collapseSpaces(QString *text, QMap< int, KoSvgText::TextSpaceCollapse > collapseMethods)
collapseSpaces Some versions of CSS-Text 'white-space' or 'text-space-collapse' will collapse or tran...
static QString transformTextFullSizeKana(const QString &text)
transformTextFullSizeKana This function will take 'small' Kana (Japanese phonetic script) and transfo...
static bool IsCssWordSeparator(QString grapheme)
IsCssWordSeparator CSS has a number of characters it considers word-separators, which are used in jus...
static QStringList textToUnicodeGraphemeClusters(const QString &text, const QString &langCode)
textToUnicodeGraphemes In letters like Å, the amount of unicode codpoints can be 1,...
static QString transformTextCapitalize(const QString &text, QString langCode, QVector< QPair< int, int > > &positions)
transformTextToUpperCase This function splits the text into graphemes, and then uses QLocale::toUpper...
static QString transformTextToUpperCase(const QString &text, const QString &langCode, QVector< QPair< int, int > > &positions)
transformTextToUpperCase convenience function that creates a QLocale and uses it's 'toUpper' function...
static QString transformTextToLowerCase(const QString &text, const QString &langCode, QVector< QPair< int, int > > &positions)
transformTextToUpperCase convenience function that creates a QLocale and uses it's 'toLower' function...
static bool characterCanHang(QChar c, KoSvgText::HangingPunctuations hangType)
characterCanHang The function returns whether the character qualifies for 'hanging-punctuation',...
static QString getBidiClosing(KoSvgText::UnicodeBidi bidi)
getBidiClosing Returns the bidi closing string associated with the given Css unicode-bidi value.
static void removeText(QString &text, int &start, int length)
removeText Special removal of text that takes a text, start and length and will modify these values s...
static qreal cssSelectFontStyleValue(const QVector< qreal > &values, const qreal targetValue, const qreal defaultValue, const qreal defaultValueUpper, const bool shouldNotReturnDefault)
cssSelectFontStyleValue Select the closest font style value from the list, following the CSS Fonts se...
static bool collapseLastSpace(QChar c, KoSvgText::TextSpaceCollapse collapseMethod)
collapseLastSpace Some versions of CSS-Text 'white-space' or 'text-space-collapse' will collapse the ...
static QString transformTextFullWidth(const QString &text)
transformTextFullWidth This function will transform 'narrow' or 'halfwidth' characters to their norma...
static bool hangLastSpace(const QChar c, KoSvgText::TextSpaceCollapse collapseMethod, KoSvgText::TextWrap wrapMethod, bool &force, bool nextCharIsHardBreak)
hangLastSpace Some versions of CSS-Text 'white-space' or 'text-space-collapse' will hang the final sp...
static QString getBidiOpening(bool ltr, KoSvgText::UnicodeBidi bidi)
getBidiOpening Get the bidi opening string associated with the given Css unicode-bidi value and direc...
static QVector< QPair< bool, bool > > justificationOpportunities(QString text, QString langCode)
justificationOpportunities mark justification opportunities in the text. Opportunities are between ch...