X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-view.cpp;h=0be5ac608fc99f301b0e07fe08e345cbd9320b97;hb=refs%2Fchanges%2F95%2F275895%2F6;hp=137ded27f2f1a39b91ba001c0cdeb667a3e049ca;hpb=a3c24db302ffb83a32a0b5d8fba0b2c9de2b6634;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index 137ded2..0be5ac6 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -107,7 +108,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, { Length numberOfLaidOutGlyphs = 0u; Length numberOfActualLaidOutGlyphs = 0u; - const float characterSpacing = mImpl->mVisualModel->GetCharacterSpacing(); + const float modelCharacterSpacing = mImpl->mVisualModel->GetCharacterSpacing(); Vector& glyphToCharacterMap = mImpl->mVisualModel->mGlyphsToCharacters; const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); float calculatedAdvance = 0.f; @@ -115,12 +116,15 @@ Length View::GetGlyphs(GlyphInfo* glyphs, if(mImpl->mVisualModel) { + // Get the character-spacing runs. + const Vector& characterSpacingGlyphRuns = mImpl->mVisualModel->GetCharacterSpacingGlyphRuns(); + bool textElided = false; DevelText::EllipsisPosition::Type ellipsisPosition = GetEllipsisPosition(); //Reset indices of ElidedGlyphs mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(0u); - mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(numberOfGlyphs); + mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(numberOfGlyphs - 1u); // Initialization is the last index of Glyphs mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(0u); mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(0u); @@ -279,7 +283,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, const LineRun& elidedLine = *ellipsisLine; if((1u == numberOfLines) && - (GetLineHeight(elidedLine) > mImpl->mVisualModel->mControlSize.height)) + (GetLineHeight(elidedLine, true) > mImpl->mVisualModel->mControlSize.height)) { // Replace the first glyph with ellipsis glyph auto indexOfFirstGlyph = (ellipsisPosition == DevelText::EllipsisPosition::START) ? startIndexOfEllipsis : 0u; @@ -356,7 +360,8 @@ Length View::GetGlyphs(GlyphInfo* glyphs, firstPenSet = true; } - calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance); + const float characterSpacing = GetGlyphCharacterSpacing(indexOfEllipsis, characterSpacingGlyphRuns, modelCharacterSpacing); + calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance); removedGlypsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)); // Calculate the width of the ellipsis glyph and check if it fits. @@ -371,10 +376,73 @@ Length View::GetGlyphs(GlyphInfo* glyphs, glyphInfo = ellipsisGlyph; // Change the 'x' and 'y' position of the ellipsis glyph. - if(position.x > firstPenX) { - position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + if(isTailMode) + { + // To handle case of the mixed languages (LTR then RTL) with + // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x > nextXPositions) // RTL language + { + if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlypsWidth)) + { + // To handle mixed directions + // Re-calculates the first penX which will be used if rtl text is elided. + firstPenX = position.x - glyphToRemove.xBearing; + if(firstPenX < -ellipsisGlyph.xBearing) + { + // Avoids to exceed the bounding box when rtl text is elided. + firstPenX = -ellipsisGlyph.xBearing; + } + //Reset the width of removed glyphs + removedGlypsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing; + + --indexOfEllipsis; + continue; + } + else + { + // To handle the case of RTL language with EllipsisPosition::END + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + } + else + { + // To handle the case of LTR language with EllipsisPosition::START + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + else + { + if(!isTailMode) + { + // To handle case of the mixed languages (RTL then LTR) with + // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x < nextXPositions) // LTR language + { + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + + if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions) + { + position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions; + } + } + } } position.x += ellipsisGlyph.xBearing; @@ -824,6 +892,31 @@ void View::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, } } +Length View::GetNumberOfBoundedParagraphRuns() const +{ + if(mImpl->mLogicalModel) + { + return mImpl->mLogicalModel->GetNumberOfBoundedParagraphRuns(); + } + + return 0u; +} + +const Vector& View::GetBoundedParagraphRuns() const +{ + return mImpl->mLogicalModel->GetBoundedParagraphRuns(); +} + +Length View::GetNumberOfCharacterSpacingGlyphRuns() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetNumberOfCharacterSpacingGlyphRuns() : 0u; +} + +const Vector& View::GetCharacterSpacingGlyphRuns() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacingGlyphRuns() : GetEmptyCharacterSpacingGlyphRuns(); +} + const float View::GetCharacterSpacing() const { return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacing() : 0.f;