summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/sallayout.cxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-04-28 18:07:16 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2019-05-04 04:17:58 +0200
commit98630a0bd49bd80652145a21e4e0d0ded792b36b (patch)
tree3dcd728cca44338d324c0a9f2638927b3b0ff987 /vcl/source/gdi/sallayout.cxx
parent96f5b605338d28713ec8bf1e4d98efd18bf6f62a (diff)
Restore old quick-check behaviour...
that was changed in commit 5cb3a6da2a61 ("Move and fix Asian kerning unicode point check"). Change-Id: I96e815462a154e241eb8d871025e94304d458ffc Reviewed-on: https://gerrit.libreoffice.org/71487 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/source/gdi/sallayout.cxx')
-rw-r--r--vcl/source/gdi/sallayout.cxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index b5d8e96bc17b..3c197c016b1a 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -774,10 +774,6 @@ static int lcl_CalcAsianKerning(sal_UCS4 c, bool bLeft)
};
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) )
nResult = nTable[ c - 0x3000 ];
else switch( c )
@@ -801,6 +797,11 @@ static int lcl_CalcAsianKerning(sal_UCS4 c, bool bLeft)
return nResult;
}
+static bool lcl_CanApplyAsianKerning(sal_Unicode cp)
+{
+ return (0x3000 == (cp & 0xFF00)) || (0xFF00 == (cp & 0xFF00)) || (0x2010 == (cp & 0xFFF0));
+}
+
void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
{
const int nLength = rStr.getLength();
@@ -813,16 +814,24 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr)
const int n = pGlyphIter->m_nCharPos;
if (n < nLength - 1)
{
+ // ignore code ranges that are not affected by asian punctuation compression
+ const sal_Unicode cCurrent = rStr[n];
+ if (!lcl_CanApplyAsianKerning(cCurrent))
+ continue;
+ const sal_Unicode cNext = rStr[n + 1];
+ if (!lcl_CanApplyAsianKerning(cNext))
+ continue;
+
// calculate compression values
- const int nKernFirst = +lcl_CalcAsianKerning(rStr[n], true);
- if (nKernFirst == 0)
+ const int nKernCurrent = +lcl_CalcAsianKerning(cCurrent, true);
+ if (nKernCurrent == 0)
continue;
- const int nKernNext = -lcl_CalcAsianKerning(rStr[n + 1], false);
+ const int nKernNext = -lcl_CalcAsianKerning(cNext, false);
if (nKernNext == 0)
continue;
// apply punctuation compression to logical glyph widths
- int nDelta = (nKernFirst < nKernNext) ? nKernFirst : nKernNext;
+ int nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext;
if (nDelta < 0)
{
nDelta = (nDelta * pGlyphIter->m_nOrigWidth + 2) / 4;