freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master ff0ef828c 10/30: * src/type42/t42drivr.c: Clean up in


From: Werner Lemberg
Subject: [freetype2] master ff0ef828c 10/30: * src/type42/t42drivr.c: Clean up interface.
Date: Mon, 8 May 2023 01:31:46 -0400 (EDT)

branch: master
commit ff0ef828c98d8fab816de3a22de288be4f249304
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>

    * src/type42/t42drivr.c: Clean up interface.
    
    Ensure that all driver functions use the signature of the service or driver.
    This avoids pointer mismatches, which are technically undefined behaviour.
    Recent compilers are more picky in catching them as part of Control Flow
    Integrity tests.
---
 src/type42/t42drivr.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c
index ce1528e5d..ee5fd44a9 100644
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -56,33 +56,41 @@
    *
    */
 
-  static FT_Error
-  t42_get_glyph_name( T42_Face    face,
+  FT_CALLBACK_DEF( FT_Error )
+  t42_get_glyph_name( FT_Face     face,        /* T42_Face */
                       FT_UInt     glyph_index,
                       FT_Pointer  buffer,
                       FT_UInt     buffer_max )
   {
-    FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
+    T42_Face  t42face = (T42_Face)face;
+
+
+    FT_STRCPYN( buffer,
+                t42face->type1.glyph_names[glyph_index],
+                buffer_max );
 
     return FT_Err_Ok;
   }
 
 
-  static FT_UInt
-  t42_get_name_index( T42_Face          face,
+  FT_CALLBACK_DEF( FT_UInt )
+  t42_get_name_index( FT_Face           face,        /* T42_Face */
                       const FT_String*  glyph_name )
   {
-    FT_Int  i;
+    T42_Face  t42face = (T42_Face)face;
+    FT_Int    i;
 
 
-    for ( i = 0; i < face->type1.num_glyphs; i++ )
+    for ( i = 0; i < t42face->type1.num_glyphs; i++ )
     {
-      FT_String*  gname = face->type1.glyph_names[i];
+      FT_String*  gname = t42face->type1.glyph_names[i];
 
 
       if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
-        return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i],
-                                   NULL, 10 );
+        return (FT_UInt)ft_strtol(
+                          (const char *)t42face->type1.charstrings[i],
+                          NULL,
+                          10 );
     }
 
     return 0;
@@ -102,10 +110,13 @@
    *
    */
 
-  static const char*
-  t42_get_ps_font_name( T42_Face  face )
+  FT_CALLBACK_DEF( const char* )
+  t42_get_ps_font_name( FT_Face  face )    /* T42_Face */
   {
-    return (const char*)face->type1.font_name;
+    T42_Face  t42face = (T42_Face)face;
+
+
+    return (const char*)t42face->type1.font_name;
   }
 
 
@@ -121,7 +132,7 @@
    *
    */
 
-  static FT_Error
+  FT_CALLBACK_DEF( FT_Error )
   t42_ps_get_font_info( FT_Face          face,
                         PS_FontInfoRec*  afont_info )
   {
@@ -131,7 +142,7 @@
   }
 
 
-  static FT_Error
+  FT_CALLBACK_DEF( FT_Error )
   t42_ps_get_font_extra( FT_Face           face,
                          PS_FontExtraRec*  afont_extra )
   {
@@ -141,7 +152,7 @@
   }
 
 
-  static FT_Int
+  FT_CALLBACK_DEF( FT_Int )
   t42_ps_has_glyph_names( FT_Face  face )
   {
     FT_UNUSED( face );



reply via email to

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