From 720f7fdf54802a0e58d5b1131096972a88f03483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 6 Sep 2013 15:48:30 +0200 Subject: [PATCH] HaikuDepot: ParagraphLayout: Fix work around * Bail early if the TextSpan length is 0. * When the span starts with a space, the work around for the app_server bug, which I should fix, needs to offset by the other delta. --- src/apps/haiku-depot/textview/ParagraphLayout.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/apps/haiku-depot/textview/ParagraphLayout.cpp b/src/apps/haiku-depot/textview/ParagraphLayout.cpp index c56f136cb3..3634dfcd27 100644 --- a/src/apps/haiku-depot/textview/ParagraphLayout.cpp +++ b/src/apps/haiku-depot/textview/ParagraphLayout.cpp @@ -707,6 +707,10 @@ void ParagraphLayout::_DrawSpan(BView* view, BPoint offset, const TextSpan& span, int32 textOffset) const { + const BString& text = span.Text(); + if (text.Length() == 0) + return; + const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset); const LineInfo& line = fLineInfos.ItemAtFast(glyph.lineIndex); @@ -725,7 +729,10 @@ ParagraphLayout::_DrawSpan(BView* view, BPoint offset, delta.space = line.extraWhiteSpacing; // TODO: Fix in app_server: First glyph should not be shifted by delta. - offset.x -= delta.nonspace; + if (text[0] == ' ') + offset.x -= delta.space; + else + offset.x -= delta.nonspace; view->DrawString(span.Text(), offset, &delta); }