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): New `cf2_instance' field. * src/psaux/psdecode.c (ps_decoder_init): Copy `cf2_instance' to `PS_Decoder'. * src/psaux/t1decode.c (t1_decoder_done): Add finalization code. * src/psaux/psft.c (cf2_decoder_parse_charstrings): Update accesses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
diff --git a/ChangeLog b/ChangeLog
index ef1290e..620f84c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+ [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): New
+ `cf2_instance' field.
+
+ * src/psaux/psdecode.c (ps_decoder_init): Copy `cf2_instance' to
+ `PS_Decoder'.
+
+ * src/psaux/t1decode.c (t1_decoder_done): Add finalization code.
+
+ * src/psaux/psft.c (cf2_decoder_parse_charstrings): Update accesses.
+
+2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+
Allow `type1' module to use the Adobe engine.
Add the callback and some conditionals to switch between the two
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 );
+ }
}