freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-wip 07131fb 05/29: [psaux, cff] Add callbacks for i


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-wip 07131fb 05/29: [psaux, cff] Add callbacks for inter-module calls.
Date: Mon, 26 Jun 2017 01:55:02 -0400 (EDT)

branch: ewaldhew-wip
commit 07131fb25356afd89ca172aa21cc444174c2b685
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    [psaux, cff] Add callbacks for inter-module calls.
    
    NOTE: Does not compile!
    
    * include/freetype/internal/psaux.h: Add function pointer declarations.
    
    * src/psaux/cffdecode.c (cff_decoder_init): Updated to take in callbacks.
    * src/psaux/cffdecode.h: Ditto.
    
    * src/cff/cffgload.c (cff_compute_max_advance, cff_slot_load): Update calls 
to pass in callbacks.
    * src/psaux/cf2ft.c, src/psaux/cffdecode.c: Use them.
---
 include/freetype/internal/psaux.h | 19 ++++++++++++++++++-
 src/cff/cffgload.c                |  6 ++++--
 src/psaux/cf2ft.c                 | 14 +++++++-------
 src/psaux/cffdecode.c             | 19 ++++++++++++-------
 src/psaux/cffdecode.h             |  4 +++-
 5 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/include/freetype/internal/psaux.h 
b/include/freetype/internal/psaux.h
index 47f62ac..a786113 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -868,6 +868,18 @@ FT_BEGIN_HEADER
   } CFF_Decoder_Zone;
 
 
+  typedef FT_Error
+  (*CFF_Decoder_Get_Glyph_Callback)( TT_Face    face,
+                                     FT_UInt    glyph_index,
+                                     FT_Byte**  pointer,
+                                     FT_ULong*  length );
+
+  typedef void
+  (*CFF_Decoder_Free_Glyph_Callback)( TT_Face    face,
+                                      FT_Byte**  pointer,
+                                      FT_ULong   length );
+
+
   typedef struct  CFF_Decoder_
   {
     CFF_Builder        builder;
@@ -909,6 +921,9 @@ FT_BEGIN_HEADER
 
     CFF_SubFont        current_subfont; /* for current glyph_index */
 
+    CFF_Decoder_Get_Glyph_Callback   get_glyph_callback;
+    CFF_Decoder_Free_Glyph_Callback  free_glyph_callback;
+
   } CFF_Decoder;
 
   typedef const struct CFF_Decoder_FuncsRec_*  CFF_Decoder_Funcs;
@@ -921,7 +936,9 @@ FT_BEGIN_HEADER
              CFF_Size        size,
              CFF_GlyphSlot   slot,
              FT_Bool         hinting,
-             FT_Render_Mode  hint_mode );
+             FT_Render_Mode  hint_mode,
+             CFF_Decoder_Get_Glyph_Callback   get_callback,
+             CFF_Decoder_Free_Glyph_Callback  free_callback );
 
     FT_Error
     (*prepare)( CFF_Decoder*  decoder,
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index b30902d..e9c2826 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -149,7 +149,7 @@
     *max_advance = 0;
 
     /* Initialize load decoder */
-    decoder_funcs->init( &decoder, face, 0, 0, 0, 0 );
+    decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 );
 
     decoder.builder.metrics_only = 1;
     decoder.builder.load_points  = 0;
@@ -404,7 +404,9 @@
 
 
       decoder_funcs->init( &decoder, face, size, glyph, hinting,
-                           FT_LOAD_TARGET_MODE( load_flags ) );
+                           FT_LOAD_TARGET_MODE( load_flags ),
+                           cff_get_glyph_data,
+                           cff_free_glyph_data );
 
       /* this is for pure CFFs */
       if ( load_flags & FT_LOAD_ADVANCE_ONLY )
diff --git a/src/psaux/cf2ft.c b/src/psaux/cf2ft.c
index c6c00d1..169e116 100644
--- a/src/psaux/cf2ft.c
+++ b/src/psaux/cf2ft.c
@@ -647,10 +647,10 @@
         return FT_THROW( Invalid_Glyph_Format );
     }
 
-    error = cff_get_glyph_data( decoder->builder.face,
-                                (CF2_UInt)gid,
-                                &charstring,
-                                &len );
+    error = decoder->get_glyph_callback( decoder->builder.face,
+                                         (CF2_UInt)gid,
+                                         &charstring,
+                                         &len );
     /* TODO: for now, just pass the FreeType error through */
     if ( error )
       return error;
@@ -672,9 +672,9 @@
   {
     FT_ASSERT( decoder );
 
-    cff_free_glyph_data( decoder->builder.face,
-                         (FT_Byte**)&buf->start,
-                         (FT_ULong)( buf->end - buf->start ) );
+    decoder->free_glyph_callback( decoder->builder.face,
+                                  (FT_Byte**)&buf->start,
+                                  (FT_ULong)( buf->end - buf->start ) );
   }
 
 
diff --git a/src/psaux/cffdecode.c b/src/psaux/cffdecode.c
index e1af544..baa318b 100644
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -272,8 +272,8 @@
     FT_GlyphLoader_Prepare( builder->loader );
 
     /* First load `bchar' in builder */
-    error = cff_get_glyph_data( face, (FT_UInt)bchar_index,
-                                &charstring, &charstring_len );
+    error = decoder->get_glyph_callback( face, (FT_UInt)bchar_index,
+                                         &charstring, &charstring_len );
     if ( !error )
     {
       /* the seac operator must not be nested */
@@ -282,7 +282,7 @@
                                              charstring_len, 0 );
       decoder->seac = FALSE;
 
-      cff_free_glyph_data( face, &charstring, charstring_len );
+      decoder->free_glyph_callback( face, &charstring, charstring_len );
 
       if ( error )
         goto Exit;
@@ -302,8 +302,8 @@
     builder->pos_y = ady;
 
     /* Now load `achar' on top of the base outline. */
-    error = cff_get_glyph_data( face, (FT_UInt)achar_index,
-                                &charstring, &charstring_len );
+    error = decoder->get_glyph_callback( face, (FT_UInt)achar_index,
+                                         &charstring, &charstring_len );
     if ( !error )
     {
       /* the seac operator must not be nested */
@@ -312,7 +312,7 @@
                                              charstring_len, 0 );
       decoder->seac = FALSE;
 
-      cff_free_glyph_data( face, &charstring, charstring_len );
+      decoder->free_glyph_callback( face, &charstring, charstring_len );
 
       if ( error )
         goto Exit;
@@ -2231,7 +2231,9 @@
                     CFF_Size        size,
                     CFF_GlyphSlot   slot,
                     FT_Bool         hinting,
-                    FT_Render_Mode  hint_mode )
+                    FT_Render_Mode  hint_mode,
+                    CFF_Decoder_Get_Glyph_Callback   get_callback,
+                    CFF_Decoder_Free_Glyph_Callback  free_callback )
   {
     CFF_Font  cff = (CFF_Font)face->extra.data;
 
@@ -2251,6 +2253,9 @@
                               decoder->num_globals );
 
     decoder->hint_mode    = hint_mode;
+
+    decoder->get_glyph_callback  = get_callback;
+    decoder->free_glyph_callback = free_callback;
   }
 
 
diff --git a/src/psaux/cffdecode.h b/src/psaux/cffdecode.h
index a464127..e708040 100644
--- a/src/psaux/cffdecode.h
+++ b/src/psaux/cffdecode.h
@@ -14,7 +14,9 @@ FT_BEGIN_HEADER
                     CFF_Size        size,
                     CFF_GlyphSlot   slot,
                     FT_Bool         hinting,
-                    FT_Render_Mode  hint_mode);
+                    FT_Render_Mode  hint_mode,
+                    CFF_Decoder_Get_Glyph_Callback   get_callback,
+                    CFF_Decoder_Free_Glyph_Callback  free_callback);
 
   FT_LOCAL( FT_Error )
   cff_decoder_prepare( CFF_Decoder*  decoder,



reply via email to

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