| 124 | } |
| 125 | |
| 126 | void Font::ProcessText(const StringView& text, Array<FontLineCache, InlinedAllocation<8>>& outputLines, const TextLayoutOptions& layout) |
| 127 | { |
| 128 | int32 textLength = text.Length(); |
| 129 | if (textLength == 0) |
| 130 | return; |
| 131 | float cursorX = 0; |
| 132 | int32 kerning; |
| 133 | FontLineCache tmpLine; |
| 134 | FontCharacterEntry entry; |
| 135 | FontCharacterEntry previous; |
| 136 | float scale = layout.Scale / FontManager::FontScale; |
| 137 | float boundsWidth = layout.Bounds.GetWidth(); |
| 138 | float baseLinesDistance = static_cast<float>(_height) * layout.BaseLinesGapScale * scale; |
| 139 | tmpLine.Location = Float2::Zero; |
| 140 | tmpLine.Size = Float2::Zero; |
| 141 | tmpLine.FirstCharIndex = 0; |
| 142 | tmpLine.LastCharIndex = -1; |
| 143 | |
| 144 | int32 lastWrapCharIndex = INVALID_INDEX; |
| 145 | float lastWrapCharX = 0; |
| 146 | bool lastMoveLine = false; |
| 147 | const Char compChar = TEXT('_'); |
| 148 | |
| 149 | // Process each character to split text into single lines |
| 150 | for (int32 currentIndex = 0; currentIndex < textLength;) |
| 151 | { |
| 152 | bool moveLine = false; |
| 153 | float xAdvance = 0; |
| 154 | int32 nextCharIndex = currentIndex + 1; |
| 155 | |
| 156 | // Cache current character |
| 157 | const Char currentChar = text[currentIndex]; |
| 158 | const bool isWhitespace = StringUtils::IsWhitespace(currentChar); |
| 159 | |
| 160 | // Check if character can wrap words |
| 161 | const bool isWrapChar = (!StringUtils::IsAlnum(currentChar) && StringUtils::Compare(¤tChar, &compChar) == 0) || isWhitespace || StringUtils::IsUpper(currentChar); |
| 162 | if (isWrapChar && currentIndex != 0) |
| 163 | { |
| 164 | lastWrapCharIndex = currentIndex; |
| 165 | lastWrapCharX = cursorX; |
| 166 | } |
| 167 | |
| 168 | // Check if it's a newline character |
| 169 | if (currentChar == '\n') |
| 170 | { |
| 171 | // Break line |
| 172 | moveLine = true; |
| 173 | currentIndex++; |
| 174 | tmpLine.LastCharIndex++; |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | // Get character entry |
| 179 | GetCharacter(currentChar, entry); |
| 180 | |
| 181 | // Get kerning |
| 182 | if (!isWhitespace && previous.IsValid) |
| 183 | { |
no test coverage detected