MCPcopy Create free account
hub / github.com/axmolengine/axmol / divideString

Method divideString

core/platform/linux/Device-linux.cpp:187–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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))

Callers

nothing calls this directly

Calls 15

FT_Get_Char_IndexFunction · 0.85
FT_Load_GlyphFunction · 0.85
FT_Get_KerningFunction · 0.85
calculateWidthMethod · 0.80
maxFunction · 0.50
clearMethod · 0.45
emplace_backMethod · 0.45
resetMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected