| 2892 | } |
| 2893 | |
| 2894 | int Label::getFirstWordLen(const std::u32string& utf32Text, int startIndex, int textLen) const |
| 2895 | { |
| 2896 | int len = 0; |
| 2897 | auto nextLetterX = 0; |
| 2898 | FontLetterDefinition letterDef; |
| 2899 | auto contentScaleFactor = AX_CONTENT_SCALE_FACTOR(); |
| 2900 | |
| 2901 | for (int index = startIndex; index < textLen; ++index) |
| 2902 | { |
| 2903 | char32_t character = utf32Text[index]; |
| 2904 | |
| 2905 | if (character == StringUtils::UnicodeCharacters::NewLine || |
| 2906 | (!StringUtils::isUnicodeNonBreaking(character) && |
| 2907 | (StringUtils::isUnicodeSpace(character) || StringUtils::isCJKUnicode(character)))) |
| 2908 | { |
| 2909 | break; |
| 2910 | } |
| 2911 | |
| 2912 | if (!getFontLetterDef(character, letterDef)) |
| 2913 | { |
| 2914 | break; |
| 2915 | } |
| 2916 | |
| 2917 | if (_maxLineWidth > 0.f) |
| 2918 | { |
| 2919 | auto letterX = (nextLetterX + letterDef.offsetX * _fontScale) / contentScaleFactor; |
| 2920 | |
| 2921 | if (letterX + letterDef.width * _fontScale > _maxLineWidth) |
| 2922 | break; |
| 2923 | } |
| 2924 | |
| 2925 | nextLetterX += static_cast<int>(letterDef.xAdvance * _fontScale + _additionalKerning); |
| 2926 | |
| 2927 | len++; |
| 2928 | } |
| 2929 | |
| 2930 | if (len == 0 && textLen) |
| 2931 | len = 1; |
| 2932 | |
| 2933 | return len; |
| 2934 | } |
| 2935 | |
| 2936 | bool Label::getFontLetterDef(char32_t character, FontLetterDefinition& letterDef) const |
| 2937 | { |
nothing calls this directly
no test coverage detected