📄 ttload.c
字号:
os2->ulCodePageRange2 = 0; if ( os2->version >= 0x0001 ) { /* only version 1 tables */#ifdef READ_FIELDS if ( READ_Fields( os2_fields_extra, os2 ) ) goto Exit;#else if ( ACCESS_Frame( 8L ) ) /* read into frame */ goto Exit; os2->ulCodePageRange1 = GET_ULong(); os2->ulCodePageRange2 = GET_ULong(); FORGET_Frame();#endif } FT_TRACE2(( "loaded\n" )); Exit: return error; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_Postscript */ /* */ /* <Description> */ /* Loads the Postscript table. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* stream :: A handle to the input stream. */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ LOCAL_FUNC TT_Error TT_Load_PostScript( TT_Face face, FT_Stream stream ) { TT_Error error; TT_Postscript* post = &face->postscript;#ifdef READ_FIELDS const FT_Frame_Field post_fields[] = { { ft_frame_start, 0, 32 }, FT_FRAME_ULONG( TT_Postscript, FormatType ), FT_FRAME_ULONG( TT_Postscript, italicAngle ), FT_FRAME_SHORT( TT_Postscript, underlinePosition ), FT_FRAME_SHORT( TT_Postscript, underlineThickness ), FT_FRAME_ULONG( TT_Postscript, isFixedPitch ), FT_FRAME_ULONG( TT_Postscript, minMemType42 ), FT_FRAME_ULONG( TT_Postscript, maxMemType42 ), FT_FRAME_ULONG( TT_Postscript, minMemType1 ), FT_FRAME_ULONG( TT_Postscript, maxMemType1 ), { ft_frame_end } };#endif FT_TRACE2(( "PostScript " )); error = face->goto_table( face, TTAG_post, stream, 0 ); if (error) return TT_Err_Post_Table_Missing;#ifdef READ_FIELDS if ( READ_Fields( post_fields, post ) ) return error;#else if ( ACCESS_Frame( 32L ) ) return error; /* read frame data into face table */ post->FormatType = GET_ULong(); post->italicAngle = GET_ULong(); post->underlinePosition = GET_Short(); post->underlineThickness = GET_Short(); post->isFixedPitch = GET_ULong(); post->minMemType42 = GET_ULong(); post->maxMemType42 = GET_ULong(); post->minMemType1 = GET_ULong(); post->maxMemType1 = GET_ULong(); FORGET_Frame();#endif /* we don't load the glyph names, we do that in another */ /* module (ttpost). */ FT_TRACE2(( "loaded\n" )); return TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_Gasp */ /* */ /* <Description> */ /* Loads the `GASP' table into a face object. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* stream :: The input stream. */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ LOCAL_FUNC TT_Error TT_Load_Gasp( TT_Face face, FT_Stream stream ) { TT_Error error; FT_Memory memory = stream->memory; TT_UInt j,num_ranges; TT_GaspRange* gaspranges; FT_TRACE2(( "TT_Load_Gasp( %08lx )\n", (TT_Long)face )); /* the gasp table is optional */ error = face->goto_table( face, TTAG_gasp, stream, 0 ); if (error) return TT_Err_Ok; if ( ACCESS_Frame( 4L ) ) goto Exit; face->gasp.version = GET_UShort(); face->gasp.numRanges = GET_UShort(); FORGET_Frame(); num_ranges = face->gasp.numRanges; FT_TRACE3(( "number of ranges = %d\n", num_ranges )); if ( ALLOC_ARRAY( gaspranges, num_ranges, TT_GaspRange ) || ACCESS_Frame( num_ranges * 4L ) ) goto Exit; face->gasp.gaspRanges = gaspranges; for ( j = 0; j < num_ranges; j++ ) { gaspranges[j].maxPPEM = GET_UShort(); gaspranges[j].gaspFlag = GET_UShort(); FT_TRACE3(( " [max:%d flag:%d]", gaspranges[j].maxPPEM, gaspranges[j].gaspFlag )); } FT_TRACE3(( "\n" )); FORGET_Frame(); FT_TRACE2(( "GASP loaded\n" )); Exit: return error; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_Kern */ /* */ /* <Description> */ /* Loads the first kerning table with format 0 in the font. Only */ /* accepts the first horizontal kerning table. Developers should use */ /* the `ftxkern' extension to access other kerning tables in the font */ /* file, if they really want to. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* stream :: The input stream. */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ LOCAL_FUNC TT_Error TT_Load_Kern( TT_Face face, FT_Stream stream ) { TT_Error error; FT_Memory memory = stream->memory; TT_UInt n, num_tables, version; /* the kern table is optional. exit silently if it's missing */ error = face->goto_table( face, TTAG_kern, stream, 0 ); if ( error ) return TT_Err_Ok; if ( ACCESS_Frame( 4L ) ) goto Exit; version = GET_UShort(); num_tables = GET_UShort(); FORGET_Frame(); for ( n = 0; n < num_tables; n++ ) { TT_UInt coverage; TT_UInt length; if ( ACCESS_Frame( 6L ) ) goto Exit; version = GET_UShort(); /* version */ length = GET_UShort() - 6; /* substract header length */ coverage = GET_UShort(); FORGET_Frame(); if ( coverage == 0x0001 ) { TT_UInt num_pairs; TT_Kern_0_Pair* pair; TT_Kern_0_Pair* limit; /* found a horizontal format 0 kerning table ! */ if ( ACCESS_Frame(8L) ) goto Exit; num_pairs = GET_UShort(); /* skip the rest */ FORGET_Frame(); /* allocate array of kerning pairs */ if ( ALLOC_ARRAY( face->kern_pairs, num_pairs, TT_Kern_0_Pair ) || ACCESS_Frame( 6L * num_pairs ) ) goto Exit; pair = face->kern_pairs; limit = pair + num_pairs; for ( ; pair < limit; pair++ ) { pair->left = GET_UShort(); pair->right = GET_UShort(); pair->value = GET_UShort(); } FORGET_Frame(); face->num_kern_pairs = num_pairs; face->kern_table_index = n; goto Exit; } if ( FILE_Skip( length ) ) goto Exit; } /* no kern table found -- doesn't matter */ face->kern_table_index = -1; face->num_kern_pairs = 0; face->kern_pairs = NULL; Exit: return error; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_Hdmx */ /* */ /* <Description> */ /* Loads the horizontal device metrics table. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* stream :: A handle to the input stream. */ /* */ /* <Return> */ /* TrueType error code. 0 means success. */ /* */ LOCAL_FUNC TT_Error TT_Load_Hdmx( TT_Face face, FT_Stream stream ) { TT_Error error; FT_Memory memory = stream->memory; TT_Hdmx* hdmx = &face->hdmx; TT_Long num_glyphs; TT_Long record_size; hdmx->version = 0; hdmx->num_records = 0; hdmx->records = 0; /* this table is optional */ error = face->goto_table( face, TTAG_hdmx, stream, 0 ); if (error) return TT_Err_Ok; if ( ACCESS_Frame( 8L ) ) goto Exit; hdmx->version = GET_UShort(); hdmx->num_records = GET_Short(); record_size = GET_Long(); FORGET_Frame(); /* Only recognize format 0 */ if ( hdmx->version != 0 ) goto Exit; if ( ALLOC_ARRAY( hdmx->records, hdmx->num_records, TT_HdmxRec ) ) goto Exit; num_glyphs = face->root.num_glyphs; record_size -= num_glyphs + 2; { TT_HdmxRec* cur = hdmx->records; TT_HdmxRec* limit = cur + hdmx->num_records; for ( ; cur < limit; cur++ ) { /* read record */ if ( READ_Byte( cur->ppem ) || READ_Byte( cur->max_width ) ) goto Exit; if ( ALLOC( cur->widths, num_glyphs ) || FILE_Read( cur->widths, num_glyphs ) ) goto Exit; /* skip padding bytes */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -