?? t1load.c
字號:
parse_blend_design_positions( T1_Face face, T1_Loader loader ) { T1_TokenRec design_tokens[ T1_MAX_MM_DESIGNS ]; FT_Int num_designs; FT_Int num_axis; T1_Parser parser = &loader->parser; FT_Error error = 0; PS_Blend blend; /* get the array of design tokens - compute number of designs */ T1_ToTokenArray( parser, design_tokens, T1_MAX_MM_DESIGNS, &num_designs ); if ( num_designs <= 0 || num_designs > T1_MAX_MM_DESIGNS ) { FT_ERROR(( "parse_blend_design_positions:" )); FT_ERROR(( " incorrect number of designs: %d\n", num_designs )); error = T1_Err_Invalid_File_Format; goto Exit; } { FT_Byte* old_cursor = parser->root.cursor; FT_Byte* old_limit = parser->root.limit; FT_UInt n; blend = face->blend; num_axis = 0; /* make compiler happy */ for ( n = 0; n < (FT_UInt)num_designs; n++ ) { T1_TokenRec axis_tokens[ T1_MAX_MM_DESIGNS ]; T1_Token token; FT_Int axis, n_axis; /* read axis/coordinates tokens */ token = design_tokens + n; parser->root.cursor = token->start - 1; parser->root.limit = token->limit + 1; T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis ); if ( n == 0 ) { num_axis = n_axis; error = t1_allocate_blend( face, num_designs, num_axis ); if ( error ) goto Exit; blend = face->blend; } else if ( n_axis != num_axis ) { FT_ERROR(( "parse_blend_design_positions: incorrect table\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } /* now, read each axis token into the design position */ for ( axis = 0; axis < n_axis; axis++ ) { T1_Token token2 = axis_tokens + axis; parser->root.cursor = token2->start; parser->root.limit = token2->limit; blend->design_pos[n][axis] = T1_ToFixed( parser, 0 ); } } loader->parser.root.cursor = old_cursor; loader->parser.root.limit = old_limit; } Exit: loader->parser.root.error = error; } static void parse_blend_design_map( T1_Face face, T1_Loader loader ) { FT_Error error = 0; T1_Parser parser = &loader->parser; PS_Blend blend; T1_TokenRec axis_tokens[T1_MAX_MM_AXIS]; FT_Int n, num_axis; FT_Byte* old_cursor; FT_Byte* old_limit; FT_Memory memory = face->root.memory; T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &num_axis ); if ( num_axis <= 0 || num_axis > T1_MAX_MM_AXIS ) { FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n", num_axis )); error = T1_Err_Invalid_File_Format; goto Exit; } old_cursor = parser->root.cursor; old_limit = parser->root.limit; error = t1_allocate_blend( face, 0, num_axis ); if ( error ) goto Exit; blend = face->blend; /* now, read each axis design map */ for ( n = 0; n < num_axis; n++ ) { PS_DesignMap map = blend->design_map + n; T1_Token token; FT_Int p, num_points; token = axis_tokens + n; parser->root.cursor = token->start; parser->root.limit = token->limit; /* count the number of map points */ { FT_Byte* ptr = token->start; FT_Byte* limit = token->limit; num_points = 0; for ( ; ptr < limit; ptr++ ) if ( ptr[0] == '[' ) num_points++; } if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS ) { FT_ERROR(( "parse_blend_design_map: incorrect table\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } /* allocate design map data */ if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) ) goto Exit; map->blend_points = map->design_points + num_points; map->num_points = (FT_Byte)num_points; for ( p = 0; p < num_points; p++ ) { map->design_points[p] = T1_ToInt( parser ); map->blend_points [p] = T1_ToFixed( parser, 0 ); } } parser->root.cursor = old_cursor; parser->root.limit = old_limit; Exit: parser->root.error = error; } static void parse_weight_vector( T1_Face face, T1_Loader loader ) { FT_Error error = 0; T1_Parser parser = &loader->parser; PS_Blend blend = face->blend; T1_TokenRec master; FT_UInt n; FT_Byte* old_cursor; FT_Byte* old_limit; if ( !blend || blend->num_designs == 0 ) { FT_ERROR(( "parse_weight_vector: too early!\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } T1_ToToken( parser, &master ); if ( master.type != T1_TOKEN_TYPE_ARRAY ) { FT_ERROR(( "parse_weight_vector: incorrect format!\n" )); error = T1_Err_Invalid_File_Format; goto Exit; } old_cursor = parser->root.cursor; old_limit = parser->root.limit; parser->root.cursor = master.start; parser->root.limit = master.limit; for ( n = 0; n < blend->num_designs; n++ ) { blend->default_weight_vector[n] = blend->weight_vector[n] = T1_ToFixed( parser, 0 ); } parser->root.cursor = old_cursor; parser->root.limit = old_limit; Exit: parser->root.error = error; } /* the keyword `/shareddict' appears in some multiple master fonts */ /* with a lot of Postscript garbage behind it (that's completely out */ /* of spec!); we detect it and terminate the parsing */ /* */ static void parse_shared_dict( T1_Face face, T1_Loader loader ) { T1_Parser parser = &loader->parser; FT_UNUSED( face ); parser->root.cursor = parser->root.limit; parser->root.error = 0; }#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */ /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE 1 SYMBOL PARSING *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* First of all, define the token field static variables. This is a set */ /* of T1_FieldRec variables used later. */ /* */ /*************************************************************************/ static FT_Error t1_load_keyword( T1_Face face, T1_Loader loader, T1_Field field ) { FT_Error error; void* dummy_object; void** objects; FT_UInt max_objects; PS_Blend blend = face->blend; /* if the keyword has a dedicated callback, call it */ if ( field->type == T1_FIELD_TYPE_CALLBACK ) { field->reader( (FT_Face)face, loader ); error = loader->parser.root.error; goto Exit; } /* now, the keyword is either a simple field, or a table of fields; */ /* we are now going to take care of it */ switch ( field->location ) { case T1_FIELD_LOCATION_FONT_INFO: dummy_object = &face->type1.font_info; objects = &dummy_object; max_objects = 0; if ( blend ) { objects = (void**)blend->font_infos; max_objects = blend->num_designs; } break; case T1_FIELD_LOCATION_PRIVATE: dummy_object = &face->type1.private_dict; objects = &dummy_object; max_objects = 0; if ( blend ) { objects = (void**)blend->privates; max_objects = blend->num_designs; } break; default: dummy_object = &face->type1; objects = &dummy_object; max_objects = 0; } if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY || field->type == T1_FIELD_TYPE_FIXED_ARRAY ) error = T1_Load_Field_Table( &loader->parser, field, objects, max_objects, 0 ); else error = T1_Load_Field( &loader->parser, field, objects, max_objects, 0 ); Exit: return error; } static int is_space( FT_Byte c ) { return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' ); } static int is_alpha( FT_Byte c ) { /* Note: we must accept "+" as a valid character, as it is used in */ /* embedded type1 fonts in PDF documents. */ /* */ return ( ft_isalnum( c ) || c == '.' || c == '_' || c == '-' || c == '+' ); } static int read_binary_data( T1_Parser parser, FT_Int* size, FT_Byte** base ) { FT_Byte* cur; FT_Byte* limit = parser->root.limit; /* the binary data has the following format */ /* */ /* `size' [white*] RD white ....... ND */ /* */ T1_Skip_Spaces( parser ); cur = parser->root.cursor; if ( cur < limit && (FT_Byte)( *cur - '0' ) < 10 ) { *size = T1_ToInt( parser ); T1_Skip_Spaces( parser ); T1_Skip_Alpha ( parser ); /* `RD' or `-|' or something else */ /* there is only one whitespace char after the */ /* `RD' or `-|' token */ *base = parser->root.cursor + 1; parser->root.cursor += *size + 1; return 1; } FT_ERROR(( "read_binary_data: invalid size field\n" )); parser->root.error = T1_Err_Invalid_File_Format; return 0; } /* we will now define the routines used to handle */ /* the `/Encoding', `/Subrs', and `/CharStrings' */ /* dictionaries */ static void parse_font_name( T1_Face face, T1_Loader loader ) { T1_Parser parser = &loader->parser; FT_Error error; FT_Memory memory = parser->root.memory; FT_Int len; FT_Byte* cur; FT_Byte* cur2; FT_Byte* limit; if ( face->type1.font_name ) /* with synthetic fonts, it's possible we get here twice */ return; T1_Skip_Spaces( parser ); cur = parser->root.cursor; limit = parser->root.limit; if ( cur >= limit - 1 || *cur != '/' ) return; cur++; cur2 = cur; while ( cur2 < limit && is_alpha( *cur2 ) ) cur2++; len = (FT_Int)( cur2 - cur ); if ( len > 0 ) { if ( FT_ALLOC( face->type1.font_name, len + 1 ) ) { parser->root.error = error; return; } FT_MEM_COPY( face->type1.font_name, cur, len ); face->type1.font_name[len] = '\0'; } parser->root.cursor = cur2; } static void parse_font_bbox( T1_Face face, T1_Loader loader ) { T1_Parser parser = &loader->parser; FT_Fixed temp[4]; FT_BBox* bbox = &face->type1.font_bbox; (void)T1_ToFixedArray( parser, 4, temp, 0 ); bbox->xMin = FT_RoundFix( temp[0] ); bbox->yMin = FT_RoundFix( temp[1] ); bbox->xMax = FT_RoundFix( temp[2] ); bbox->yMax = FT_RoundFix( temp[3] ); } static void parse_font_matrix( T1_Face face,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -