[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    [ft-devel] Another font variation bug fix
From:       Matthias Clasen <matthias.clasen () gmail ! com>
Date:       2017-12-18 19:08:08
Message-ID: CAFwd_vARCQzMJ4GCcZJNL=3frjeAsXdCQH0Upwd7Cauw8ZqSbA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Here is a small fix that we came upon while working on font variations
support for pango

[Attachment #5 (text/html)]

<div dir="ltr">Here is a small fix that we came upon while working on font variations \
support for pango<br></div>

--94eb2c04435e236c620560a2127f--


["0001-Fix-clamping-of-font-variation-axis-values.patch" (text/x-patch)]

From 723b01eadd71549b7315fd20d858d043ed9e9562 Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Mon, 18 Dec 2017 14:06:02 -0500
Subject: [PATCH] Fix clamping of font variation axis values

We were clamping the value correctly here, but then
used the original value for normalization anyway.
---
 src/truetype/ttgxvar.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 0d4872f4a..4b4069111 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -54,6 +54,7 @@
 
 #include "tterrors.h"
 
+#include <stdio.h>
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 
@@ -1733,7 +1734,7 @@
     /* based on the [min,def,max] values for the axis to be [-1,0,1]. */
     /* Then, if there's an `avar' table, we renormalize this range.   */
 
-    FT_TRACE5(( "design coordinates:\n" ));
+    printf( "design coordinates: %d\n", num_coords);
 
     a = mmvar->axis;
     for ( i = 0; i < num_coords; i++, a++ )
@@ -1741,15 +1742,15 @@
       FT_Fixed  coord = coords[i];
 
 
-      FT_TRACE5(( "  %.5f\n", coord / 65536.0 ));
+      printf( "  %.5f\n", coord / 65536.0 );
       if ( coord > a->maximum || coord < a->minimum )
       {
-        FT_TRACE1((
+        printf(
           "ft_var_to_normalized: design coordinate %.5f\n"
           "                      is out of range [%.5f;%.5f]; clamping\n",
           coord / 65536.0,
           a->minimum / 65536.0,
-          a->maximum / 65536.0 ));
+          a->maximum / 65536.0 );
 
         if ( coord > a->maximum)
           coord = a->maximum;
@@ -1758,10 +1759,10 @@
       }
 
       if ( coord < a->def )
-        normalized[i] = -FT_DivFix( coords[i] - a->def,
+        normalized[i] = -FT_DivFix( coord - a->def,
                                     a->minimum - a->def );
       else if ( coord > a->def )
-        normalized[i] = FT_DivFix( coords[i] - a->def,
+        normalized[i] = FT_DivFix( coord - a->def,
                                    a->maximum - a->def );
       else
         normalized[i] = 0;
-- 
2.15.1



_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic