}
else
{
- determinedCount = 0;
+ determinedCount = bidiProperty.pBidiIndex[0];
}
}
}
pcDim.SetSize(right - left, __fontAttrib.size.ToInt());
count = text.length;
}
- else
+ else if (determinedCount > 0 && right - left > 0)
{
_TextBidiPropertyWithReorder determinedBidiProperty(text.pStart, determinedCount);
}
pcDim.SetSize(right - left, __fontAttrib.size.ToInt());
- count = (determinedCount >= 0) ? determinedCount : 0;
+ count = determinedCount;
// for arabic collation element
if (text.pStart + count != null)
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);
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;
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)
{
const wchar_t* pSrc = text.pStart;
uint32_t* pDstBegin = pDst;
- uint32_t* pDstEnd = pDstBegin + text.length;
+ uint32_t* pDstEnd = pDstBegin + textLength;
while (pDstBegin < pDstEnd)
{
*pDstBegin = 0;
}
- hb_buffer_add_utf32(hBuffer, pDst, text.length, 0, text.length);
+ hb_buffer_add_utf32(hBuffer, pDst, textLength, 0, textLength);
delete[] pDst;
}
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;
+ }
}
}