freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 2f4b740: Fix invalid function pointer casts.


From: Werner LEMBERG
Subject: [freetype2] master 2f4b740: Fix invalid function pointer casts.
Date: Thu, 7 Mar 2019 03:43:47 -0500 (EST)

branch: master
commit 2f4b740ce435bc1ad5ef8570bb91ab7cd5682720
Author: Andrei Alexeyev <address@hidden>
Commit: Werner Lemberg <address@hidden>

    Fix invalid function pointer casts.
    
    This change should allow Freetype to work on WASM/Emscripten without
    needing `-s EMULATE_FUNCTION_POINTER_CASTS=1'.
    
    * src/autofit/afdummy.c (af_dummy_hints_apply): Fix signature.
    
    * src/cid/cidload.c (cid_parse_font_matrix, parse_fd_array,
    parse_expansion_factor, parse_font_name): Return `void', not
    `FT_Error'.
    
    * include/freetype/internal/ftobjs.h (FT_CMap_CharVarIsDefaultFunc):
    Fix signature.
---
 ChangeLog                          | 17 +++++++++++++++++
 include/freetype/internal/ftobjs.h |  2 +-
 src/autofit/afdummy.c              |  8 +++++---
 src/cid/cidload.c                  | 27 +++++++++++++++------------
 4 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae2d132..5172696 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2019-03-07  Andrei Alexeyev  <address@hidden>
+            Werner Lemberg  <address@hidden>
+
+       Fix invalid function pointer casts.
+
+       This change should allow Freetype to work on WASM/Emscripten without
+       needing `-s EMULATE_FUNCTION_POINTER_CASTS=1'.
+
+       * src/autofit/afdummy.c (af_dummy_hints_apply): Fix signature.
+
+       * src/cid/cidload.c (cid_parse_font_matrix, parse_fd_array,
+       parse_expansion_factor, parse_font_name): Return `void', not
+       `FT_Error'.
+
+       * include/freetype/internal/ftobjs.h (FT_CMap_CharVarIsDefaultFunc):
+       Fix signature.
+
 2019-03-05  Werner Lemberg  <address@hidden>
 
        [base] Handle numeric overflow (#55827).
diff --git a/include/freetype/internal/ftobjs.h 
b/include/freetype/internal/ftobjs.h
index 9b94a5d..f3a41b3 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -185,7 +185,7 @@ FT_BEGIN_HEADER
                                FT_UInt32  char_code,
                                FT_UInt32  variant_selector );
 
-  typedef FT_Bool
+  typedef FT_Int
   (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap    cmap,
                                    FT_UInt32  char_code,
                                    FT_UInt32  variant_selector );
diff --git a/src/autofit/afdummy.c b/src/autofit/afdummy.c
index 6dd98d9..7e07a41 100644
--- a/src/autofit/afdummy.c
+++ b/src/autofit/afdummy.c
@@ -38,13 +38,15 @@
 
 
   static FT_Error
-  af_dummy_hints_apply( FT_UInt        glyph_index,
-                        AF_GlyphHints  hints,
-                        FT_Outline*    outline )
+  af_dummy_hints_apply( FT_UInt          glyph_index,
+                        AF_GlyphHints    hints,
+                        FT_Outline*      outline,
+                        AF_StyleMetrics  metrics )
   {
     FT_Error  error;
 
     FT_UNUSED( glyph_index );
+    FT_UNUSED( metrics );
 
 
     error = af_glyph_hints_reload( hints, outline );
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index e94fb33..fce3e37 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -154,7 +154,7 @@
   }
 
 
-  FT_CALLBACK_DEF( FT_Error )
+  FT_CALLBACK_DEF( void )
   cid_parse_font_matrix( CID_Face     face,
                          CID_Parser*  parser )
   {
@@ -179,7 +179,10 @@
       result = cid_parser_to_fixed_array( parser, 6, temp, 3 );
 
       if ( result < 6 )
-        return FT_THROW( Invalid_File_Format );
+      {
+        FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" ));
+        goto Exit;
+      }
 
       FT_TRACE4(( " [%f %f %f %f %f %f]\n",
                   (double)temp[0] / 65536 / 1000,
@@ -194,7 +197,7 @@
       if ( temp_scale == 0 )
       {
         FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
-        return FT_THROW( Invalid_File_Format );
+        goto Exit;
       }
 
       /* atypical case */
@@ -220,7 +223,7 @@
       {
         FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
         parser->root.error = FT_THROW( Invalid_File_Format );
-        return FT_THROW( Invalid_File_Format );
+        goto Exit;
       }
 
       /* note that the font offsets are expressed in integer font units */
@@ -228,11 +231,12 @@
       offset->y  = temp[5] >> 16;
     }
 
-    return FT_Err_Ok;
+  Exit:
+    return;
   }
 
 
-  FT_CALLBACK_DEF( FT_Error )
+  FT_CALLBACK_DEF( void )
   parse_fd_array( CID_Face     face,
                   CID_Parser*  parser )
   {
@@ -247,7 +251,6 @@
     if ( num_dicts < 0 )
     {
       FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
-      error = FT_THROW( Invalid_File_Format );
       goto Exit;
     }
 
@@ -304,7 +307,7 @@
     }
 
   Exit:
-    return error;
+    return;
   }
 
 
@@ -312,7 +315,7 @@
   /* and CID_FaceDictRec (both are public header files and can't  */
   /* changed).  We simply copy the value.                         */
 
-  FT_CALLBACK_DEF( FT_Error )
+  FT_CALLBACK_DEF( void )
   parse_expansion_factor( CID_Face     face,
                           CID_Parser*  parser )
   {
@@ -329,7 +332,7 @@
       FT_TRACE4(( "%d\n", dict->expansion_factor ));
     }
 
-    return FT_Err_Ok;
+    return;
   }
 
 
@@ -337,7 +340,7 @@
   /* `FontName' keyword.  FreeType doesn't need it, but it is nice */
   /* to catch it for producing better trace output.                */
 
-  FT_CALLBACK_DEF( FT_Error )
+  FT_CALLBACK_DEF( void )
   parse_font_name( CID_Face     face,
                    CID_Parser*  parser )
   {
@@ -361,7 +364,7 @@
     FT_UNUSED( parser );
 #endif
 
-    return FT_Err_Ok;
+    return;
   }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]