From 64b40c8725ba9ef71b060d598ec9d434fae5ffa7 Mon Sep 17 00:00:00 2001 From: Yunji Park Date: Fri, 21 Jun 2013 16:43:25 +0900 Subject: [PATCH] Modified block rectangle - Fixed PLM Change-Id: Icc42e52c1f464e7ceb053fee84e50de0505ef476 --- src/graphics/text/FGrp_TextTextComposite.cpp | 55 +++++++++++++++++++++------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/src/graphics/text/FGrp_TextTextComposite.cpp b/src/graphics/text/FGrp_TextTextComposite.cpp index da9007b..80acaa7 100644 --- a/src/graphics/text/FGrp_TextTextComposite.cpp +++ b/src/graphics/text/FGrp_TextTextComposite.cpp @@ -1718,6 +1718,11 @@ TextComposite::DrawBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayR int blockStartTextIndex = Math::Max(__workStart, startTextIndex); int blockEndTextIndex = Math::Min(__workStart + __workLength, startTextIndex + textLength); int blockTextLength = blockEndTextIndex - blockStartTextIndex; + float left = 0; + float right = 0; + bool isRtL = false; + bool isLtR = false; + wchar_t ch; if (blockStartTextIndex >= blockEndTextIndex) { @@ -1727,17 +1732,11 @@ TextComposite::DrawBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayR FloatRectangle lineBounds = pTextLine->GetBoundsF(); blockStartTextIndex -= lineOffset; blockEndTextIndex -= lineOffset; - FloatRectangle blockRect = displayRect; blockRect.y = lineBounds.y; Collection::ArrayListT<_FloatPair>* pGapList = pTextLine->GetTextExtentList(); - float left = 0; - float right = 0; - float blockStart = 0; - float blockEnd = 0; - _FloatPair currentGap; IEnumeratorT<_FloatPair >* pGapEnum = pGapList->GetEnumeratorN(); @@ -1746,11 +1745,23 @@ TextComposite::DrawBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayR pGapEnum->MoveNext(); } + pGapEnum->GetCurrent(currentGap); + float blockStart = currentGap.first; + float blockEnd = currentGap.second; + bool prevRtL = TextUtility::IsRTLCharacter(GetCharacter(blockStartTextIndex + lineOffset)); + TextBidiHint bidiHint = _GetTextBidiHint(); + bool isBidiEnabled = (bidiHint == TEXT_BIDI_HINT_RTL) ? true : false; + for (int count = 0; count < blockTextLength; count++) { pGapEnum->GetCurrent(currentGap); - if (right == currentGap.first || left == currentGap.second) + ch = GetCharacter(blockStartTextIndex + lineOffset + count); + isRtL = TextUtility::IsRTLCharacter(ch); + isLtR = TextUtility::IsLTRCharacter(ch); + isRtL = (!isRtL && !isLtR) ? isBidiEnabled : isRtL; + + if (prevRtL == isRtL) { blockStart = (currentGap.first < blockStart) ? currentGap.first : blockStart; blockEnd = (currentGap.second > blockEnd) ? currentGap.second : blockEnd; @@ -1768,6 +1779,7 @@ TextComposite::DrawBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayR left = currentGap.first; right = currentGap.second; + prevRtL = isRtL; pGapEnum->MoveNext(); } @@ -1802,15 +1814,16 @@ TextComposite::DrawBackgroundBlock(_CanvasImpl& canvasImpl, const FloatRectangle int blockEndTextIndex = startTextIndex + textLength; float prevLeft = 0; float prevRight = 0; - float blockStart = 0; - float blockEnd = 0; int currentLength = 0; int elementTextOffset = 0; int elementIndex = 0; int textIndexFromElementOffset = 0; + int textIndex = startTextIndex; + bool isRtL = false; + bool isLtR = false; + wchar_t ch; FloatRectangle lineBounds = pTextLine->GetBoundsF(); - blockEndTextIndex -= pTextLine->GetTextOffset(); FloatRectangle blockRect = displayRect; blockRect.y = lineBounds.y; @@ -1835,11 +1848,24 @@ TextComposite::DrawBackgroundBlock(_CanvasImpl& canvasImpl, const FloatRectangle _FloatPair currentGap; IEnumeratorT<_FloatPair >* pEnum = elemenGapListF.GetEnumeratorN(); - while (pEnum->MoveNext() == E_SUCCESS) + pEnum->MoveNext(); + pEnum->GetCurrent(currentGap); + float blockStart = currentGap.first; + float blockEnd = currentGap.second; + bool prevRtL = TextUtility::IsRTLCharacter(GetCharacter(textIndex)); + TextBidiHint bidiHint = _GetTextBidiHint(); + bool isBidiEnabled = (bidiHint == TEXT_BIDI_HINT_RTL) ? true : false; + + while (textIndex < blockEndTextIndex) { pEnum->GetCurrent(currentGap); - if (prevRight == currentGap.first || prevLeft == currentGap.second) + ch = GetCharacter(textIndex++); + isRtL = TextUtility::IsRTLCharacter(ch); + isLtR = TextUtility::IsLTRCharacter(ch); + isRtL = (!isRtL && !isLtR) ? isBidiEnabled : isRtL; + + if (prevRtL == isRtL) { blockStart = (currentGap.first < blockStart) ? currentGap.first : blockStart; blockEnd = (currentGap.second > blockEnd) ? currentGap.second : blockEnd; @@ -1857,6 +1883,9 @@ TextComposite::DrawBackgroundBlock(_CanvasImpl& canvasImpl, const FloatRectangle prevLeft = currentGap.first; prevRight = currentGap.second; + prevRtL = isRtL; + + pEnum->MoveNext(); } if (blockStart != blockEnd) @@ -1864,7 +1893,7 @@ TextComposite::DrawBackgroundBlock(_CanvasImpl& canvasImpl, const FloatRectangle canvasImpl.FillRectangle(backgroundColor, FloatRectangle(blockRect.x + blockStart, displayRect.y, blockEnd - blockStart, displayRect.height)); } - if ((pTextLine->GetEndType() == TEXT_RETBY_LINEFEED) && (pTextLine->GetTextLength() == blockEndTextIndex)) + if ((pTextLine->GetEndType() == TEXT_RETBY_LINEFEED) && (pTextLine->GetTextOffset() + pTextLine->GetTextLength() == blockEndTextIndex)) { canvasImpl.FillRectangle(backgroundColor, FloatRectangle(blockRect.x + blockEnd, displayRect.y, LINE_FEED_WIDTH, displayRect.height)); } -- 2.7.4