From 9f3fce1eac49627262f5b60051e28ec1617a1787 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 16 Oct 2008 21:40:12 +0000 Subject: [PATCH] Stippi + zooey: * fixed LineHeight() for the case when the textview does not yet contain anything - instead of returning 0 we now return the lineheight of the default style (or the textview's font). Fixes #2231 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28194 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 1f90c125db..d3f73158dc 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -1969,7 +1969,21 @@ BTextView::LineWidth(int32 lineNum) const float BTextView::LineHeight(int32 lineNum) const { - return TextHeight(lineNum, lineNum); + float lineHeight = TextHeight(lineNum, lineNum); + if (lineHeight == 0.0) { + // We probably don't have text content yet. Take the initial + // style's font height or fall back to the plain font. + const BFont* font; + fStyles->GetNullStyle(&font, NULL); + if (font == NULL) + font = be_plain_font; + + font_height fontHeight; + font->GetHeight(&fontHeight); + // This is how the height is calculated in _RecalculateLineBreaks(). + lineHeight = ceilf(fontHeight.ascent + fontHeight.descent) + 1; + } + return lineHeight; } @@ -2734,19 +2748,6 @@ BTextView::_ValidateLayoutData() CALLED(); float lineHeight = ceilf(LineHeight(0)); - if (lineHeight == 0.0) { - // We probably don't have text content yet. Take the initial - // style's font height or fall back to the plain font. - const BFont* font; - fStyles->GetNullStyle(&font, NULL); - if (font == NULL) - font = be_plain_font; - - font_height fontHeight; - font->GetHeight(&fontHeight); - // This is how the height is calculated in _RecalculateLineBreaks(). - lineHeight = ceilf(fontHeight.ascent + fontHeight.descent) + 1; - } TRACE("line height: %.2f\n", lineHeight); // compute our minimal size