bool ParagraphLayout::_FinalizeLine(int lineStart, int lineEnd, int lineIndex, float y, float& lineHeight) { LineInfo line(lineStart, y, 0.0f, 0.0f, 0.0f); int spanIndex = -1; int spanStart = 0; int spanEnd = 0; for (int i = lineStart; i <= lineEnd; i++) { // Mark line index in glyph GlyphInfo glyph = fGlyphInfos.ItemAtFast(i); glyph.lineIndex = lineIndex; fGlyphInfos.Replace(i, glyph); // See if the next sub-span needs to be added to the LineInfo bool addSpan = false; while (i >= spanEnd) { spanIndex++; const TextSpan& span = fTextSpans.ItemAt(spanIndex); spanStart = spanEnd; spanEnd += span.CountChars(); addSpan = true; } if (addSpan) { const TextSpan& span = fTextSpans.ItemAt(spanIndex); TextSpan subSpan = span.SubSpan(i - spanStart, (lineEnd - spanStart + 1) - (i - spanStart)); line.layoutedSpans.Add(subSpan); _IncludeStyleInLine(line, span.Style()); } } if (fGlyphInfos.CountItems() == 0 && fTextSpans.CountItems() > 0) { // When the layout contains no glyphs, but there is at least one // TextSpan in the paragraph, use the font info from that span // to calculate the height of the first LineInfo. const TextSpan& span = fTextSpans.ItemAtFast(0); line.layoutedSpans.Add(span); _IncludeStyleInLine(line, span.Style()); } lineHeight = line.height; return fLineInfos.Add(line); }
bool ParagraphLayout::_FinalizeLine(int lineStart, int lineEnd, int lineIndex, float y, float& lineHeight) { LineInfo line(lineStart, y, 0.0f, 0.0f, 0.0f); int spanIndex = -1; int spanStart = 0; int spanEnd = 0; for (int i = lineStart; i <= lineEnd; i++) { // Mark line index in glyph GlyphInfo glyph = fGlyphInfos.ItemAtFast(i); glyph.lineIndex = lineIndex; fGlyphInfos.Replace(i, glyph); // See if the next sub-span needs to be added to the LineInfo bool addSpan = false; while (i >= spanEnd) { spanIndex++; const TextSpan& span = fTextSpans.ItemAt(spanIndex); spanStart = spanEnd; spanEnd += span.CharCount(); addSpan = true; } if (addSpan) { const TextSpan& span = fTextSpans.ItemAt(spanIndex); TextSpan subSpan = span.SubSpan(i - spanStart, (lineEnd - spanStart) - (i - spanStart)); line.layoutedSpans.Add(subSpan); _IncludeStyleInLine(line, span.Style()); } } lineHeight = line.height; return fLineInfos.Add(line); }