📄 ttload.c
字号:
/*************************************************************************/ /* */ /* <Function> */ /* TT_Free_Names */ /* */ /* <Description> */ /* Frees the name records. */ /* */ /* <Input> */ /* face :: A handle to the target face object. */ /* */ FT_LOCAL_DEF void TT_Free_Names( TT_Face face ) { FT_Memory memory = face->root.driver->root.memory; TT_NameTable* names = &face->name_table; /* free strings table */ FREE( names->names ); /* free strings storage */ FREE( names->storage ); names->numNameRecords = 0; names->format = 0; names->storageOffset = 0; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_CMap */ /* */ /* <Description> */ /* Loads the cmap directory in a face object. The cmaps itselves are */ /* loaded on demand in the `ttcmap.c' module. */ /* */ /* <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_CMap( TT_Face face, FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; FT_Long table_start; TT_CMapDir cmap_dir; const FT_Frame_Field cmap_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE TT_CMapDir FT_FRAME_START( 4 ), FT_FRAME_USHORT( tableVersionNumber ), FT_FRAME_USHORT( numCMaps ), FT_FRAME_END }; const FT_Frame_Field cmap_rec_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE TT_CMapTable FT_FRAME_START( 6 ), FT_FRAME_USHORT( format ), FT_FRAME_USHORT( length ), FT_FRAME_USHORT( version ), FT_FRAME_END }; FT_TRACE2(( "CMaps " )); error = face->goto_table( face, TTAG_cmap, stream, 0 ); if ( error ) { error = TT_Err_CMap_Table_Missing; goto Exit; } table_start = FILE_Pos(); if ( READ_Fields( cmap_fields, &cmap_dir ) ) goto Exit; /* reserve space in face table for cmap tables */ if ( ALLOC_ARRAY( face->charmaps, cmap_dir.numCMaps, TT_CharMapRec ) ) goto Exit; face->num_charmaps = cmap_dir.numCMaps; { TT_CharMap charmap = face->charmaps; TT_CharMap limit = charmap + face->num_charmaps; /* read the header of each charmap first */ if ( ACCESS_Frame( face->num_charmaps * 8L ) ) goto Exit; for ( ; charmap < limit; charmap++ ) { TT_CMapTable* cmap; charmap->root.face = (FT_Face)face; cmap = &charmap->cmap; cmap->loaded = FALSE; cmap->platformID = GET_UShort(); cmap->platformEncodingID = GET_UShort(); cmap->offset = (FT_ULong)GET_Long(); } FORGET_Frame(); /* now read the rest of each table */ for ( charmap = face->charmaps; charmap < limit; charmap++ ) { TT_CMapTable* cmap = &charmap->cmap; if ( FILE_Seek( table_start + (FT_Long)cmap->offset ) || READ_Fields( cmap_rec_fields, cmap ) ) goto Exit; cmap->offset = FILE_Pos(); } } FT_TRACE2(( "loaded\n" )); Exit: return error; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_OS2 */ /* */ /* <Description> */ /* Loads the OS2 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_OS2( TT_Face face, FT_Stream stream ) { FT_Error error; TT_OS2* os2;#undef FT_STRUCTURE#define FT_STRUCTURE TT_OS2 const FT_Frame_Field os2_fields[] = { FT_FRAME_START( 78 ), FT_FRAME_USHORT( version ), FT_FRAME_SHORT ( xAvgCharWidth ), FT_FRAME_USHORT( usWeightClass ), FT_FRAME_USHORT( usWidthClass ), FT_FRAME_SHORT ( fsType ), FT_FRAME_SHORT ( ySubscriptXSize ), FT_FRAME_SHORT ( ySubscriptYSize ), FT_FRAME_SHORT ( ySubscriptXOffset ), FT_FRAME_SHORT ( ySubscriptYOffset ), FT_FRAME_SHORT ( ySuperscriptXSize ), FT_FRAME_SHORT ( ySuperscriptYSize ), FT_FRAME_SHORT ( ySuperscriptXOffset ), FT_FRAME_SHORT ( ySuperscriptYOffset ), FT_FRAME_SHORT ( yStrikeoutSize ), FT_FRAME_SHORT ( yStrikeoutPosition ), FT_FRAME_SHORT ( sFamilyClass ), FT_FRAME_BYTE ( panose[0] ), FT_FRAME_BYTE ( panose[1] ), FT_FRAME_BYTE ( panose[2] ), FT_FRAME_BYTE ( panose[3] ), FT_FRAME_BYTE ( panose[4] ), FT_FRAME_BYTE ( panose[5] ), FT_FRAME_BYTE ( panose[6] ), FT_FRAME_BYTE ( panose[7] ), FT_FRAME_BYTE ( panose[8] ), FT_FRAME_BYTE ( panose[9] ), FT_FRAME_ULONG ( ulUnicodeRange1 ), FT_FRAME_ULONG ( ulUnicodeRange2 ), FT_FRAME_ULONG ( ulUnicodeRange3 ), FT_FRAME_ULONG ( ulUnicodeRange4 ), FT_FRAME_BYTE ( achVendID[0] ), FT_FRAME_BYTE ( achVendID[1] ), FT_FRAME_BYTE ( achVendID[2] ), FT_FRAME_BYTE ( achVendID[3] ), 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 = TT_Err_Ok; goto Exit; } os2 = &face->os2; if ( READ_Fields( os2_fields, os2 ) ) goto Exit; os2->ulCodePageRange1 = 0; os2->ulCodePageRange2 = 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 TT_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 TT_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* TT_Load_PCLT */ /* */ /* <Description> */ /* Loads the PCL 5 Table. */ /* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -