📄 ttload.c
字号:
FT_FRAME_USHORT( fsSelection ), FT_FRAME_USHORT( usFirstCharIndex ), FT_FRAME_USHORT( usLastCharIndex ), FT_FRAME_SHORT ( sTypoAscender ), FT_FRAME_SHORT ( sTypoDescender ), FT_FRAME_SHORT ( sTypoLineGap ), FT_FRAME_USHORT( usWinAscent ), FT_FRAME_USHORT( usWinDescent ), FT_FRAME_END }; const FT_Frame_Field os2_fields_extra[] = { FT_FRAME_START( 8 ), FT_FRAME_ULONG( ulCodePageRange1 ), FT_FRAME_ULONG( ulCodePageRange2 ), FT_FRAME_END }; const FT_Frame_Field os2_fields_extra2[] = { FT_FRAME_START( 10 ), FT_FRAME_SHORT ( sxHeight ), FT_FRAME_SHORT ( sCapHeight ), FT_FRAME_USHORT( usDefaultChar ), FT_FRAME_USHORT( usBreakChar ), FT_FRAME_USHORT( usMaxContext ), FT_FRAME_END }; FT_TRACE2(( "OS/2 Table " )); /* We now support old Mac fonts where the OS/2 table doesn't */ /* exist. Simply put, we set the `version' field to 0xFFFF */ /* and test this value each time we need to access the table. */ error = face->goto_table( face, TTAG_OS2, stream, 0 ); if ( error ) { FT_TRACE2(( "is missing!\n" )); face->os2.version = 0xFFFF; error = SFNT_Err_Ok; goto Exit; } os2 = &face->os2; if ( READ_Fields( os2_fields, os2 ) ) goto Exit; os2->ulCodePageRange1 = 0; os2->ulCodePageRange2 = 0; os2->sxHeight = 0; os2->sCapHeight = 0; os2->usDefaultChar = 0; os2->usBreakChar = 0; os2->usMaxContext = 0; if ( os2->version >= 0x0001 ) { /* only version 1 tables */ if ( READ_Fields( os2_fields_extra, os2 ) ) goto Exit; if ( os2->version >= 0x0002 ) { /* only version 2 tables */ if ( READ_Fields( os2_fields_extra2, os2 ) ) goto Exit; } } 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> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error TT_Load_PostScript( TT_Face face, FT_Stream stream ) { FT_Error error; TT_Postscript* post = &face->postscript; static const FT_Frame_Field post_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE TT_Postscript FT_FRAME_START( 32 ), FT_FRAME_ULONG( FormatType ), FT_FRAME_ULONG( italicAngle ), FT_FRAME_SHORT( underlinePosition ), FT_FRAME_SHORT( underlineThickness ), FT_FRAME_ULONG( isFixedPitch ), FT_FRAME_ULONG( minMemType42 ), FT_FRAME_ULONG( maxMemType42 ), FT_FRAME_ULONG( minMemType1 ), FT_FRAME_ULONG( maxMemType1 ), FT_FRAME_END }; FT_TRACE2(( "PostScript " )); error = face->goto_table( face, TTAG_post, stream, 0 ); if ( error ) return SFNT_Err_Post_Table_Missing; if ( READ_Fields( post_fields, post ) ) return error; /* we don't load the glyph names, we do that in another */ /* module (ttpost). */ FT_TRACE2(( "loaded\n" )); return SFNT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_PCLT */ /* */ /* <Description> */ /* Loads the PCL 5 Table. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* stream :: A handle to the input stream. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error TT_Load_PCLT( TT_Face face, FT_Stream stream ) { static const FT_Frame_Field pclt_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE TT_PCLT FT_FRAME_START( 54 ), FT_FRAME_ULONG ( Version ), FT_FRAME_ULONG ( FontNumber ), FT_FRAME_USHORT( Pitch ), FT_FRAME_USHORT( xHeight ), FT_FRAME_USHORT( Style ), FT_FRAME_USHORT( TypeFamily ), FT_FRAME_USHORT( CapHeight ), FT_FRAME_BYTES ( TypeFace, 16 ), FT_FRAME_BYTES ( CharacterComplement, 8 ), FT_FRAME_BYTES ( FileName, 6 ), FT_FRAME_CHAR ( StrokeWeight ), FT_FRAME_CHAR ( WidthType ), FT_FRAME_BYTE ( SerifStyle ), FT_FRAME_BYTE ( Reserved ), FT_FRAME_END }; FT_Error error; TT_PCLT* pclt = &face->pclt; FT_TRACE2(( "PCLT " )); /* optional table */ error = face->goto_table( face, TTAG_PCLT, stream, 0 ); if ( error ) { FT_TRACE2(( "missing (optional)\n" )); pclt->Version = 0; return SFNT_Err_Ok; } if ( READ_Fields( pclt_fields, pclt ) ) goto Exit; FT_TRACE2(( "loaded\n" )); Exit: return error; } /*************************************************************************/ /* */ /* <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> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error TT_Load_Gasp( TT_Face face, FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; FT_UInt j,num_ranges; TT_GaspRange* gaspranges; FT_TRACE2(( "TT_Load_Gasp: %08p\n", face )); /* the gasp table is optional */ error = face->goto_table( face, TTAG_gasp, stream, 0 ); if ( error ) return SFNT_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; } FT_CALLBACK_DEF( int ) tt_kern_pair_compare( const void* a, const void* b ); /*************************************************************************/ /* */ /* <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> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error TT_Load_Kern( TT_Face face, FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; FT_UInt n, num_tables; /* the kern table is optional; exit silently if it is missing */ error = face->goto_table( face, TTAG_kern, stream, 0 ); if ( error ) return SFNT_Err_Ok; if ( ACCESS_Frame( 4L ) ) goto Exit; (void)GET_UShort(); /* version */ num_tables = GET_UShort(); FORGET_Frame(); for ( n = 0; n < num_tables; n++ ) { FT_UInt coverage; FT_UInt length; if ( ACCESS_Frame( 6L ) ) goto Exit; (void)GET_UShort(); /* version */ length = GET_UShort() - 6; /* substract header length */ coverage = GET_UShort(); FORGET_Frame(); if ( coverage == 0x0001 ) { FT_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 ) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -