freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-cleaned 1111d75 12/36: [psaux] Objects for new inte


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-cleaned 1111d75 12/36: [psaux] Objects for new interpreter (part 2)
Date: Wed, 9 Aug 2017 21:36:08 -0400 (EDT)

branch: ewaldhew-cleaned
commit 1111d755904128dea2b13a276a18b42ffe74898c
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    [psaux] Objects for new interpreter (part 2)
    
    Make the new objects copy over values. They are essentially wrapper types
    for the different decoders/builders.
    
    * include/freetype/internal/psaux.h: Update declarations.
    Add is_t1 flag to PS_Builder.
    * src/psaux/psdecode.h, src/psaux/psobjs.h: Update declarations.
    
    * src/psaux/psdecode.c, src/psaux/psobjs.c: Implement copy with two modes.
    
    * src/psaux/psauxmod.c: Add builder and decoder functions to PSAux service.
---
 include/freetype/internal/psaux.h | 60 +++++++++++++---------------
 src/psaux/psauxmod.c              | 10 +++++
 src/psaux/psdecode.c              | 83 +++++++++++++++++++++++++++------------
 src/psaux/psdecode.h              | 11 +++++-
 src/psaux/psobjs.c                | 61 +++++++++++++++++++++++++---
 src/psaux/psobjs.h                |  8 ++--
 6 files changed, 164 insertions(+), 69 deletions(-)

diff --git a/include/freetype/internal/psaux.h 
b/include/freetype/internal/psaux.h
index 43ea776..3361b97 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -457,14 +457,12 @@ FT_BEGIN_HEADER
   typedef struct  PS_Builder_FuncsRec_
   {
     void
-    (*init)( PS_Builder    builder,
-             FT_Face       face,
-             FT_Size       size,
-             FT_GlyphSlot  slot,
-             FT_Bool       hinting );
+    (*init)( void*        builder,
+             FT_Bool      is_t1,
+             PS_Builder*  ps_builder );
 
     void
-    (*done)( PS_Builder   builder );
+    (*done)( PS_Builder*   builder );
 
   } PS_Builder_FuncsRec;
 
@@ -521,13 +519,13 @@ FT_BEGIN_HEADER
     FT_Outline*     base;
     FT_Outline*     current;
 
-    FT_Pos          pos_x;
-    FT_Pos          pos_y;
+    FT_Pos*         pos_x;
+    FT_Pos*         pos_y;
 
-    FT_Vector       left_bearing;
-    FT_Vector       advance;
+    FT_Vector*      left_bearing;
+    FT_Vector*      advance;
 
-    FT_BBox         bbox;          /* bounding box */
+    FT_BBox*        bbox;          /* bounding box */
     FT_Bool         path_begun;
     FT_Bool         load_points;
     FT_Bool         no_recurse;
@@ -537,6 +535,8 @@ FT_BEGIN_HEADER
     void*           hints_funcs;    /* hinter-specific */
     void*           hints_globals;  /* hinter-specific */
 
+    FT_Bool         is_t1;
+
     PS_Builder_FuncsRec  funcs;
 
   };
@@ -570,15 +570,16 @@ FT_BEGIN_HEADER
 
 
   typedef FT_Error
-  (*PS_Decoder_Get_Glyph_Callback)( TT_Face    face,
-                                    FT_UInt    glyph_index,
-                                    FT_Byte**  pointer,
-                                    FT_ULong*  length );
+  (*CFF_Decoder_Get_Glyph_Callback)( TT_Face    face,
+                                     FT_UInt    glyph_index,
+                                     FT_Byte**  pointer,
+                                     FT_ULong*  length );
 
   typedef void
-  (*PS_Decoder_Free_Glyph_Callback)( TT_Face    face,
-                                     FT_Byte**  pointer,
-                                     FT_ULong   length );
+  (*CFF_Decoder_Free_Glyph_Callback)( TT_Face    face,
+                                      FT_Byte**  pointer,
+                                      FT_ULong   length );
+
 
   typedef struct  PS_Decoder_
   {
@@ -620,8 +621,8 @@ FT_BEGIN_HEADER
 
     FT_Bool            seac;
 
-    PS_Decoder_Get_Glyph_Callback   get_glyph_callback;
-    PS_Decoder_Free_Glyph_Callback  free_glyph_callback;
+    CFF_Decoder_Get_Glyph_Callback   get_glyph_callback;
+    CFF_Decoder_Free_Glyph_Callback  free_glyph_callback;
     
     /* Type 1 stuff */
     FT_Service_PsCMaps   psnames;      /* for seac */
@@ -638,6 +639,8 @@ FT_BEGIN_HEADER
     FT_Long*             buildchar;
     FT_UInt              len_buildchar;
 
+    void*                t1_parse_callback;
+
   } PS_Decoder;
 
 
@@ -1069,18 +1072,6 @@ 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;
@@ -1268,6 +1259,11 @@ FT_BEGIN_HEADER
     FT_UInt32
     (*cff_random)( FT_UInt32  r );
 
+    void
+    (*ps_decoder_init)( void*        decoder,
+                        FT_Bool      is_t1,
+                        PS_Decoder*  ps_decoder );
+
 
     T1_CMap_Classes  t1_cmap_classes;
 
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index eb94d54..d7223e2 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -23,6 +23,7 @@
 #include "t1cmap.h"
 #include "psft.h"
 #include "cffdecode.h"
+#include "psdecode.h"
 
 #ifndef T1_CONFIG_OPTION_NO_AFM
 #include "afmparse.h"
@@ -62,6 +63,14 @@
 
 
   FT_CALLBACK_TABLE_DEF
+  const PS_Builder_FuncsRec  ps_builder_funcs =
+  {
+    ps_builder_init,          /* init */
+    ps_builder_done           /* done */
+  };
+
+
+  FT_CALLBACK_TABLE_DEF
   const T1_Builder_FuncsRec  t1_builder_funcs =
   {
     t1_builder_init,          /* init */
@@ -144,6 +153,7 @@
     &t1_decoder_funcs,
     t1_decrypt,
     cff_random,
+    ps_decoder_init,
 
     (const T1_CMap_ClassesRec*) &t1_cmap_classes,
 
diff --git a/src/psaux/psdecode.c b/src/psaux/psdecode.c
index 7003425..86b4286 100644
--- a/src/psaux/psdecode.c
+++ b/src/psaux/psdecode.c
@@ -2,7 +2,6 @@
 
 #include <ft2build.h>
 #include FT_INTERNAL_SERVICE_H
-#include FT_SERVICE_CFF_TABLE_LOAD_H
 
 #include "psdecode.h"
 #include "psobjs.h"
@@ -16,42 +15,76 @@
   /*    ps_decoder_init                                                    */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    Initializes a given glyph decoder.                                 */
+  /*    Creates a decoder for the combined Type 1 / CFF interpreter.       */
   /*                                                                       */
   /* <InOut>                                                               */
   /*    decoder :: A pointer to the glyph builder to initialize.           */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    face      :: The current face object.                              */
   /*                                                                       */
-  /*    size      :: The current size object.                              */
   /*                                                                       */
-  /*    slot      :: The current glyph object.                             */
   /*                                                                       */
-  /*    hinting   :: Whether hinting is active.                            */
   /*                                                                       */
-  /*    hint_mode :: The hinting mode.                                     */
   /*                                                                       */
   FT_LOCAL_DEF( void )
-  ps_decoder_init( PS_Decoder*     decoder,
-                   TT_Face         face,
-                   FT_Size         size,
-                   CFF_GlyphSlot   slot,
-                   FT_Byte**       glyph_names,
-                   PS_Blend        blend,
-                   FT_Bool         hinting,
-                   FT_Render_Mode  hint_mode,
-                   PS_Decoder_Get_Glyph_Callback   get_callback,
-                   PS_Decoder_Free_Glyph_Callback  free_callback )
+  ps_decoder_init( void*        decoder,
+                   FT_Bool      is_t1,
+                   PS_Decoder*  ps_decoder )
   {
-  }
+    FT_ZERO( ps_decoder );
 
+    if ( is_t1 )
+    {
+      T1_Decoder  t1_decoder = (T1_Decoder)decoder;
 
-  /* this function is used to select the subfont */
-  /* and the locals subrs array                  */
-  FT_LOCAL_DEF( FT_Error )
-  ps_decoder_prepare( PS_Decoder*  decoder,
-                      FT_Size      size,
-                      FT_UInt      glyph_index )
-  {
+      ps_builder_init( &t1_decoder->builder,
+                       is_t1,
+                       &ps_decoder->builder );
+
+      ps_decoder->psnames            =  t1_decoder->psnames;
+
+      ps_decoder->num_glyphs         =  t1_decoder->num_glyphs;
+      ps_decoder->glyph_names        =  t1_decoder->glyph_names;
+      ps_decoder->hint_mode          =  t1_decoder->hint_mode;
+      ps_decoder->blend              =  t1_decoder->blend;
+      /* ps_decoder->t1_parse_callback  =  t1_decoder->parse_callback; */
+
+      ps_decoder->num_locals         =  t1_decoder->num_subrs;
+      ps_decoder->locals             =  t1_decoder->subrs;
+      ps_decoder->locals_len         =  t1_decoder->subrs_len;
+      ps_decoder->locals_hash        =  t1_decoder->subrs_hash;
+
+      ps_decoder->buildchar          =  t1_decoder->buildchar;
+      ps_decoder->len_buildchar      =  t1_decoder->len_buildchar;
+
+      ps_decoder->lenIV              =  t1_decoder->lenIV;
+    }
+    else
+    {
+      CFF_Decoder*  cff_decoder = (CFF_Decoder*)decoder;
+
+      ps_builder_init( &cff_decoder->builder,
+                       is_t1,
+                       &ps_decoder->builder );
+
+      ps_decoder->cff                 =  cff_decoder->cff;
+      ps_decoder->current_subfont     =  cff_decoder->current_subfont;
+
+      ps_decoder->num_globals         =  cff_decoder->num_globals;
+      ps_decoder->globals             =  cff_decoder->globals;
+      ps_decoder->globals_bias        =  cff_decoder->globals_bias;
+      ps_decoder->num_locals          =  cff_decoder->num_locals;
+      ps_decoder->locals              =  cff_decoder->locals;
+      ps_decoder->locals_bias         =  cff_decoder->locals_bias;
+
+      ps_decoder->glyph_width         =  cff_decoder->glyph_width;
+      ps_decoder->nominal_width       =  cff_decoder->nominal_width;
+      ps_decoder->width_only          =  cff_decoder->width_only;
+
+      ps_decoder->hint_mode           =  cff_decoder->hint_mode;
+
+      ps_decoder->get_glyph_callback  =  cff_decoder->get_glyph_callback;
+      ps_decoder->free_glyph_callback =  cff_decoder->free_glyph_callback;
+    }
   }
+
diff --git a/src/psaux/psdecode.h b/src/psaux/psdecode.h
index 2a53065..dd7e6f2 100644
--- a/src/psaux/psdecode.h
+++ b/src/psaux/psdecode.h
@@ -5,9 +5,16 @@
 #include <ft2build.h>
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 
-#include "cffdecode.h"
-#include "t1decode.h"
 
+FT_BEGIN_HEADER
 
+  FT_LOCAL( void )
+  ps_decoder_init( void*        decoder,
+                   FT_Bool      is_t1,
+                   PS_Decoder*  ps_decoder );
+
+
+FT_END_HEADER
 
 #endif
+
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 815bca3..a4dd448 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -2052,12 +2052,63 @@
   /*    hinting :: Whether hinting should be applied.                      */
   /*                                                                       */
   FT_LOCAL_DEF( void )
-  ps_builder_init( PS_Builder*    builder,
-                   TT_Face        face,
-                   FT_Size        size,
-                   CFF_GlyphSlot  glyph,
-                   FT_Bool        hinting )
+  ps_builder_init( void*        builder,
+                   FT_Bool      is_t1,
+                   PS_Builder*  ps_builder )
   {
+    FT_ZERO( ps_builder );
+
+    if ( is_t1 )
+    {
+      T1_Builder  t1builder = (T1_Builder)builder;
+
+      ps_builder->face           = (TT_Face)t1builder->face;
+      ps_builder->glyph          = t1builder->glyph;
+      ps_builder->memory         =  t1builder->memory;
+      ps_builder->loader         =  t1builder->loader;
+      ps_builder->base           =  t1builder->base;
+      ps_builder->current        =  t1builder->current;
+
+      ps_builder->pos_x          = &t1builder->pos_x;
+      ps_builder->pos_y          = &t1builder->pos_y;
+
+      ps_builder->left_bearing   = &t1builder->left_bearing;
+      ps_builder->advance        = &t1builder->advance;
+
+      ps_builder->bbox           = &t1builder->bbox;
+      ps_builder->path_begun     =  0;
+      ps_builder->load_points    =  t1builder->load_points;
+      ps_builder->no_recurse     =  t1builder->no_recurse;
+
+      ps_builder->metrics_only   =  t1builder->metrics_only;
+    }
+    else
+    {
+      CFF_Builder*  cffbuilder = (CFF_Builder*)builder;
+
+      ps_builder->face           = cffbuilder->face;
+      ps_builder->memory         =  cffbuilder->memory;
+      ps_builder->glyph          =  cffbuilder->glyph;
+      ps_builder->loader         =  cffbuilder->loader;
+      ps_builder->base           =  cffbuilder->base;
+      ps_builder->current        =  cffbuilder->current;
+
+      ps_builder->pos_x          = &cffbuilder->pos_x;
+      ps_builder->pos_y          = &cffbuilder->pos_y;
+
+      ps_builder->left_bearing   = &cffbuilder->left_bearing;
+      ps_builder->advance        = &cffbuilder->advance;
+
+      ps_builder->bbox           = &cffbuilder->bbox;
+      ps_builder->path_begun     =  cffbuilder->path_begun;
+      ps_builder->load_points    =  cffbuilder->load_points;
+      ps_builder->no_recurse     =  cffbuilder->no_recurse;
+
+      ps_builder->metrics_only   =  cffbuilder->metrics_only;
+    }
+
+    ps_builder->is_t1            = is_t1;
+    ps_builder->funcs            = ps_builder_funcs;
   }
 
 
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index 64e85c5..1f68419 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -242,11 +242,9 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
   FT_LOCAL( void )
-  ps_builder_init( PS_Builder*    builder,
-                   TT_Face        face,
-                   FT_Size        size,
-                   CFF_GlyphSlot  glyph,
-                   FT_Bool        hinting );
+  ps_builder_init( void*        builder,
+                   FT_Bool      is_t1,
+                   PS_Builder*  ps_builder );
 
   FT_LOCAL( void )
   ps_builder_done( PS_Builder*  builder );



reply via email to

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