|
Krita Source Code Documentation
|
The KoCssTextUtils class. More...
#include <KoCssTextUtils.h>
Static Public Member Functions | |
| static bool | characterCanHang (QChar c, KoSvgText::HangingPunctuations hangType) |
| characterCanHang The function returns whether the character qualifies for 'hanging-punctuation', using the given hang-type. | |
| static bool | collapseLastSpace (QChar c, KoSvgText::TextSpaceCollapse collapseMethod) |
| collapseLastSpace Some versions of CSS-Text 'white-space' or 'text-space-collapse' will collapse the last spaces while others don't. This function returns whether that's the case. | |
| 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 transform white space characters while others don't. This function returns whether that's the case. | |
| 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 selection algorithm. Note that for slant, this needs to be inverted. | |
| static QString | getBidiClosing (KoSvgText::UnicodeBidi bidi) |
| getBidiClosing Returns the bidi closing string associated with the given Css unicode-bidi value. | |
| static QString | getBidiOpening (bool ltr, KoSvgText::UnicodeBidi bidi) |
| getBidiOpening Get the bidi opening string associated with the given Css unicode-bidi value and direction https://www.w3.org/TR/css-writing-modes-3/#unicode-bidi | |
| 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 space depending on the situation. | |
| static bool | IsCssWordSeparator (QString grapheme) |
| IsCssWordSeparator CSS has a number of characters it considers word-separators, which are used in justification and for word-spacing. | |
| static QVector< QPair< bool, bool > > | justificationOpportunities (QString text, QString langCode) |
| justificationOpportunities mark justification opportunities in the text. Opportunities are between characters, so this returns a pair of before and after. As of currently, this only implements the bare minimum for CSS-Text-3 auto justification. | |
| 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 so that... | |
| static QStringList | textToUnicodeGraphemeClusters (const QString &text, const QString &langCode) |
| textToUnicodeGraphemes In letters like Å, the amount of unicode codpoints can be 1, but it can also be 2, one for 'A', and one for 'Combining Mark Ring Above". In some letters used by Vietnamese, such as ỗ there can be even 3. Such codepoint sequences are considered 'grapheme-clusters'. For editing text, matching fonts or capitalizing the first letter, it's wisest to do so on the grapheme clusters instead of the individual codepoints. | |
| 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 for each letter following a whitespace character or CSS Wordseparator. It has a small codepath for transforming the Dutch IJ correctly, as this is more readable. Note: When building Qt without ICU, this uses platform dependant functions. | |
| static QString | transformTextFullSizeKana (const QString &text) |
| transformTextFullSizeKana This function will take 'small' Kana (Japanese phonetic script) and transform it to their 'full-size' equivalents, following the list in the CSS-Text-3 spec. | |
| static QString | transformTextFullWidth (const QString &text) |
| transformTextFullWidth This function will transform 'narrow' or 'halfwidth' characters to their normal counterparts, and will transform ascii characters to their 'fullwidth'/'ideographic' counterparts. | |
| 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. Note: When building Qt without ICU, this uses platform dependant functions. | |
| 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. Note: When building Qt without ICU, this uses platform dependant functions. | |
The KoCssTextUtils class.
This class keeps a number of utility functions related to CSS Text, in particular CSS-Text-3 and CSS-Text-4.
Definition at line 21 of file KoCssTextUtils.h.
|
static |
characterCanHang The function returns whether the character qualifies for 'hanging-punctuation', using the given hang-type.
| c | the character to check. |
| hangType | how to hang. |
Definition at line 329 of file KoCssTextUtils.cpp.
References KoSvgText::HangEnd, KoSvgText::HangFirst, and KoSvgText::HangLast.
|
static |
collapseLastSpace Some versions of CSS-Text 'white-space' or 'text-space-collapse' will collapse the last spaces while others don't. This function returns whether that's the case.
| c | the character to check. |
| collapseMethod | the text-space collapse type. |
Definition at line 272 of file KoCssTextUtils.cpp.
References KoSvgText::BreakSpaces, KoSvgText::Collapse, KoSvgText::Discard, KoSvgText::Preserve, KoSvgText::PreserveBreaks, and KoSvgText::PreserveSpaces.
|
static |
collapseSpaces Some versions of CSS-Text 'white-space' or 'text-space-collapse' will collapse or transform white space characters while others don't. This function returns whether that's the case.
| text | the text to check against, this text will be transformed if the collapse method requires that. |
| collapseMethod | the white-space/text-space-collapse method, with the key indicating the position in the string at which it starts. |
Definition at line 199 of file KoCssTextUtils.cpp.
References KoSvgText::BreakSpaces, KoSvgText::Collapse, KoSvgText::Discard, KoSvgText::Preserve, KoSvgText::PreserveBreaks, and KoSvgText::PreserveSpaces.
|
static |
cssSelectFontStyleValue Select the closest font style value from the list, following the CSS Fonts selection algorithm. Note that for slant, this needs to be inverted.
| values | – values list to search in. |
| targetValue | – the target value to search for. |
| defaultValue | – the (lower-end) default value for the given axis. |
| defaultValueUpper | – the upper-end of the default value, for example, for weight this is 100 larger than default, for the others it is exactly the same. |
| shouldNotReturnDefault | – used for the slants, as they need to fall back on one another. |
Definition at line 592 of file KoCssTextUtils.cpp.
References qFuzzyCompare().
|
static |
getBidiClosing Returns the bidi closing string associated with the given Css unicode-bidi value.
| bidi | – the unicode-bidi value |
Definition at line 488 of file KoCssTextUtils.cpp.
References BIDI_CONTROL_PDF, BIDI_CONTROL_PDI, and UNICODE_BIDI_ISOLATE_OVERRIDE_END.
|
static |
getBidiOpening Get the bidi opening string associated with the given Css unicode-bidi value and direction https://www.w3.org/TR/css-writing-modes-3/#unicode-bidi
| ltr | – whether the direction is left-to-right |
| bidi | – the unicodee-bidi value. |
Definition at line 453 of file KoCssTextUtils.cpp.
References BIDI_CONTROL_FSI, BIDI_CONTROL_LRE, BIDI_CONTROL_LRI, BIDI_CONTROL_LRO, BIDI_CONTROL_RLE, BIDI_CONTROL_RLI, BIDI_CONTROL_RLO, UNICODE_BIDI_ISOLATE_OVERRIDE_LR_START, and UNICODE_BIDI_ISOLATE_OVERRIDE_RL_START.
|
static |
hangLastSpace Some versions of CSS-Text 'white-space' or 'text-space-collapse' will hang the final space depending on the situation.
| c | the character in question. |
| collapseMethod | the collapse method |
| wrapMethod | the wrap method. |
| force | whether said hang is a forced hang or not. |
| nextCharIsHardBreak | whether the next char is a line break. |
Definition at line 298 of file KoCssTextUtils.cpp.
References KoSvgText::Collapse, KoSvgText::NoWrap, KoSvgText::Preserve, and KoSvgText::PreserveBreaks.
|
static |
IsCssWordSeparator CSS has a number of characters it considers word-separators, which are used in justification and for word-spacing.
| grapheme | a grapheme to check. Using graphemes here, because some of the word-separators are not in the unicode basic plane. |
Definition at line 374 of file KoCssTextUtils.cpp.
|
static |
justificationOpportunities mark justification opportunities in the text. Opportunities are between characters, so this returns a pair of before and after. As of currently, this only implements the bare minimum for CSS-Text-3 auto justification.
| text | the text to check against. |
| langCode | language, used for the grapheme breaking. |
Definition at line 424 of file KoCssTextUtils.cpp.
References blockScript, clusterScript, IsCssWordSeparator(), and textToUnicodeGraphemeClusters().
|
static |
removeText Special removal of text that takes a text, start and length and will modify these values so that...
| text | text to remove text from. |
| start | the start index, will be modified. |
| length | the length. |
Definition at line 532 of file KoCssTextUtils.cpp.
References isVariationSelector(), length(), regionalIndicator(), v, and ZERO_WIDTH_JOINER.
|
static |
textToUnicodeGraphemes In letters like Å, the amount of unicode codpoints can be 1, but it can also be 2, one for 'A', and one for 'Combining Mark Ring Above". In some letters used by Vietnamese, such as ỗ there can be even 3. Such codepoint sequences are considered 'grapheme-clusters'. For editing text, matching fonts or capitalizing the first letter, it's wisest to do so on the grapheme clusters instead of the individual codepoints.
| text | the text to break. |
| langCode | the language code of the text, BCP style. |
Definition at line 384 of file KoCssTextUtils.cpp.
|
static |
transformTextToUpperCase This function splits the text into graphemes, and then uses QLocale::toUpper for each letter following a whitespace character or CSS Wordseparator. It has a small codepath for transforming the Dutch IJ correctly, as this is more readable. Note: When building Qt without ICU, this uses platform dependant functions.
| text | the text to transform. |
| langCode | the language code in BCP format, it gets transformed to qLocale's format. |
While this is the only case I know of, make no mistake, "IJsbeer" (Polar bear) is much more readable than "Ijsbeer".
Definition at line 56 of file KoCssTextUtils.cpp.
References IsCssWordSeparator(), positionDifference(), and textToUnicodeGraphemeClusters().
|
static |
transformTextFullSizeKana This function will take 'small' Kana (Japanese phonetic script) and transform it to their 'full-size' equivalents, following the list in the CSS-Text-3 spec.
| text | the text to transform. |
Definition at line 189 of file KoCssTextUtils.cpp.
References findSmallKanaToBigKana().
|
static |
transformTextFullWidth This function will transform 'narrow' or 'halfwidth' characters to their normal counterparts, and will transform ascii characters to their 'fullwidth'/'ideographic' counterparts.
| text | the text to transform. |
Definition at line 103 of file KoCssTextUtils.cpp.
References findProportionalToFullWidth().
|
static |
transformTextToUpperCase convenience function that creates a QLocale and uses it's 'toLower' function. Note: When building Qt without ICU, this uses platform dependant functions.
| text | the text to transform. |
| langCode | the language code in BCP format, it gets transformed to qLocale's format. |
Definition at line 47 of file KoCssTextUtils.cpp.
References positionDifference(), and textToUnicodeGraphemeClusters().
|
static |
transformTextToUpperCase convenience function that creates a QLocale and uses it's 'toUpper' function. Note: When building Qt without ICU, this uses platform dependant functions.
| text | the text to transform. |
| langCode | the language code in BCP format, it gets transformed to qLocale's format. |
Definition at line 38 of file KoCssTextUtils.cpp.
References positionDifference(), and textToUnicodeGraphemeClusters().