Commit 74c0a72d529ab1622e055aeb59bc7dde2824b8f2

Behdad Esfahbod 2016-03-09T20:35:27

[truetype] Fix handling of non-intermediate GX tuples. We probably did not notice this as all fonts we tested had only tuple_coords[i] be +1 or -1 for non-intermediate tuples. * src/truetype/ttgxvar.c (ft_var_apply_tuple): Implement it.

diff --git a/ChangeLog b/ChangeLog
index 8761d54..5eb6def 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-03-09  Behdad Esfahbod  <behdad@behdad.org>
+
+	[truetype] Fix handling of non-intermediate GX tuples.
+
+	We probably did not notice this as all fonts we tested had only
+	tuple_coords[i] be +1 or -1 for non-intermediate tuples.
+
+	* src/truetype/ttgxvar.c (ft_var_apply_tuple): Implement it.
+
 2016-03-06  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[base] Refuse to render enormous outlines (#47114).
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 6b29a83..ce4c8a0 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -632,8 +632,8 @@
         break;
       }
 
-      else if ( ( blend->normalizedcoords[i] < 0 && tuple_coords[i] > 0 ) ||
-                ( blend->normalizedcoords[i] > 0 && tuple_coords[i] < 0 ) )
+      else if ( ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) ) ||
+                ( blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) ) )
       {
         FT_TRACE6(( "      tuple coordinate value %.4f is exceeded, stop\n",
                     tuple_coords[i] / 65536.0 ));
@@ -646,10 +646,9 @@
         FT_TRACE6(( "      tuple coordinate value %.4f fits\n",
                     tuple_coords[i] / 65536.0 ));
         /* not an intermediate tuple */
-        apply = FT_MulFix( apply,
-                           blend->normalizedcoords[i] > 0
-                             ? blend->normalizedcoords[i]
-                             : -blend->normalizedcoords[i] );
+        apply = FT_MulDiv( apply,
+                           blend->normalizedcoords[i],
+                           tuple_coords[i] );
       }
 
       else if ( blend->normalizedcoords[i] < im_start_coords[i] ||