[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Aug 8 04:38:06 UTC 2017


 src/hb-ot-var-avar-table.hh |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 5dc30451b80f6bb0079424a130875c10486e4d34
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Aug 7 21:37:07 2017 -0700

    Two fixes to avar mapping
    
    1. Handle segment with two entries correctly,
    
    2. Fix rounding math.  Ouch!
    
    Fixes https://github.com/behdad/harfbuzz/issues/521

diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh
index ace0f5f2..464cf35b 100644
--- a/src/hb-ot-var-avar-table.hh
+++ b/src/hb-ot-var-avar-table.hh
@@ -57,8 +57,13 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
      * that at least -1, 0, and +1 must be mapped. But we include these as
      * part of a better error recovery scheme. */
 
-    if (!len)
-      return value;
+    if (len < 2)
+    {
+      if (!len)
+	return value;
+      else /* len == 1*/
+	return value - array[0].fromCoord + array[0].toCoord;
+    }
 
     if (value <= array[0].fromCoord)
       return value - array[0].fromCoord + array[0].toCoord;
@@ -76,8 +81,8 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
 
     int denom = array[i].fromCoord - array[i-1].fromCoord;
     return array[i-1].toCoord +
-	   (array[i].toCoord - array[i-1].toCoord) *
-	   (value - array[i-1].fromCoord + denom/2) / denom;
+	   ((array[i].toCoord - array[i-1].toCoord) *
+	    (value - array[i-1].fromCoord) + denom/2) / denom;
   }
 
   DEFINE_SIZE_ARRAY (2, array);


More information about the HarfBuzz mailing list