ParagraphLayout: Handle empty paragraphs.

Add one LineInfo for the empty TextSpan, if they have one. This gives the
layout a height for the one, empty line.
This commit is contained in:
Stephan Aßmus 2014-01-26 15:16:58 +01:00
parent 3627434d2b
commit 90d1cbe3e4
1 changed files with 10 additions and 1 deletions

View File

@ -628,7 +628,7 @@ ParagraphLayout::_Layout()
}
// The last line may not have been appended and initialized yet.
if (lineStart <= glyphCount - 1) {
if (lineStart <= glyphCount - 1 || glyphCount == 0) {
float lineHeight;
_FinalizeLine(lineStart, glyphCount - 1, lineIndex, y, lineHeight);
}
@ -867,6 +867,15 @@ ParagraphLayout::_FinalizeLine(int lineStart, int lineEnd, int lineIndex,
}
}
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);