From cb3f4c610d7f724731466eac78e667865f13d178 Mon Sep 17 00:00:00 2001 From: Ewald Hew Date: Mon, 25 Sep 2017 06:44:51 +0200 Subject: [PATCH] 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. --- ChangeLog | 18 ++++++++++++++++++ include/freetype/internal/psaux.h | 7 +++++-- src/psaux/psdecode.c | 3 ++- src/psaux/psft.c | 10 +++++----- src/psaux/t1decode.c | 8 ++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef1290ecc..620f84c7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2017-09-25 Ewald Hew + + [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 Allow `type1' module to use the Adobe engine. diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h index a8469f722..b28392bed 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 86b42863f..c8a5d01c2 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 c91fedd28..ab1982663 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 1250b53f5..81f579744 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 ); + } }