freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-refactor-cf2 c60dd2d 3/3: Added func ptrs for cff g


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-refactor-cf2 c60dd2d 3/3: Added func ptrs for cff get/free glyph_data (callback)
Date: Tue, 30 May 2017 04:34:14 -0400 (EDT)

branch: ewaldhew-refactor-cf2
commit c60dd2d5aaf6e01e3898e044945253e6de010cc7
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    Added func ptrs for cff get/free glyph_data (callback)
---
 include/freetype/internal/psaux.h | 24 +++++++++++++++++++++---
 src/cff/cffgload.c                |  9 ++++++---
 src/cff/cffgload.h                |  1 -
 src/cff/cffparse.c                | 15 ++++++++++-----
 src/psaux/cf2ft.c                 | 15 +++++++--------
 src/psaux/cffdecode.c             | 19 ++++++++++++-------
 src/psaux/psauxmod.c              |  2 +-
 src/psaux/psobjs.c                |  3 +--
 8 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/include/freetype/internal/psaux.h 
b/include/freetype/internal/psaux.h
index e0b7694..7118bf3 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -712,7 +712,8 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
 
-#if 0
+#if 1
+  //TODO(ewaldhew): use these in cf2_interp
   typedef FT_Error
   (*CFF_Builder_Check_Points_Func)( CFF_Builder*  builder,
                                     FT_Int        count );
@@ -833,7 +834,7 @@ FT_BEGIN_HEADER
     void*           hints_funcs;    /* hinter-specific */
     void*           hints_globals;  /* hinter-specific */
 
-    //CFF_Builder_FuncsRec  funcs;
+    CFF_Builder_FuncsRec  funcs;
 
   } CFF_Builder;
 
@@ -866,6 +867,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;
@@ -907,6 +920,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;
@@ -919,7 +935,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 4f27c17..799db9a 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -20,6 +20,7 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_SFNT_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
 #include FT_OUTLINE_H
 #include FT_CFF_DRIVER_H
 
@@ -40,7 +41,7 @@
 #define FT_COMPONENT  trace_cffgload
 
 
-FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( FT_Error )
   cff_get_glyph_data( TT_Face    face,
                       FT_UInt    glyph_index,
                       FT_Byte**  pointer,
@@ -147,7 +148,7 @@ FT_LOCAL_DEF( FT_Error )
     *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;
@@ -402,7 +403,9 @@ FT_LOCAL_DEF( FT_Error )
 
 
       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/cff/cffgload.h b/src/cff/cffgload.h
index 61ab6a4..b2e945d 100644
--- a/src/cff/cffgload.h
+++ b/src/cff/cffgload.h
@@ -27,7 +27,6 @@
 
 FT_BEGIN_HEADER
 
-//TODO(ewaldhew): these need to be func ptr too
   FT_LOCAL( FT_Error )
   cff_get_glyph_data( TT_Face    face,
                       FT_UInt    glyph_index,
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index e1511bd..cc237b0 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -20,10 +20,10 @@
 #include "cffparse.h"
 #include FT_INTERNAL_STREAM_H
 #include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
 
 #include "cfferrs.h"
 #include "cffpic.h"
-#include "cffgload.h"
 #include "cffload.h"
 
 
@@ -1279,6 +1279,7 @@
     FT_Library  library = parser->library;
     FT_UNUSED( library );
 
+    
 
     parser->top    = parser->stack;
     parser->start  = start;
@@ -1363,10 +1364,14 @@
         cff_rec.top_font.font_dict.num_axes    = parser->num_axes;
         decoder.cff                            = &cff_rec;
 
-        error = cff_decoder_parse_charstrings( &decoder,
-                                               charstring_base,
-                                               charstring_len,
-                                               1 );
+        /* TODO(ewaldhew): link this
+        PSAux_Service            psaux         = cff->psaux;
+        const CFF_Decoder_Funcs  decoder_funcs = psaux->cff_decoder_funcs;
+        */
+        error = decoder_funcs->parse_charstrings( &decoder,
+                                                  charstring_base,
+                                                  charstring_len,
+                                                  1 );
 
         /* Now copy the stack data in the temporary decoder object,    */
         /* converting it back to charstring number representations     */
diff --git a/src/psaux/cf2ft.c b/src/psaux/cf2ft.c
index 751a9fe..c414bc8 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,10 +672,9 @@
   {
     FT_ASSERT( decoder );
 
-    //TODO(ewaldhew): needs to use func ptr too
-    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 e6b54db..9ae2ba2 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;
@@ -2197,7 +2197,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;
 
@@ -2217,6 +2219,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/psauxmod.c b/src/psaux/psauxmod.c
index 17f7888..a37ac74 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -105,7 +105,7 @@
     &t1_cmap_unicode_class_rec
   };
 
-#if 0
+#if 1
   FT_CALLBACK_TABLE_DEF
   const CFF_Builder_FuncsRec  cff_builder_funcs =
   {
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 5e3e375..37ea6fe 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1836,8 +1836,7 @@
     builder->advance.x      = 0;
     builder->advance.y      = 0;
 
-    //TODO(ewaldhew): what is this even used for? (ref t1_builder_funcs)
-    //builder->funcs = cff_builder_funcs;
+    builder->funcs = cff_builder_funcs;
   }
 
 



reply via email to

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