freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2017-ewaldhew 3c20490 19/42: [psaux] Add missing object


From: Hew Yih Shiuan Ewald
Subject: [freetype2] GSoC-2017-ewaldhew 3c20490 19/42: [psaux] Add missing objects for Type 1. (1/2)
Date: Sun, 27 Aug 2017 20:33:19 -0400 (EDT)

branch: GSoC-2017-ewaldhew
commit 3c20490ae4db82ed22b4f7139581bfe924439fed
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    [psaux] Add missing objects for Type 1. (1/2)
    
    Move CF2_Font instance to PS_Decoder. This is the context for the 
interpreter
    and since it is currently stored in CFF_Font, is unavailable in Type 1 mode.
    
    * include/freetype/internal/psaux.h (T1_Decoder, PS_Decoder): Add the
    cf2_instance field.
    
    * src/psaux/psdecode.c (ps_decoder_init): Copy cf2_instance to PS_Decoder.
    Remove unused line.
    * src/psaux/t1decode.c (t1_decoder_done): Add finalization code.
    
    * src/psaux/psft.c: Update accesses.
---
 include/freetype/internal/psaux.h |  7 +++++--
 src/psaux/psdecode.c              |  3 ++-
 src/psaux/psft.c                  | 10 +++++-----
 src/psaux/t1decode.c              |  8 ++++++++
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/freetype/internal/psaux.h 
b/include/freetype/internal/psaux.h
index a8469f7..b28392b 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -610,7 +610,8 @@ FT_BEGIN_HEADER
 
     CFF_Font           cff;
     CFF_SubFont        current_subfont; /* for current glyph_index */
-    
+    FT_Generic*        cf2_instance;
+
     FT_Pos             glyph_width;
     FT_Pos             nominal_width;
 
@@ -636,7 +637,7 @@ FT_BEGIN_HEADER
 
     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 */
 
@@ -924,6 +925,8 @@ FT_BEGIN_HEADER
 
     FT_Bool              seac;
 
+    FT_Generic           cf2_instance;
+
   } T1_DecoderRec;
 
   /*************************************************************************/
diff --git a/src/psaux/psdecode.c b/src/psaux/psdecode.c
index 86b4286..c8a5d01 100644
--- a/src/psaux/psdecode.c
+++ b/src/psaux/psdecode.c
@@ -41,13 +41,13 @@
                        is_t1,
                        &ps_decoder->builder );
 
+      ps_decoder->cf2_instance       = &t1_decoder->cf2_instance;
       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;
@@ -68,6 +68,7 @@
                        &ps_decoder->builder );
 
       ps_decoder->cff                 =  cff_decoder->cff;
+      ps_decoder->cf2_instance        = &cff_decoder->cff->cf2_instance;
       ps_decoder->current_subfont     =  cff_decoder->current_subfont;
 
       ps_decoder->num_globals         =  cff_decoder->num_globals;
diff --git a/src/psaux/psft.c b/src/psaux/psft.c
index c91fedd..ab19826 100644
--- a/src/psaux/psft.c
+++ b/src/psaux/psft.c
@@ -318,19 +318,19 @@
     memory = decoder->builder.memory;
 
     /* CF2 data is saved here across glyphs */
-    font = (CF2_Font)decoder->cff->cf2_instance.data;
+    font = (CF2_Font)decoder->cf2_instance->data;
 
     /* on first glyph, allocate instance structure */
-    if ( !decoder->cff->cf2_instance.data )
+    if ( !decoder->cf2_instance->data )
     {
-      decoder->cff->cf2_instance.finalizer =
+      decoder->cf2_instance->finalizer =
         (FT_Generic_Finalizer)cf2_free_instance;
 
-      if ( FT_ALLOC( decoder->cff->cf2_instance.data,
+      if ( FT_ALLOC( decoder->cf2_instance->data,
                      sizeof ( CF2_FontRec ) ) )
         return FT_THROW( Out_Of_Memory );
 
-      font = (CF2_Font)decoder->cff->cf2_instance.data;
+      font = (CF2_Font)decoder->cf2_instance->data;
 
       font->memory = memory;
 
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 1250b53..81f5797 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -1641,7 +1641,15 @@
   FT_LOCAL_DEF( void )
   t1_decoder_done( T1_Decoder  decoder )
   {
+    FT_Memory  memory = decoder->builder.memory;
+
     t1_builder_done( &decoder->builder );
+
+    if ( decoder->cf2_instance.finalizer )
+    {
+      decoder->cf2_instance.finalizer( decoder->cf2_instance.data );
+      FT_FREE( decoder->cf2_instance.data );
+    }
   }
 
 



reply via email to

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