Commit 60bf264ee25dc08403dddb3e4cd2bf950cda9e90

Behdad Esfahbod 2017-05-02T14:38:54

[truetype] Make `IUP' gvar deltas do the same as Apple (#50832). When points are not touched by gvar interpolation deltas, FreeType gave a slightly different result than Apple's CoreText. The OpenType working group will update the specification to document the following behaviour: If the two points with deltas to the `left' and `right' of the untouched point have the same coordinate, then the inferred delta for the untouched point should be zero. * src/truetype/ttgxvar.c (tt_delta_interpolate): Implement new behaviour.

diff --git a/ChangeLog b/ChangeLog
index 8dd013e..05fd0aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2017-05-02  Behdad Esfahbod  <behdad@behdad.org>
+
+	[truetype] Make `IUP' gvar deltas do the same as Apple (#50832).
+
+	When points are not touched by gvar interpolation deltas, FreeType
+	gave a slightly different result than Apple's CoreText.
+
+	The OpenType working group will update the specification to document
+	the following behaviour: If the two points with deltas to the `left'
+	and `right' of the untouched point have the same coordinate, then
+	the inferred delta for the untouched point should be zero.
+
+	* src/truetype/ttgxvar.c (tt_delta_interpolate): Implement new
+	behaviour.
+
 2017-05-02  Werner Lemberg  <wl@gnu.org>
 
 	[autofit] Remove `slight' auto-hint mode again.
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 6d4529b..0cedb6b 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -3081,25 +3081,12 @@
       d1   = out1 - in1;
       d2   = out2 - in2;
 
-      if ( out1 == out2 || in1 == in2 )
+      /* If the reference points have the same coordinate but different */
+      /* delta, inferred delta is zero.  Otherwise interpolate.         */
+      if ( in1 != in2 || out1 == out2 )
       {
-        for ( p = p1; p <= p2; p++ )
-        {
-          out = in_points[p].x;
-
-          if ( out <= in1 )
-            out += d1;
-          else if ( out >= in2 )
-            out += d2;
-          else
-            out = out1;
-
-          out_points[p].x = out;
-        }
-      }
-      else
-      {
-        FT_Fixed  scale = FT_DivFix( out2 - out1, in2 - in1 );
+        FT_Fixed  scale = in1 != in2 ? FT_DivFix( out2 - out1, in2 - in1 )
+                                     : 0;
 
 
         for ( p = p1; p <= p2; p++ )