From 90d1cbe3e496733d0ec1ff1cb668eb5b5fb8be0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 26 Jan 2014 15:16:58 +0100 Subject: [PATCH] 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. --- src/apps/haiku-depot/textview/ParagraphLayout.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.cpp b/src/apps/haiku-depot/textview/ParagraphLayout.cpp index 107a606b3e..86f30c2599 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.cpp +++ b/src/apps/haiku-depot/textview/ParagraphLayout.cpp @@ -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);