Kaydet (Commit) 5cb3a6da authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Move and fix Asian kerning unicode point check

It's the same then

* (1 != c && 2 != c) || (3 != c)
* !(1 == c || 2 == c) || !(3 == c)
* !((1 == c || 2 == c) && (3 == c))

which is always true.

Change-Id: Ib63127319ff7e9c13877ac54aa92427637061812
Reviewed-on: https://gerrit.libreoffice.org/71477
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 9c1c18f4
...@@ -774,6 +774,10 @@ static int lcl_CalcAsianKerning(sal_UCS4 c, bool bLeft) ...@@ -774,6 +774,10 @@ static int lcl_CalcAsianKerning(sal_UCS4 c, bool bLeft)
}; };
int nResult = 0; int nResult = 0;
// ignore code ranges that are not affected by asian punctuation compression
if ((0x3000 != (c & 0xFF00)) && (0xFF00 != (c & 0xFF00)) && (0x2010 != (c & 0xFFF0)))
return nResult;
if( (c >= 0x3000) && (c < 0x3030) ) if( (c >= 0x3000) && (c < 0x3030) )
nResult = nTable[ c - 0x3000 ]; nResult = nTable[ c - 0x3000 ];
else switch( c ) else switch( c )
...@@ -809,21 +813,17 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) ...@@ -809,21 +813,17 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
const int n = pGlyphIter->m_nCharPos; const int n = pGlyphIter->m_nCharPos;
if (n < nLength - 1) if (n < nLength - 1)
{ {
// ignore code ranges that are not affected by asian punctuation compression // calculate compression values
const sal_Unicode cHere = rStr[n]; const int nKernFirst = +lcl_CalcAsianKerning(rStr[n], true);
if( ((0x3000 != (cHere & 0xFF00)) && (0x2010 != (cHere & 0xFFF0))) || (0xFF00 != (cHere & 0xFF00)) ) if (nKernFirst == 0)
continue; continue;
const sal_Unicode cNext = rStr[n+1]; const int nKernNext = -lcl_CalcAsianKerning(rStr[n + 1], false);
if( ((0x3000 != (cNext & 0xFF00)) && (0x2010 != (cNext & 0xFFF0))) || (0xFF00 != (cNext & 0xFF00)) ) if (nKernNext == 0)
continue; continue;
// calculate compression values
const int nKernFirst = +lcl_CalcAsianKerning(cHere, true);
const int nKernNext = -lcl_CalcAsianKerning(cNext, false);
// apply punctuation compression to logical glyph widths // apply punctuation compression to logical glyph widths
int nDelta = (nKernFirst < nKernNext) ? nKernFirst : nKernNext; int nDelta = (nKernFirst < nKernNext) ? nKernFirst : nKernNext;
if( nDelta<0 && nKernFirst!=0 && nKernNext!=0 ) if (nDelta < 0)
{ {
nDelta = (nDelta * pGlyphIter->m_nOrigWidth + 2) / 4; nDelta = (nDelta * pGlyphIter->m_nOrigWidth + 2) / 4;
if( pGlyphIter+1 == pGlyphIterEnd ) if( pGlyphIter+1 == pGlyphIterEnd )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment