[Libreoffice-commits] core.git: vcl/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Sat May 4 02:18:30 UTC 2019


 vcl/source/gdi/sallayout.cxx |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

New commits:
commit 98630a0bd49bd80652145a21e4e0d0ded792b36b
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Sun Apr 28 18:07:16 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat May 4 04:17:58 2019 +0200

    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 at fbihome.de>

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;


More information about the Libreoffice-commits mailing list