From: Sungyeon Woo Date: Sat, 23 Mar 2013 08:30:08 +0000 (+0900) Subject: bug fix for bidi X-Git-Tag: accepted/tizen_2.1/20130425.033138~757^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70acd2d4e61b9b840dc8457d60a167e5a2551e4d;p=platform%2Fframework%2Fnative%2Fuifw.git bug fix for bidi Change-Id: Ibe3c000761ed03e4f64fbb50ba24cffc8a291c8e Signed-off-by: Sungyeon Woo --- diff --git a/src/graphics/FGrp_Font.cpp b/src/graphics/FGrp_Font.cpp index e6e17f9..c6ece5e 100644 --- a/src/graphics/FGrp_Font.cpp +++ b/src/graphics/FGrp_Font.cpp @@ -1124,7 +1124,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co } else { - determinedCount = 0; + determinedCount = bidiProperty.pBidiIndex[0]; } } } @@ -1134,7 +1134,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co pcDim.SetSize(right - left, __fontAttrib.size.ToInt()); count = text.length; } - else + else if (determinedCount > 0 && right - left > 0) { _TextBidiPropertyWithReorder determinedBidiProperty(text.pStart, determinedCount); @@ -1157,7 +1157,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co } pcDim.SetSize(right - left, __fontAttrib.size.ToInt()); - count = (determinedCount >= 0) ? determinedCount : 0; + count = determinedCount; // for arabic collation element if (text.pStart + count != null) @@ -1185,7 +1185,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co right = (i->second > right) ? i->second : right; } - int tempWidth = (right - left) < width ? right - left : 0; + int temp1Width = right - left; //count + 1 < width _TextBidiPropertyWithReorder tempBidiProperty2(text.pStart, count + 1); @@ -1208,26 +1208,34 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co right = (i->second > right) ? i->second : right; } - if (right - left < width) + int temp2Width = right - left; + + if (temp2Width < width) { - if (right - left < tempWidth) + if (temp2Width < temp1Width) { - pcDim.SetSize(tempWidth, __fontAttrib.size.ToInt()); - count -= 1; + pcDim.SetSize(temp1Width, __fontAttrib.size.ToInt()); + count--; } else { - pcDim.SetSize(right - left, __fontAttrib.size.ToInt()); - count += 1; + pcDim.SetSize(temp2Width, __fontAttrib.size.ToInt()); + count++; } } else { - pcDim.SetSize(tempWidth, __fontAttrib.size.ToInt()); - count -= 1; + pcDim.SetSize(temp1Width, __fontAttrib.size.ToInt()); + count--; } } } +///// + } + else + { + pcDim.SetSize(0, 0); + count = 0; } return E_SUCCESS; diff --git a/src/graphics/FGrp_FontBidiUtil.cpp b/src/graphics/FGrp_FontBidiUtil.cpp index a71e16d..49b26db 100644 --- a/src/graphics/FGrp_FontBidiUtil.cpp +++ b/src/graphics/FGrp_FontBidiUtil.cpp @@ -634,13 +634,15 @@ _FontGlyphList::_FontGlyphList(const _Util::String& text, void* pFace, int scrip hb_buffer_set_script(hBuffer, hb_glib_script_to_script(GUnicodeScript(script))); hb_buffer_set_direction(hBuffer, (isRtl) ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); + int textLength = text.length; + if (sizeof(wchar_t) == sizeof(uint32_t)) { - hb_buffer_add_utf32(hBuffer, (const uint32_t*)text.pStart, text.length, 0, text.length); + hb_buffer_add_utf32(hBuffer, (const uint32_t*)text.pStart, textLength, 0, textLength); } else { - uint32_t* pDst = new (std::nothrow) uint32_t[text.length + 1]; + uint32_t* pDst = new (std::nothrow) uint32_t[textLength + 1]; if (pDst) { @@ -648,7 +650,7 @@ _FontGlyphList::_FontGlyphList(const _Util::String& text, void* pFace, int scrip const wchar_t* pSrc = text.pStart; uint32_t* pDstBegin = pDst; - uint32_t* pDstEnd = pDstBegin + text.length; + uint32_t* pDstEnd = pDstBegin + textLength; while (pDstBegin < pDstEnd) { @@ -658,7 +660,7 @@ _FontGlyphList::_FontGlyphList(const _Util::String& text, void* pFace, int scrip *pDstBegin = 0; } - hb_buffer_add_utf32(hBuffer, pDst, text.length, 0, text.length); + hb_buffer_add_utf32(hBuffer, pDst, textLength, 0, textLength); delete[] pDst; } @@ -667,27 +669,82 @@ _FontGlyphList::_FontGlyphList(const _Util::String& text, void* pFace, int scrip hb_shape(hSubFont, hBuffer, NULL, 0); this->__glyphCount = hb_buffer_get_length(hBuffer); - this->__pGlyphAuxInfo = new (std::nothrow) GlyphAuxInfo[this->__glyphCount]; - if (this->__pGlyphAuxInfo) + + if (int(this->__glyphCount) == textLength) { - hb_glyph_position_t* pPosition = hb_buffer_get_glyph_positions(hBuffer, NULL); - hb_glyph_info_t* pInfo = hb_buffer_get_glyph_infos(hBuffer, NULL); + this->__pGlyphAuxInfo = new (std::nothrow) GlyphAuxInfo[this->__glyphCount]; + + if (this->__pGlyphAuxInfo) + { + hb_glyph_position_t* pPosition = hb_buffer_get_glyph_positions(hBuffer, NULL); + hb_glyph_info_t* pInfo = hb_buffer_get_glyph_infos(hBuffer, NULL); - GlyphAuxInfo* pAuxInfo = &this->__pGlyphAuxInfo[0]; - GlyphAuxInfo* pAuxInfoEnd = pAuxInfo + this->__glyphCount; + GlyphAuxInfo* pAuxInfo = &this->__pGlyphAuxInfo[0]; + GlyphAuxInfo* pAuxInfoEnd = pAuxInfo + this->__glyphCount; - while (pAuxInfo < pAuxInfoEnd) + while (pAuxInfo < pAuxInfoEnd) + { + pAuxInfo->glyphIndex = pInfo->codepoint; + pAuxInfo->xOffset.Reset(pPosition->x_offset); + pAuxInfo->yOffset.Reset(pPosition->y_offset); + pAuxInfo->xAdvance.Reset(pPosition->x_advance); + pAuxInfo->yAdvance.Reset(pPosition->y_advance); + + ++pInfo; + ++pPosition; + ++pAuxInfo; + } + } + } + else + { + this->__glyphCount = textLength; + + this->__pGlyphAuxInfo = new (std::nothrow) GlyphAuxInfo[this->__glyphCount]; + + if (this->__pGlyphAuxInfo) { - pAuxInfo->glyphIndex = pInfo->codepoint; - pAuxInfo->xOffset.Reset(pPosition->x_offset); - pAuxInfo->yOffset.Reset(pPosition->y_offset); - pAuxInfo->xAdvance.Reset(pPosition->x_advance); - pAuxInfo->yAdvance.Reset(pPosition->y_advance); - - ++pInfo; - ++pPosition; - ++pAuxInfo; + hb_glyph_position_t* pPosition = hb_buffer_get_glyph_positions(hBuffer, NULL); + hb_glyph_info_t* pInfo = hb_buffer_get_glyph_infos(hBuffer, NULL); + + GlyphAuxInfo* pAuxInfo = &this->__pGlyphAuxInfo[0]; + GlyphAuxInfo* pAuxInfoEnd = pAuxInfo + this->__glyphCount; + + int textIndex = 0; + + while (pAuxInfo < pAuxInfoEnd) + { + pAuxInfo->glyphIndex = pInfo->codepoint; + pAuxInfo->xOffset.Reset(pPosition->x_offset); + pAuxInfo->yOffset.Reset(pPosition->y_offset); + pAuxInfo->xAdvance.Reset(pPosition->x_advance); + pAuxInfo->yAdvance.Reset(pPosition->y_advance); + + bool isColltionElement = ((textIndex + 1 < textLength) && _TextBidiUtil::IsCollationElement(*(text.pStart + textIndex + 1), *(text.pStart + textIndex))); // for Embeding Level = 0; + + if (isRtl) + { + isColltionElement = ((textIndex + 1 < textLength) && _TextBidiUtil::IsCollationElement(*(text.pStart + textIndex), *(text.pStart + textIndex + 1))); // for RtL + } + + if (isColltionElement) + { + ++pAuxInfo; + ++textIndex; + + pAuxInfo->glyphIndex = 0; + pAuxInfo->xOffset.Reset(0); + pAuxInfo->yOffset.Reset(0); + pAuxInfo->xAdvance.Reset(0); + pAuxInfo->yAdvance.Reset(0); + } + + ++pInfo; + ++pPosition; + ++pAuxInfo; + ++textIndex; + } } }