X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-background-actor.cpp;h=72bfcdea741da687d0e32c128dc427f98947b4db;hp=dda514fcea2ed72fd9ce2c7644b8bddfa8aefcbf;hb=895806b4ad86de88dcc731aeb8e3dbe453ce4202;hpb=6c542cda6eb2ae887cb7a8a6c5d77e2f9659cbf7 diff --git a/dali-toolkit/internal/text/text-controller-background-actor.cpp b/dali-toolkit/internal/text/text-controller-background-actor.cpp index dda514f..72bfcde 100644 --- a/dali-toolkit/internal/text/text-controller-background-actor.cpp +++ b/dali-toolkit/internal/text/text-controller-background-actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,11 +24,11 @@ // INTERNAL INCLUDES #include #include +#include #include namespace Dali::Toolkit::Text { - namespace { struct BackgroundVertex @@ -44,7 +44,7 @@ struct BackgroundMesh }; } // unnamed namespace -Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr& textVisualModel, Shader& textShaderBackground) +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. @@ -63,10 +63,10 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr const LineRun* lineRun = textVisualModel->mLines.Begin(); float alignmentOffset = lineRun->alignmentOffset; numberOfGlyphs = textView.GetGlyphs(glyphs.Begin(), - positions.Begin(), - alignmentOffset, - 0u, - numberOfGlyphs); + positions.Begin(), + alignmentOffset, + 0u, + numberOfGlyphs); glyphs.Resize(numberOfGlyphs); positions.Resize(numberOfGlyphs); @@ -86,6 +86,10 @@ 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(); + Vector& glyphToCharacterMap = textVisualModel->mGlyphsToCharacters; + const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); + float calculatedAdvance = 0.f; Vector4 quad; uint32_t numberOfQuads = 0u; @@ -117,33 +121,34 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr if(backgroundColor != Color::TRANSPARENT) { const Vector2 position = *(positionsBuffer + i); + calculatedAdvance = GetCalculatedAdvance(*(textLogicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + i))), characterSpacing, glyph.advance); if(i == 0u && glyphSize == 1u) // Only one glyph in the whole text { quad.x = position.x; quad.y = yLineOffset; - quad.z = quad.x + std::max(glyph.advance, glyph.xBearing + glyph.width); + quad.z = quad.x + std::max(calculatedAdvance, glyph.xBearing + glyph.width); quad.w = lineHeight; } else if((lineIndex != prevLineIndex) || (i == 0u)) // The first glyph in the line { quad.x = position.x; quad.y = yLineOffset; - quad.z = quad.x - glyph.xBearing + glyph.advance; + quad.z = quad.x - glyph.xBearing + calculatedAdvance; quad.w = quad.y + lineHeight; } else if(i == glyphSize - 1u) // The last glyph in the whole text { quad.x = position.x - glyph.xBearing; quad.y = yLineOffset; - quad.z = quad.x + std::max(glyph.advance, glyph.xBearing + glyph.width); + quad.z = quad.x + std::max(calculatedAdvance, glyph.xBearing + glyph.width); quad.w = quad.y + lineHeight; } else // The glyph in the middle of the text { quad.x = position.x - glyph.xBearing; quad.y = yLineOffset; - quad.z = quad.x + glyph.advance; + quad.z = quad.x + calculatedAdvance; quad.w = quad.y + lineHeight; }