X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-background-actor.cpp;h=7def7e8bdc51835002c11a33b655d445713aba07;hb=702cdc29b907688eef62afbc63f0edb9e2dfb7d2;hp=72bfcdea741da687d0e32c128dc427f98947b4db;hpb=960870f0f39490cf3679ab54b3f32c258bb4ab03;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller-background-actor.cpp b/dali-toolkit/internal/text/text-controller-background-actor.cpp index 72bfcde..7def7e8 100644 --- a/dali-toolkit/internal/text/text-controller-background-actor.cpp +++ b/dali-toolkit/internal/text/text-controller-background-actor.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace Dali::Toolkit::Text @@ -44,6 +45,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. @@ -86,11 +99,14 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr const Vector4* const backgroundColorsBuffer = textView.GetBackgroundColors(); const ColorIndex* const backgroundColorIndicesBuffer = textView.GetBackgroundColorIndices(); const Vector4& defaultBackgroundColor = textVisualModel->IsBackgroundEnabled() ? textVisualModel->GetBackgroundColor() : Color::TRANSPARENT; - const float characterSpacing = textVisualModel->GetCharacterSpacing(); + const float modelCharacterSpacing = textVisualModel->GetCharacterSpacing(); Vector& glyphToCharacterMap = textVisualModel->mGlyphsToCharacters; const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); float calculatedAdvance = 0.f; + // Get the character-spacing runs. + const Vector& characterSpacingGlyphRuns = textVisualModel->GetCharacterSpacingGlyphRuns(); + Vector4 quad; uint32_t numberOfQuads = 0u; Length yLineOffset = 0; @@ -110,16 +126,23 @@ 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 if(backgroundColor != Color::TRANSPARENT) { + const float characterSpacing = GetGlyphCharacterSpacing(i, characterSpacingGlyphRuns, modelCharacterSpacing); + const Vector2 position = *(positionsBuffer + i); calculatedAdvance = GetCalculatedAdvance(*(textLogicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + i))), characterSpacing, glyph.advance);