| 185 | } |
| 186 | |
| 187 | bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) |
| 188 | { |
| 189 | const char* pText = sText; |
| 190 | textLines.clear(); |
| 191 | iMaxLineWidth = 0; |
| 192 | |
| 193 | FT_UInt unicode; |
| 194 | FT_UInt prevCharacter = 0; |
| 195 | FT_UInt glyphIndex = 0; |
| 196 | FT_UInt prevGlyphIndex = 0; |
| 197 | FT_Vector delta; |
| 198 | LineBreakLine currentLine; |
| 199 | |
| 200 | int currentPaintPosition = 0; |
| 201 | int firstBreakIndex = -1; |
| 202 | int lastBreakIndex = -1; |
| 203 | bool hasKerning = FT_HAS_KERNING(face); |
| 204 | while ((unicode = utf8((char**)&pText))) |
| 205 | { |
| 206 | if (unicode == '\n') |
| 207 | { |
| 208 | currentLine.calculateWidth(); |
| 209 | iMaxLineWidth = std::max(iMaxLineWidth, currentLine.lineWidth); |
| 210 | textLines.emplace_back(currentLine); |
| 211 | currentLine.reset(); |
| 212 | prevGlyphIndex = 0; |
| 213 | prevCharacter = 0; |
| 214 | firstBreakIndex = -1; |
| 215 | lastBreakIndex = -1; |
| 216 | currentPaintPosition = 0; |
| 217 | continue; |
| 218 | } |
| 219 | |
| 220 | if (isBreakPoint(unicode, prevCharacter)) |
| 221 | { |
| 222 | lastBreakIndex = currentLine.glyphs.size() - 1; |
| 223 | } |
| 224 | |
| 225 | glyphIndex = FT_Get_Char_Index(face, unicode); |
| 226 | if (FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT)) |
| 227 | { |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | LineBreakGlyph glyph; |
| 232 | glyph.glyphIndex = glyphIndex; |
| 233 | glyph.glyphWidth = face->glyph->metrics.width >> 6; |
| 234 | glyph.bearingX = face->glyph->metrics.horiBearingX >> 6; |
| 235 | glyph.horizAdvance = face->glyph->metrics.horiAdvance >> 6; |
| 236 | glyph.kerning = 0; |
| 237 | |
| 238 | if (prevGlyphIndex != 0 && hasKerning) |
| 239 | { |
| 240 | FT_Get_Kerning(face, prevGlyphIndex, glyphIndex, FT_KERNING_DEFAULT, &delta); |
| 241 | glyph.kerning = delta.x >> 6; |
| 242 | } |
| 243 | |
| 244 | if (iswspace(unicode)) |
nothing calls this directly
no test coverage detected