📄 t2objs.c
字号:
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" )); goto Bad_Format; } /* If we are performing a simple font format check, exit immediately */ if ( face_index < 0 ) return T2_Err_Ok; sfnt_format = 1; /* now, the font can be either an OpenType/CFF font, or a SVG CEF */ /* font in the later case; it doesn't have a `head' table */ error = face->goto_table( face, TTAG_head, stream, 0 ); if ( !error ) { pure_cff = 0; /* Load font directory */ error = sfnt->load_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; } else { /* load the `cmap' table by hand */ error = sfnt->load_charmaps( face, stream ); if ( error ) goto Exit; /* XXX: for now, we don't load the GPOS table, as OpenType Layout */ /* support will be added later to FreeType 2 as a separate module */ } /* now, load the CFF part of the file */ error = face->goto_table( face, TTAG_CFF, stream, 0 ); if ( error ) goto Exit; } else { /* rewind to start of file; we are going to load a pure-CFF font */ if ( FILE_Seek( 0 ) ) goto Exit; error = FT_Err_Ok; } /* now load and parse the CFF table in the file */ { CFF_Font* cff; FT_Memory memory = face->root.memory; FT_Face root; FT_UInt flags; FT_ULong base_offset; if ( ALLOC( cff, sizeof ( *cff ) ) ) goto Exit; base_offset = FILE_Pos(); face->extra.data = cff; error = T2_Load_CFF_Font( stream, face_index, cff ); if ( error ) goto Exit; /* Complement the root flags with some interesting information. */ /* Note that this is only necessary for pure CFF and CEF fonts */ root = &face->root; if ( pure_cff ) { CFF_Font_Dict* dict = &cff->top_font.font_dict; /* we need the `PSNames' module for pure-CFF and CEF formats */ if ( !psnames ) { FT_ERROR(( "T2_Init_Face:" )); FT_ERROR(( " cannot open CFF & CEF fonts\n" )); FT_ERROR(( " " )); FT_ERROR(( " without the `PSNames' module\n" )); goto Bad_Format; } /* Set up num_faces. */ root->num_faces = cff->num_faces; /* compute number of glyphs */ if ( dict->cid_registry ) root->num_glyphs = dict->cid_count; else root->num_glyphs = cff->charstrings_index.count; /* set global bbox, as well as EM size */ root->units_per_EM = 1000; root->bbox = dict->font_bbox; root->ascender = (FT_Short)root->bbox.yMax; root->descender = (FT_Short)root->bbox.yMin; root->height = ( ( root->ascender - root->descender ) * 12 ) / 10; /* retrieve font family & style name */ root->family_name = T2_Get_Name( &cff->name_index, face_index ); if ( dict->cid_registry ) { root->style_name = T2_StrCopy( memory, "Regular" ); /* XXXX */ } else { root->style_name = T2_Get_String( &cff->string_index, dict->weight, psnames ); } /*******************************************************************/ /* */ /* Compute face flags. */ /* */ flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ if ( sfnt_format ) flags |= FT_FACE_FLAG_SFNT; /* fixed width font? */ if ( dict->is_fixed_pitch ) flags |= FT_FACE_FLAG_FIXED_WIDTH;/* XXXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */#if 0 /* kerning available? */ if ( face->kern_pairs ) flags |= FT_FACE_FLAG_KERNING;#endif root->face_flags = flags; /*******************************************************************/ /* */ /* Compute style flags. */ /* */ flags = 0; if ( dict->italic_angle ) flags |= FT_STYLE_FLAG_ITALIC; /* XXX: may not be correct */ if ( cff->top_font.private_dict.force_bold ) flags |= FT_STYLE_FLAG_BOLD; root->style_flags = flags; /* set the charmaps if any */ if ( sfnt_format ) { /*****************************************************************/ /* */ /* Polish the charmaps. */ /* */ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ TT_CharMap charmap; FT_Int n; charmap = face->charmaps; root->num_charmaps = face->num_charmaps; /* allocate table of pointers */ if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) ) goto Exit; for ( n = 0; n < root->num_charmaps; n++, charmap++ ) { FT_Int platform = charmap->cmap.platformID; FT_Int encoding = charmap->cmap.platformEncodingID; charmap->root.face = (FT_Face)face; charmap->root.platform_id = platform; charmap->root.encoding_id = encoding; charmap->root.encoding = find_encoding( platform, encoding ); /* now, set root->charmap with a unicode charmap */ /* wherever available */ if ( !root->charmap && charmap->root.encoding == ft_encoding_unicode ) root->charmap = (FT_CharMap)charmap; root->charmaps[n] = (FT_CharMap)charmap; } } } } Exit: return error; Bad_Format: error = FT_Err_Unknown_File_Format; goto Exit; } /*************************************************************************/ /* */ /* <Function> */ /* T2_Done_Face */ /* */ /* <Description> */ /* Finalizes a given face object. */ /* */ /* <Input> */ /* face :: A pointer to the face object to destroy. */ /* */ FT_LOCAL void T2_Done_Face( T2_Face face ) { FT_Memory memory = face->root.memory; SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; if ( sfnt ) sfnt->done_face( face ); { CFF_Font* cff = (CFF_Font*)face->extra.data; if ( cff ) { T2_Done_CFF_Font( cff ); FREE( face->extra.data ); } } } /*************************************************************************/ /* */ /* <Function> */ /* T2_Init_Driver */ /* */ /* <Description> */ /* Initializes a given OpenType driver object. */ /* */ /* <Input> */ /* driver :: A handle to the target driver object. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error T2_Init_Driver( T2_Driver driver ) { /* init extension registry if needed */#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE return TT_Init_Extensions( driver );#else FT_UNUSED( driver ); return T2_Err_Ok;#endif } /*************************************************************************/ /* */ /* <Function> */ /* T2_Done_Driver */ /* */ /* <Description> */ /* Finalizes a given OpenType driver. */ /* */ /* <Input> */ /* driver :: A handle to the target OpenType driver. */ /* */ FT_LOCAL_DEF void T2_Done_Driver( T2_Driver driver ) { /* destroy extensions registry if needed */#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE TT_Done_Extensions( driver );#else FT_UNUSED( driver );#endif }/* END */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -