diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-06-20 01:56:21 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-06-20 01:56:21 +0000 |
commit | bbda1cc717797ba68eb2eda0dd18205ea4413009 (patch) | |
tree | 2ab54b718e2475169b65b58818934da04c602e36 /Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c | |
parent | ff31ae48b941d2911b213d6fcf6043bfecf803ef (diff) |
freetype2 2.8.0
git-svn-id: svn://tug.org/texlive/trunk@44650 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c')
-rw-r--r-- | Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c | 117 |
1 files changed, 64 insertions, 53 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c index 926effc5236..61613933ff7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,6 +27,11 @@ #include FT_INTERNAL_SFNT_H #include FT_CFF_DRIVER_H +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#endif + #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" @@ -49,9 +54,6 @@ /* */ /* SIZE FUNCTIONS */ /* */ - /* Note that we store the global hints in the size's `internal' root */ - /* field. */ - /* */ /*************************************************************************/ @@ -75,10 +77,11 @@ FT_LOCAL_DEF( void ) cff_size_done( FT_Size cffsize ) /* CFF_Size */ { + FT_Memory memory = cffsize->face->memory; CFF_Size size = (CFF_Size)cffsize; CFF_Face face = (CFF_Face)size->root.face; CFF_Font font = (CFF_Font)face->extra.data; - CFF_Internal internal = (CFF_Internal)cffsize->internal; + CFF_Internal internal = (CFF_Internal)cffsize->internal->module_data; if ( internal ) @@ -98,7 +101,7 @@ funcs->destroy( internal->subfonts[i - 1] ); } - /* `internal' is freed by destroy_size (in ftobjs.c) */ + FT_FREE( internal ); } } @@ -194,7 +197,7 @@ goto Exit; } - cffsize->internal = (FT_Size_Internal)(void*)internal; + cffsize->internal->module_data = internal; } size->strike_index = 0xFFFFFFFFUL; @@ -224,7 +227,7 @@ { CFF_Face face = (CFF_Face)size->face; CFF_Font font = (CFF_Font)face->extra.data; - CFF_Internal internal = (CFF_Internal)size->internal; + CFF_Internal internal = (CFF_Internal)size->internal->module_data; FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; FT_UInt i; @@ -296,7 +299,7 @@ { CFF_Face cffface = (CFF_Face)size->face; CFF_Font font = (CFF_Font)cffface->extra.data; - CFF_Internal internal = (CFF_Internal)size->internal; + CFF_Internal internal = (CFF_Internal)size->internal->module_data; FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; FT_UInt i; @@ -517,6 +520,7 @@ goto Exit; /* check whether we have a valid OpenType file */ + FT_TRACE2(( " " )); error = sfnt->init_face( stream, face, face_index, num_params, params ); if ( !error ) { @@ -559,8 +563,8 @@ error = face->goto_table( face, TTAG_CFF2, stream, 0 ); if ( !error ) { - cff2 = 1; - face->isCFF2 = cff2; + cff2 = 1; + face->is_cff2 = cff2; } if ( FT_ERR_EQ( error, Table_Missing ) ) @@ -594,6 +598,7 @@ stream, face_index, cff, + face, pure_cff, cff2 ); if ( error ) @@ -683,62 +688,56 @@ } #endif /* FT_DEBUG_LEVEL_TRACE */ - - #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - - { - FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; - - FT_Int instance_index = face_index >> 16; - - - if ( FT_HAS_MULTIPLE_MASTERS( cffface ) && - mm && - instance_index > 0 ) { - FT_MM_Var* mm_var; - + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; - error = mm->get_mm_var( cffface, NULL ); - if ( error ) - goto Exit; + FT_Int instance_index = face_index >> 16; - mm->get_var_blend( cffface, NULL, NULL, &mm_var ); - if ( mm_var->namedstyle ) + if ( FT_HAS_MULTIPLE_MASTERS( cffface ) && + mm && + instance_index > 0 ) { - FT_Var_Named_Style* named_style; - FT_String* style_name; + FT_MM_Var* mm_var; - /* in `face_index', the instance index starts with value 1 */ - named_style = mm_var->namedstyle + instance_index - 1; - error = sfnt->get_name( face, - (FT_UShort)named_style->strid, - &style_name ); + error = mm->get_mm_var( cffface, NULL ); if ( error ) goto Exit; - /* set style name; if already set, replace it */ - if ( face->root.style_name ) - FT_FREE( face->root.style_name ); - face->root.style_name = style_name; + mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var ); - /* finally, select the named instance */ - error = mm->set_var_design( cffface, - mm_var->num_axis, - named_style->coords ); - if ( error ) - goto Exit; + if ( mm_var->namedstyle ) + { + FT_Var_Named_Style* named_style; + FT_String* style_name; + + + /* in `face_index', the instance index starts with value 1 */ + named_style = mm_var->namedstyle + instance_index - 1; + error = sfnt->get_name( face, + (FT_UShort)named_style->strid, + &style_name ); + if ( error ) + goto Exit; + + /* set style name; if already set, replace it */ + if ( face->root.style_name ) + FT_FREE( face->root.style_name ); + face->root.style_name = style_name; + + /* finally, select the named instance */ + error = mm->set_var_design( cffface, + mm_var->num_axis, + named_style->coords ); + if ( error ) + goto Exit; + } } } - } - #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ - - if ( !dict->has_font_matrix ) dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM; @@ -1021,7 +1020,6 @@ cffface->style_flags = flags; } - #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */ /* has unset this flag because of the 3.0 `post' table. */ @@ -1032,7 +1030,6 @@ if ( dict->cid_registry != 0xFFFFU && pure_cff ) cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; - /*******************************************************************/ /* */ /* Compute char maps. */ @@ -1164,6 +1161,8 @@ { CFF_Driver driver = (CFF_Driver)module; + FT_UInt32 seed; + /* set default property values, cf. `ftcffdrv.h' */ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE @@ -1183,6 +1182,18 @@ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4; driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4; + /* compute random seed from some memory addresses */ + seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&module ^ + (FT_Offset)(char*)module->memory ); + seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 ); + + driver->random_seed = (FT_Int32)seed; + if ( driver->random_seed < 0 ) + driver->random_seed = -driver->random_seed; + else if ( driver->random_seed == 0 ) + driver->random_seed = 123456789; + return FT_Err_Ok; } |