?? ttgload.c
字號:
FT_Byte* flag = (FT_Byte*)outline->tags; FT_Pos x = 0; for ( ; vec < limit; vec++, flag++ ) { FT_Pos y = 0; if ( *flag & 2 ) { y = FT_GET_BYTE(); if ( ( *flag & 16 ) == 0 ) y = -y; } else if ( ( *flag & 16 ) == 0 ) y = FT_GET_SHORT(); x += y; vec->x = x; } } /* reading the Y coordinates */ { FT_Vector* vec = gloader->current.outline.points; FT_Vector* limit = vec + n_points; FT_Byte* flag = (FT_Byte*)outline->tags; FT_Pos x = 0; for ( ; vec < limit; vec++, flag++ ) { FT_Pos y = 0; if ( *flag & 4 ) { y = FT_GET_BYTE(); if ( ( *flag & 32 ) == 0 ) y = -y; } else if ( ( *flag & 32 ) == 0 ) y = FT_GET_SHORT(); x += y; vec->y = x; } } /* clear the touch tags */ for ( n = 0; n < n_points; n++ ) outline->tags[n] &= FT_Curve_Tag_On; outline->n_points = (FT_UShort)n_points; outline->n_contours = (FT_Short) n_contours; load->byte_len = byte_len; Fail: return error; Invalid_Outline: error = TT_Err_Invalid_Outline; goto Fail; } FT_CALLBACK_DEF( FT_Error ) TT_Load_Composite_Glyph( TT_Loader loader ) { FT_Error error; FT_Stream stream = loader->stream; FT_GlyphLoader gloader = loader->gloader; FT_SubGlyph subglyph; FT_UInt num_subglyphs; FT_Int byte_len = loader->byte_len; num_subglyphs = 0; do { FT_Fixed xx, xy, yy, yx; /* check that we can load a new subglyph */ error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 ); if ( error ) goto Fail; /* check space */ byte_len -= 4; if ( byte_len < 0 ) goto Invalid_Composite; subglyph = gloader->current.subglyphs + num_subglyphs; subglyph->arg1 = subglyph->arg2 = 0; subglyph->flags = FT_GET_USHORT(); subglyph->index = FT_GET_USHORT(); /* check space */ byte_len -= 2; if ( subglyph->flags & ARGS_ARE_WORDS ) byte_len -= 2; if ( subglyph->flags & WE_HAVE_A_SCALE ) byte_len -= 2; else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) byte_len -= 4; else if ( subglyph->flags & WE_HAVE_A_2X2 ) byte_len -= 8; if ( byte_len < 0 ) goto Invalid_Composite; /* read arguments */ if ( subglyph->flags & ARGS_ARE_WORDS ) { subglyph->arg1 = FT_GET_SHORT(); subglyph->arg2 = FT_GET_SHORT(); } else { subglyph->arg1 = FT_GET_CHAR(); subglyph->arg2 = FT_GET_CHAR(); } /* read transform */ xx = yy = 0x10000L; xy = yx = 0; if ( subglyph->flags & WE_HAVE_A_SCALE ) { xx = (FT_Fixed)FT_GET_SHORT() << 2; yy = xx; } else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE ) { xx = (FT_Fixed)FT_GET_SHORT() << 2; yy = (FT_Fixed)FT_GET_SHORT() << 2; } else if ( subglyph->flags & WE_HAVE_A_2X2 ) { xx = (FT_Fixed)FT_GET_SHORT() << 2; xy = (FT_Fixed)FT_GET_SHORT() << 2; yx = (FT_Fixed)FT_GET_SHORT() << 2; yy = (FT_Fixed)FT_GET_SHORT() << 2; } subglyph->transform.xx = xx; subglyph->transform.xy = xy; subglyph->transform.yx = yx; subglyph->transform.yy = yy; num_subglyphs++; } while ( subglyph->flags & MORE_COMPONENTS ); gloader->current.num_subglyphs = num_subglyphs;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER { /* we must undo the FT_FRAME_ENTER in order to point to the */ /* composite instructions, if we find some. */ /* we will process them later... */ /* */ loader->ins_pos = (FT_ULong)( FT_STREAM_POS() + stream->cursor - stream->limit ); }#endif loader->byte_len = byte_len; Fail: return error; Invalid_Composite: error = TT_Err_Invalid_Composite; goto Fail; } FT_LOCAL_DEF( void ) TT_Init_Glyph_Loading( TT_Face face ) { face->access_glyph_frame = TT_Access_Glyph_Frame; face->read_glyph_header = TT_Load_Glyph_Header; face->read_simple_glyph = TT_Load_Simple_Glyph; face->read_composite_glyph = TT_Load_Composite_Glyph; face->forget_glyph_frame = TT_Forget_Glyph_Frame; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Process_Simple_Glyph */ /* */ /* <Description> */ /* Once a simple glyph has been loaded, it needs to be processed. */ /* Usually, this means scaling and hinting through bytecode */ /* interpretation. */ /* */ static FT_Error TT_Process_Simple_Glyph( TT_Loader load, FT_Bool debug ) { FT_GlyphLoader gloader = load->gloader; FT_Outline* outline = &gloader->current.outline; FT_UInt n_points = outline->n_points;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER FT_UInt n_ins;#endif TT_GlyphZone zone = &load->zone; FT_Error error = TT_Err_Ok; FT_UNUSED( debug ); /* used by truetype interpreter only */#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER n_ins = load->glyph->control_len;#endif /* add shadow points */ /* Now add the two shadow points at n and n + 1. */ /* We need the left side bearing and advance width. */ { FT_Vector* pp1; FT_Vector* pp2; /* pp1 = xMin - lsb */ pp1 = outline->points + n_points; pp1->x = load->bbox.xMin - load->left_bearing; pp1->y = 0; /* pp2 = pp1 + aw */ pp2 = pp1 + 1; pp2->x = pp1->x + load->advance; pp2->y = 0; outline->tags[n_points ] = 0; outline->tags[n_points + 1] = 0; } /* Note that we return two more points that are not */ /* part of the glyph outline. */ n_points += 2; /* set up zone for hinting */ tt_prepare_zone( zone, &gloader->current, 0, 0 ); /* eventually scale the glyph */ if ( !( load->load_flags & FT_LOAD_NO_SCALE ) ) { FT_Vector* vec = zone->cur; FT_Vector* limit = vec + n_points; FT_Fixed x_scale = load->size->metrics.x_scale; FT_Fixed y_scale = load->size->metrics.y_scale; /* first scale the glyph points */ for ( ; vec < limit; vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } } cur_to_org( n_points, zone ); /* eventually hint the glyph */ if ( IS_HINTED( load->load_flags ) ) { FT_Pos x = zone->org[n_points-2].x; x = ( ( x + 32 ) & -64 ) - x; translate_array( n_points, zone->org, x, 0 ); org_to_cur( n_points, zone ); zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER /* now consider hinting */ if ( n_ins > 0 ) { error = TT_Set_CodeRange( load->exec, tt_coderange_glyph, load->exec->glyphIns, n_ins ); if ( error ) goto Exit; load->exec->is_composite = FALSE; load->exec->pedantic_hinting = (FT_Bool)( load->load_flags & FT_LOAD_PEDANTIC ); load->exec->pts = *zone; load->exec->pts.n_points += 2; error = TT_Run_Context( load->exec, debug ); if ( error && load->exec->pedantic_hinting ) goto Exit; error = TT_Err_Ok; /* ignore bytecode errors in non-pedantic mode */ }#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ } /* save glyph phantom points */ if ( !load->preserve_pps ) { load->pp1 = zone->cur[n_points - 2]; load->pp2 = zone->cur[n_points - 1]; }#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER Exit:#endif return error; } /*************************************************************************/ /* */ /* <Function> */ /* load_truetype_glyph */ /* */ /* <Description> */ /* Loads a given truetype glyph. Handles composites and uses a */ /* TT_Loader object. */ /* */ static FT_Error load_truetype_glyph( TT_Loader loader, FT_UInt glyph_index ) {#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER FT_Stream stream = loader->stream;#endif FT_Error error; TT_Face face = (TT_Face)loader->face; FT_ULong offset; FT_Int contours_count; FT_UInt idx, num_points, count; FT_Fixed x_scale, y_scale; FT_GlyphLoader gloader = loader->gloader; FT_Bool opened_frame = 0; /* check glyph index */ idx = glyph_index; if ( idx >= (FT_UInt)face->root.num_glyphs ) { error = TT_Err_Invalid_Glyph_Index; goto Exit; } loader->glyph_index = glyph_index; num_points = 0; x_scale = 0x10000L; y_scale = 0x10000L; if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { x_scale = loader->size->metrics.x_scale; y_scale = loader->size->metrics.y_scale; } /* get horizontal metrics */ { FT_Short left_bearing; FT_UShort advance_width; Get_HMetrics( face, idx, (FT_Bool)!( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ), &left_bearing, &advance_width ); loader->left_bearing = left_bearing; loader->advance = advance_width; if ( !loader->linear_def ) { loader->linear_def = 1; loader->linear = advance_width; } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -