📄 t1decode.c
字号:
break; case op_seac: /* return immediately after the processing */ return t1operator_seac( decoder, top[0], top[1], top[2], top[3], top[4] ); case op_sbw: FT_TRACE4(( " sbw" )); builder->left_bearing.x += top[0]; builder->left_bearing.y += top[1]; builder->advance.x = top[2]; builder->advance.y = top[3]; builder->last.x = x = builder->pos_x + top[0]; builder->last.y = y = builder->pos_y + top[1]; /* the `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) return PSaux_Err_Ok; break; case op_closepath: FT_TRACE4(( " closepath" )); close_contour( builder ); builder->path_begun = 0; break; case op_hlineto: FT_TRACE4(( " hlineto" )); if ( start_point( builder, x, y ) ) goto Memory_Error; x += top[0]; goto Add_Line; case op_hmoveto: FT_TRACE4(( " hmoveto" )); x += top[0]; if ( !decoder->flex_state ) builder->path_begun = 0; break; case op_hvcurveto: FT_TRACE4(( " hvcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Memory_Error; x += top[0]; add_point( builder, x, y, 0 ); x += top[1]; y += top[2]; add_point( builder, x, y, 0 ); y += top[3]; add_point( builder, x, y, 1 ); break; case op_rlineto: FT_TRACE4(( " rlineto" )); if ( start_point( builder, x, y ) ) goto Memory_Error; x += top[0]; y += top[1]; Add_Line: if ( add_point1( builder, x, y ) ) goto Memory_Error; break; case op_rmoveto: FT_TRACE4(( " rmoveto" )); x += top[0]; y += top[1]; if ( !decoder->flex_state ) builder->path_begun = 0; break; case op_rrcurveto: FT_TRACE4(( " rcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Memory_Error; x += top[0]; y += top[1]; add_point( builder, x, y, 0 ); x += top[2]; y += top[3]; add_point( builder, x, y, 0 ); x += top[4]; y += top[5]; add_point( builder, x, y, 1 ); break; case op_vhcurveto: FT_TRACE4(( " vhcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Memory_Error; y += top[0]; add_point( builder, x, y, 0 ); x += top[1]; y += top[2]; add_point( builder, x, y, 0 ); x += top[3]; add_point( builder, x, y, 1 ); break; case op_vlineto: FT_TRACE4(( " vlineto" )); if ( start_point( builder, x, y ) ) goto Memory_Error; y += top[0]; goto Add_Line; case op_vmoveto: FT_TRACE4(( " vmoveto" )); y += top[0]; if ( !decoder->flex_state ) builder->path_begun = 0; break; case op_div: FT_TRACE4(( " div" )); if ( top[1] ) { *top = top[0] / top[1]; ++top; } else { FT_ERROR(( "T1_Decoder_Parse_CharStrings: division by 0\n" )); goto Syntax_Error; } break; case op_callsubr: { FT_Int index; FT_TRACE4(( " callsubr" )); index = top[0]; if ( index < 0 || index >= (FT_Int)decoder->num_subrs ) { FT_ERROR(( "T1_Decoder_Parse_CharStrings: " "invalid subrs index\n" )); goto Syntax_Error; } if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) { FT_ERROR(( "T1_Decoder_Parse_CharStrings: " "too many nested subrs\n" )); goto Syntax_Error; } zone->cursor = ip; /* save current instruction pointer */ zone++; /* The Type 1 driver stores subroutines without the seed bytes. */ /* The CID driver stores subroutines with seed bytes. This */ /* case is taken care of when decoder->subrs_len == 0. */ zone->base = decoder->subrs[index]; if ( decoder->subrs_len ) zone->limit = zone->base + decoder->subrs_len[index]; else { /* We are using subroutines from a CID font. We must adjust */ /* for the seed bytes. */ zone->base += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); zone->limit = decoder->subrs[index + 1]; } zone->cursor = zone->base; if ( !zone->base ) { FT_ERROR(( "T1_Decoder_Parse_CharStrings: " "invoking empty subrs!\n" )); goto Syntax_Error; } decoder->zone = zone; ip = zone->base; limit = zone->limit; break; } case op_pop: FT_TRACE4(( " pop" )); /* theoretically, the arguments are already on the stack */ top++; break; case op_return: FT_TRACE4(( " return" )); if ( zone <= decoder->zones ) { FT_ERROR(( "T1_Decoder_Parse_CharStrings: unexpected return\n" )); goto Syntax_Error; } zone--; ip = zone->cursor; limit = zone->limit; decoder->zone = zone; break; case op_dotsection: FT_TRACE4(( " dotsection" )); break; case op_hstem: FT_TRACE4(( " hstem" )); /* record horizontal hint */ if ( hinter ) { /* top[0] += builder->left_bearing.y; */ hinter->stem( hinter->hints, 1, top ); } break; case op_hstem3: FT_TRACE4(( " hstem3" )); /* record horizontal counter-controlled hints */ if ( hinter ) hinter->stem3( hinter->hints, 1, top ); break; case op_vstem: FT_TRACE4(( " vstem" )); /* record vertical hint */ if ( hinter ) { top[0] += orig_x; hinter->stem( hinter->hints, 0, top ); } break; case op_vstem3: FT_TRACE4(( " vstem3" )); /* record vertical counter-controlled hints */ if ( hinter ) { FT_Pos dx = orig_x; top[0] += dx; top[2] += dx; top[4] += dx; hinter->stem3( hinter->hints, 0, top ); } break; case op_setcurrentpoint: FT_TRACE4(( " setcurrentpoint" )); FT_ERROR(( "T1_Decoder_Parse_CharStrings: " )); FT_ERROR(( "unexpected `setcurrentpoint'\n" )); goto Syntax_Error; default: FT_ERROR(( "T1_Decoder_Parse_CharStrings: " "unhandled opcode %d\n", op )); goto Syntax_Error; } decoder->top = top; } /* general operator processing */ } /* while ip < limit */ FT_TRACE4(( "..end..\n\n" )); return error; Syntax_Error: return PSaux_Err_Syntax_Error; Stack_Underflow: return PSaux_Err_Stack_Underflow; Memory_Error: return builder->error; } /* parse a single Type 1 glyph */ FT_LOCAL_DEF FT_Error T1_Decoder_Parse_Glyph( T1_Decoder* decoder, FT_UInt glyph ) { return decoder->parse_callback( decoder, glyph ); } /* initialise T1 decoder */ FT_LOCAL_DEF FT_Error T1_Decoder_Init( T1_Decoder* decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, T1_Blend* blend, FT_Bool hinting, T1_Decoder_Callback parse_callback ) { MEM_Set( decoder, 0, sizeof ( *decoder ) ); /* retrieve PSNames interface from list of current modules */ { PSNames_Interface* psnames = 0; psnames = (PSNames_Interface*)FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psnames" ); if ( !psnames ) { FT_ERROR(( "T1_Decoder_Init: " )); FT_ERROR(( "the `psnames' module is not available\n" )); return PSaux_Err_Unimplemented_Feature; } decoder->psnames = psnames; } T1_Builder_Init( &decoder->builder, face, size, slot, hinting ); decoder->num_glyphs = face->num_glyphs; decoder->glyph_names = glyph_names; decoder->blend = blend; decoder->parse_callback = parse_callback; decoder->funcs = t1_decoder_funcs; return 0; } /* finalize T1 decoder */ FT_LOCAL_DEF void T1_Decoder_Done( T1_Decoder* decoder ) { T1_Builder_Done( &decoder->builder ); }/* END */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -