shithub: freetype+ttf2subf

Download patch

ref: 7aeee3c50f2656b65f7dc207aa2020bb1398da98
parent: 3e79254ae73ba4e5f951967b42d38b0aa1460af8
author: Werner Lemberg <[email protected]>
date: Sat Mar 18 13:30:42 EDT 2017

Introduce FT_UINT_TO_POINTER macro (#50560).

We have to make a separate case for Windows 64's LLP64 data model.

* builds/unix/ftconfig.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro.

* src/truetype/ttgload.c (load_truetype_glyph): Use it.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2017-03-18  Werner Lemberg  <[email protected]>
 
+	Introduce FT_UINT_TO_POINTER macro (#50560).
+
+	We have to make a separate case for Windows 64's LLP64 data model.
+
+	* builds/unix/ftconfig.in, builds/vms/ftconfig.h,
+	include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro.
+
+	* src/truetype/ttgload.c (load_truetype_glyph): Use it.
+
+2017-03-18  Werner Lemberg  <[email protected]>
+
 	* src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#50573).
 
 	The problematic font that exceeds the old limit is Lato-Regular,
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -365,6 +365,15 @@
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -306,6 +306,15 @@
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -333,6 +333,15 @@
 #endif
 
 
+#ifdef _WIN64
+  /* only 64bit Windows uses the LLP64 data model, i.e., */
+  /* 32bit integers, 64bit pointers                      */
+#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x)
+#else
+#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
+#endif
+
+
   /*************************************************************************/
   /*                                                                       */
   /* miscellaneous                                                         */
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1711,7 +1711,7 @@
 
       /* check whether we already have a composite glyph with this index */
       if ( FT_List_Find( &loader->composites,
-                         (void*)(unsigned long)glyph_index ) )
+                         FT_UINT_TO_POINTER( glyph_index ) ) )
       {
         FT_TRACE1(( "TT_Load_Composite_Glyph:"
                     " infinite recursion detected\n" ));
@@ -1720,13 +1720,13 @@
       }
 
       else if ( node )
-        node->data = (void*)(unsigned long)glyph_index;
+        node->data = FT_UINT_TO_POINTER( glyph_index );
 
       else
       {
         if ( FT_NEW( node ) )
           goto Exit;
-        node->data = (void*)(unsigned long)glyph_index;
+        node->data = FT_UINT_TO_POINTER( glyph_index );
         FT_List_Add( &loader->composites, node );
       }