shithub: freetype+ttf2subf

Download patch

ref: 77c39b1deb0d44f1a642335ae72af66b91271cf9
parent: 94152819b0cdd134f51beb65e4dad21ba7a212ba
author: Werner Lemberg <[email protected]>
date: Sat May 4 14:04:07 EDT 2013

[cff] Make Adobe CFF engine work correctly on 64bit hosts.

Reported by numerous people on the `freetype-devel' list.  Without
this fix, glyphs aren't properly aligned on a common baseline.

On 64bit systems, `FT_Pos' expands to `long int', having a width of
64bit.  `CF2_Fixed' expands to `int' which is normally 32bit wide on
64bit hosts also.  Wrong casts filled up the blues arrays with
incorrect values.  Note that all blues values are accessed with the
`cf2_blueToFixed' macro which handles the 64bit to 32bit conversion.

* src/cff/cf2ft.h (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Use `FT_Pos' for
`data', not `CF2_Fixed'.
* src/cff/cf2ft.c (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated.
* src/cff/cf2blues.c (cf2_blues_init): Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2013-05-04  Werner Lemberg  <[email protected]>
 
+	[cff] Make Adobe CFF engine work correctly on 64bit hosts.
+
+	Reported by numerous people on the `freetype-devel' list.  Without
+	this fix, glyphs aren't properly aligned on a common baseline.
+
+	On 64bit systems, `FT_Pos' expands to `long int', having a width of
+	64bit.  `CF2_Fixed' expands to `int' which is normally 32bit wide on
+	64bit hosts also.  Wrong casts filled up the blues arrays with
+	incorrect values.  Note that all blues values are accessed with the
+	`cf2_blueToFixed' macro which handles the 64bit to 32bit conversion.
+
+	* src/cff/cf2ft.h (cf2_getBlueValues, cf2_getOtherBlues,
+	cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Use `FT_Pos' for
+	`data', not `CF2_Fixed'.
+	* src/cff/cf2ft.c (cf2_getBlueValues, cf2_getOtherBlues,
+	cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated.
+	* src/cff/cf2blues.c (cf2_blues_init): Updated.
+
+2013-05-04  Werner Lemberg  <[email protected]>
+
 	More fixes for clang's `sanitize' feature.
 
 	* src/base/ftcalc.c (FT_DivFix): Use unsigned values for
@@ -537,7 +557,7 @@
 	[sfnt] Fix broken pointer overflow checks.
 
 	Many compilers such as gcc and clang optimize away pointer overflow
-	checks `p + n < p', because pointer overflow is undefined behavior. 
+	checks `p + n < p', because pointer overflow is undefined behavior.
 	Use a safe form `n > p_limit - p' instead.
 
 	Also avoid possible integer overflow issues, for example, using
--- a/src/cff/cf2blues.c
+++ b/src/cff/cf2blues.c
@@ -78,10 +78,10 @@
     size_t  numFamilyBlues;
     size_t  numFamilyOtherBlues;
 
-    CF2_Fixed*  blueValues;
-    CF2_Fixed*  otherBlues;
-    CF2_Fixed*  familyBlues;
-    CF2_Fixed*  familyOtherBlues;
+    FT_Pos*  blueValues;
+    FT_Pos*  otherBlues;
+    FT_Pos*  familyBlues;
+    FT_Pos*  familyOtherBlues;
 
     size_t     i;
     CF2_Fixed  emBoxBottom, emBoxTop;
--- a/src/cff/cf2ft.c
+++ b/src/cff/cf2ft.c
@@ -432,12 +432,12 @@
   FT_LOCAL_DEF( void )
   cf2_getBlueValues( CFF_Decoder*  decoder,
                      size_t*       count,
-                     CF2_Fixed*   *data )
+                     FT_Pos*      *data )
   {
     FT_ASSERT( decoder && decoder->current_subfont );
 
     *count = decoder->current_subfont->private_dict.num_blue_values;
-    *data  = (CF2_Fixed*)
+    *data  = (FT_Pos*)
                &decoder->current_subfont->private_dict.blue_values;
   }
 
@@ -445,12 +445,12 @@
   FT_LOCAL_DEF( void )
   cf2_getOtherBlues( CFF_Decoder*  decoder,
                      size_t*       count,
-                     CF2_Fixed*   *data )
+                     FT_Pos*      *data )
   {
     FT_ASSERT( decoder && decoder->current_subfont );
 
     *count = decoder->current_subfont->private_dict.num_other_blues;
-    *data  = (CF2_Fixed*)
+    *data  = (FT_Pos*)
                &decoder->current_subfont->private_dict.other_blues;
   }
 
@@ -458,12 +458,12 @@
   FT_LOCAL_DEF( void )
   cf2_getFamilyBlues( CFF_Decoder*  decoder,
                       size_t*       count,
-                      CF2_Fixed*   *data )
+                      FT_Pos*      *data )
   {
     FT_ASSERT( decoder && decoder->current_subfont );
 
     *count = decoder->current_subfont->private_dict.num_family_blues;
-    *data  = (CF2_Fixed*)
+    *data  = (FT_Pos*)
                &decoder->current_subfont->private_dict.family_blues;
   }
 
@@ -471,12 +471,12 @@
   FT_LOCAL_DEF( void )
   cf2_getFamilyOtherBlues( CFF_Decoder*  decoder,
                            size_t*       count,
-                           CF2_Fixed*   *data )
+                           FT_Pos*      *data )
   {
     FT_ASSERT( decoder && decoder->current_subfont );
 
     *count = decoder->current_subfont->private_dict.num_family_other_blues;
-    *data  = (CF2_Fixed*)
+    *data  = (FT_Pos*)
                &decoder->current_subfont->private_dict.family_other_blues;
   }
 
--- a/src/cff/cf2ft.h
+++ b/src/cff/cf2ft.h
@@ -80,19 +80,19 @@
   FT_LOCAL( void )
   cf2_getBlueValues( CFF_Decoder*  decoder,
                      size_t*       count,
-                     CF2_Fixed*   *data );
+                     FT_Pos*      *data );
   FT_LOCAL( void )
   cf2_getOtherBlues( CFF_Decoder*  decoder,
                      size_t*       count,
-                     CF2_Fixed*   *data );
+                     FT_Pos*      *data );
   FT_LOCAL( void )
   cf2_getFamilyBlues( CFF_Decoder*  decoder,
                       size_t*       count,
-                      CF2_Fixed*   *data );
+                      FT_Pos*      *data );
   FT_LOCAL( void )
   cf2_getFamilyOtherBlues( CFF_Decoder*  decoder,
                            size_t*       count,
-                           CF2_Fixed*   *data );
+                           FT_Pos*      *data );
 
   FT_LOCAL( CF2_Int )
   cf2_getLanguageGroup( CFF_Decoder*  decoder );