From: abdullah Date: Sun, 13 Mar 2022 13:03:33 +0000 (+0300) Subject: Fix text markup background incorrect position with negative line spacing X-Git-Tag: dali_2.1.15~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=73d652743f20733dfa9c8b44f074fe390ce48825 Fix text markup background incorrect position with negative line spacing the issue appear in TextEditor when using different markup text background in different lines with negative line spacing Change-Id: I4cab4460ef3073dfe74c69b7071fa304d18b3b74 --- diff --git a/dali-toolkit/internal/text/text-controller-background-actor.cpp b/dali-toolkit/internal/text/text-controller-background-actor.cpp index 72bfcde..a129c5e 100644 --- a/dali-toolkit/internal/text/text-controller-background-actor.cpp +++ b/dali-toolkit/internal/text/text-controller-background-actor.cpp @@ -44,6 +44,18 @@ struct BackgroundMesh }; } // unnamed namespace +Length CalculateBackgroundLineHeight(LineRun lineRun) +{ + Length height = lineRun.ascender + -(lineRun.descender); + + if(lineRun.lineSpacing > 0) + { + height += lineRun.lineSpacing; + } + + return height; +} + Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr& textVisualModel, const LogicalModelPtr& textLogicalModel, Shader& textShaderBackground) { // NOTE: Currently we only support background color for left-to-right text. @@ -110,11 +122,16 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr const Vector4& backgroundColor = isDefaultBackgroundColor ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u); textVisualModel->GetNumberOfLines(i, 1, lineIndex, numberOfLines); - Length lineHeight = lineRun[lineIndex].ascender + -(lineRun[lineIndex].descender) + lineRun[lineIndex].lineSpacing; + Length lineHeight = CalculateBackgroundLineHeight(lineRun[lineIndex]); if(lineIndex != prevLineIndex) { - yLineOffset += lineHeight; + yLineOffset += CalculateBackgroundLineHeight(lineRun[prevLineIndex]); + + if(lineRun[prevLineIndex].lineSpacing < 0) + { + yLineOffset += lineRun[prevLineIndex].lineSpacing; + } } // Only create quads for glyphs with a background color