这篇教程C++ FT_STREAM_SEEK函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FT_STREAM_SEEK函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_STREAM_SEEK函数的具体用法?C++ FT_STREAM_SEEK怎么用?C++ FT_STREAM_SEEK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FT_STREAM_SEEK函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CFF_Load_FD_Select static FT_Error CFF_Load_FD_Select( CFF_FDSelect fdselect, FT_UInt num_glyphs, FT_Stream stream, FT_ULong offset ) { FT_Error error; FT_Byte format; FT_UInt num_ranges; /* read format */ if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) ) goto Exit; fdselect->format = format; fdselect->cache_count = 0; /* clear cache */ switch ( format ) { case 0: /* format 0, that's simple */ fdselect->data_size = num_glyphs; goto Load_Data; case 3: /* format 3, a tad more complex */ if ( FT_READ_USHORT( num_ranges ) ) goto Exit; fdselect->data_size = num_ranges * 3 + 2; Load_Data: if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) ) goto Exit; break; default: /* hmm... that's wrong */ error = CFF_Err_Invalid_File_Format; } Exit: return error; }
开发者ID:BlairArchibald,项目名称:Alexandria,代码行数:42,
示例2: tt_face_goto_table tt_face_goto_table( TT_Face face, FT_ULong tag, FT_Stream stream, FT_ULong* length ) { TT_Table table; FT_Error error; table = tt_face_lookup_table( face, tag ); if ( table ) { if ( length ) *length = table->Length; if ( FT_STREAM_SEEK( table->Offset ) ) goto Exit; } else error = SFNT_Err_Table_Missing; Exit: return error; }
开发者ID:howardgao-mt,项目名称:myd3dlib,代码行数:24,
示例3: ft_bzip2_check_header /* check and skip .bz2 header - we don't support `transparent' compression */ static FT_Error ft_bzip2_check_header( FT_Stream stream ) { FT_Error error = FT_Err_Ok; FT_Byte head[4]; if ( FT_STREAM_SEEK( 0 ) || FT_STREAM_READ( head, 4 ) ) goto Exit; /* head[0] && head[1] are the magic numbers; */ /* head[2] is the version, and head[3] the blocksize */ if ( head[0] != 0x42 || head[1] != 0x5a || head[2] != 0x68 ) /* only support bzip2 (huffman) */ { error = FT_THROW( Invalid_File_Format ); goto Exit; } Exit: return error; }
开发者ID:03050903,项目名称:Urho3D,代码行数:25,
示例4: ft_gzip_check_header/* check and skip .gz header - we don't support `transparent' compression */static FT_Errorft_gzip_check_header( FT_Stream stream ){ FT_Error error; FT_Byte head[4]; if ( FT_STREAM_SEEK( 0 ) || FT_STREAM_READ( head, 4 ) ) goto Exit; /* head[0] && head[1] are the magic numbers; */ /* head[2] is the method, and head[3] the flags */ if ( head[0] != 0x1f || head[1] != 0x8b || head[2] != Z_DEFLATED || (head[3] & FT_GZIP_RESERVED) ) { error = Gzip_Err_Invalid_File_Format; goto Exit; } /* skip time, xflags and os code */ (void)FT_STREAM_SKIP( 6 ); /* skip the extra field */ if ( head[3] & FT_GZIP_EXTRA_FIELD ) { FT_UInt len; if ( FT_READ_USHORT_LE( len ) || FT_STREAM_SKIP( len ) ) goto Exit; } /* skip original file name */ if ( head[3] & FT_GZIP_ORIG_NAME ) for (;;) { FT_UInt c; if ( FT_READ_BYTE( c ) ) goto Exit; if ( c == 0 ) break; } /* skip .gz comment */ if ( head[3] & FT_GZIP_COMMENT ) for (;;) { FT_UInt c; if ( FT_READ_BYTE( c ) ) goto Exit; if ( c == 0 ) break; } /* skip CRC */ if ( head[3] & FT_GZIP_HEAD_CRC ) if ( FT_STREAM_SKIP( 2 ) ) goto Exit;Exit: return error;}
开发者ID:bowlofstew,项目名称:Aquaria,代码行数:73,
示例5: tt_face_get_name//.........这里部分代码省略......... break; case TT_PLATFORM_MICROSOFT: /* we only take a non-English name when there is nothing */ /* else available in the font */ /* */ if (found_win == -1 || (rec->languageID & 0x3FF) == 0x009) { switch (rec->encodingID) { case TT_MS_ID_SYMBOL_CS: case TT_MS_ID_UNICODE_CS: case TT_MS_ID_UCS_4: is_english = FT_BOOL((rec->languageID & 0x3FF) == 0x009); found_win = n; break; default: ; } } break; default: ; } } } found_apple = found_apple_roman; if (found_apple_english >= 0) found_apple = found_apple_english; /* some fonts contain invalid Unicode or Macintosh formatted entries; */ /* we will thus favor names encoded in Windows formats if available */ /* (provided it is an English name) */ /* */ convert = NULL; if (found_win >= 0 && !(found_apple >= 0 && !is_english)) { rec = face->name_table.names + found_win; switch (rec->encodingID) { /* all Unicode strings are encoded using UTF-16BE */ case TT_MS_ID_UNICODE_CS: case TT_MS_ID_SYMBOL_CS: convert = tt_name_entry_ascii_from_utf16; break; case TT_MS_ID_UCS_4: /* Apparently, if this value is found in a name table entry, it is */ /* documented as `full Unicode repertoire'. Experience with the */ /* MsGothic font shipped with Windows Vista shows that this really */ /* means UTF-16 encoded names (UCS-4 values are only used within */ /* charmaps). */ convert = tt_name_entry_ascii_from_utf16; break; default: ; } } else if (found_apple >= 0) { rec = face->name_table.names + found_apple; convert = tt_name_entry_ascii_from_other; } else if (found_unicode >= 0) { rec = face->name_table.names + found_unicode; convert = tt_name_entry_ascii_from_utf16; } if (rec && convert) { if (rec->string == NULL) { FT_Stream stream = face->name_table.stream; if (FT_QNEW_ARRAY (rec->string, rec->stringLength) || FT_STREAM_SEEK(rec->stringOffset) || FT_STREAM_READ(rec->string, rec->stringLength)) { FT_FREE(rec->string); rec->stringLength = 0; result = NULL; goto Exit; } } result = convert(rec, memory); }Exit: *name = result; return error;}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:101,
示例6: tt_face_init tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Library library; SFNT_Service sfnt; TT_Face face = (TT_Face)ttface; library = face->root.driver->root.library; sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) goto Bad_Format; /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; /* check that we have a valid TrueType file */ error = sfnt->init_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ /* The 0x00020000 tag is completely undocumented; some fonts from */ /* Arphic made for Chinese Windows 3.1 have this. */ if ( face->format_tag != 0x00010000L && /* MS fonts */ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ face->format_tag != TTAG_true ) /* Mac fonts */ { FT_TRACE2(( "[not a valid TTF font]/n" )); goto Bad_Format; }#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER face->root.face_flags |= FT_FACE_FLAG_HINTER;#endif /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return TT_Err_Ok; /* Load font directory */ error = sfnt->load_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; error = tt_face_load_hdmx( face, stream ); if ( error ) goto Exit; if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE ) {#ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !face->root.internal->incremental_interface ) error = tt_face_load_loca( face, stream ); if ( !error ) error = tt_face_load_cvt( face, stream ) || tt_face_load_fpgm( face, stream ) || tt_face_load_prep( face, stream );#else if ( !error ) error = tt_face_load_loca( face, stream ) || tt_face_load_cvt( face, stream ) || tt_face_load_fpgm( face, stream ) || tt_face_load_prep( face, stream );#endif }#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING /* Determine whether unpatented hinting is to be used for this face. */ face->unpatented_hinting = FT_BOOL ( library->debug_hooks[ FT_DEBUG_HOOK_UNPATENTED_HINTING ] != NULL ); { int i; for ( i = 0; i < num_params && !face->unpatented_hinting; i++ ) if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING ) face->unpatented_hinting = TRUE; }#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */ /* initialize standard glyph loading routines */ TT_Init_Glyph_Loading( face ); Exit: return error;//.........这里部分代码省略.........
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:101,
示例7: cff_face_init cff_face_init( FT_Stream stream, FT_Face cffface, /* CFF_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { CFF_Face face = (CFF_Face)cffface; FT_Error error; SFNT_Service sfnt; FT_Service_PsCMaps psnames; PSHinter_Service pshinter; FT_Bool pure_cff = 1; FT_Bool sfnt_format = 0; FT_Library library = cffface->driver->root.library; sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) { FT_ERROR(( "cff_face_init: cannot access `sfnt' module/n" )); error = FT_THROW( Missing_Module ); goto Exit; } FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); pshinter = (PSHinter_Service)FT_Get_Module_Interface( library, "pshinter" ); FT_TRACE2(( "CFF driver/n" )); /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; /* check whether we have a valid OpenType file */ error = sfnt->init_face( stream, face, face_index, num_params, params ); if ( !error ) { if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */ { FT_TRACE2(( " not an OpenType/CFF font/n" )); error = FT_THROW( Unknown_File_Format ); goto Exit; } /* if we are performing a simple font format check, exit immediately */ if ( face_index < 0 ) return FT_Err_Ok; sfnt_format = 1; /* now, the font can be either an OpenType/CFF font, or an SVG CEF */ /* font; in the latter 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 explicitly */ error = sfnt->load_cmap( face, stream ); if ( error ) goto Exit; } /* 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 ( FT_STREAM_SEEK( 0 ) ) goto Exit; error = FT_Err_Ok; } /* now load and parse the CFF table in the file */ { CFF_Font cff = NULL; CFF_FontRecDict dict; FT_Memory memory = cffface->memory; FT_Int32 flags; FT_UInt i; if ( FT_NEW( cff ) ) goto Exit; face->extra.data = cff;//.........这里部分代码省略.........
开发者ID:litao1009,项目名称:SimpleRoom,代码行数:101,
示例8: cff_subfont_load static FT_Error cff_subfont_load( CFF_SubFont font, CFF_Index idx, FT_UInt font_index, FT_Stream stream, FT_ULong base_offset ) { FT_Error error; CFF_ParserRec parser; FT_Byte* dict = NULL; FT_ULong dict_len; CFF_FontRecDict top = &font->font_dict; CFF_Private priv = &font->private_dict; cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); /* set defaults */ FT_MEM_ZERO( top, sizeof ( *top ) ); top->underline_position = -100L << 16; top->underline_thickness = 50L << 16; top->charstring_type = 2; top->font_matrix.xx = 0x10000L; top->font_matrix.yy = 0x10000L; top->cid_count = 8720; /* we use the implementation specific SID value 0xFFFF to indicate */ /* missing entries */ top->version = 0xFFFFU; top->notice = 0xFFFFU; top->copyright = 0xFFFFU; top->full_name = 0xFFFFU; top->family_name = 0xFFFFU; top->weight = 0xFFFFU; top->embedded_postscript = 0xFFFFU; top->cid_registry = 0xFFFFU; top->cid_ordering = 0xFFFFU; top->cid_font_name = 0xFFFFU; error = cff_index_access_element( idx, font_index, &dict, &dict_len ); if ( !error ) error = cff_parser_run( &parser, dict, dict + dict_len ); cff_index_forget_element( idx, &dict ); if ( error ) goto Exit; /* if it is a CID font, we stop there */ if ( top->cid_registry != 0xFFFFU ) goto Exit; /* parse the private dictionary, if any */ if ( top->private_offset && top->private_size ) { /* set defaults */ FT_MEM_ZERO( priv, sizeof ( *priv ) ); priv->blue_shift = 7; priv->blue_fuzz = 1; priv->lenIV = -1; priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 ); cff_parser_init( &parser, CFF_CODE_PRIVATE, priv ); if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) || FT_FRAME_ENTER( font->font_dict.private_size ) ) goto Exit; error = cff_parser_run( &parser, (FT_Byte*)stream->cursor, (FT_Byte*)stream->limit ); FT_FRAME_EXIT(); if ( error ) goto Exit; /* ensure that `num_blue_values' is even */ priv->num_blue_values &= ~1; } /* read the local subrs, if any */ if ( priv->local_subrs_offset ) { if ( FT_STREAM_SEEK( base_offset + top->private_offset + priv->local_subrs_offset ) ) goto Exit; error = cff_index_init( &font->local_subrs_index, stream, 1 ); if ( error ) goto Exit; font->num_local_subrs = font->local_subrs_index.count; error = cff_index_get_pointers( &font->local_subrs_index, &font->local_subrs ); if ( error ) goto Exit; }//.........这里部分代码省略.........
开发者ID:Ali-il,项目名称:gamekit,代码行数:101,
示例9: cff_index_access_element cff_index_access_element( CFF_Index idx, FT_UInt element, FT_Byte** pbytes, FT_ULong* pbyte_len ) { FT_Error error = CFF_Err_Ok; if ( idx && idx->count > element ) { /* compute start and end offsets */ FT_Stream stream = idx->stream; FT_ULong off1, off2 = 0; /* load offsets from file or the offset table */ if ( !idx->offsets ) { FT_ULong pos = element * idx->off_size; if ( FT_STREAM_SEEK( idx->start + 3 + pos ) ) goto Exit; off1 = cff_index_read_offset( idx, &error ); if ( error ) goto Exit; if ( off1 != 0 ) { do { element++; off2 = cff_index_read_offset( idx, &error ); } while ( off2 == 0 && element < idx->count ); } } else /* use offsets table */ { off1 = idx->offsets[element]; if ( off1 ) { do { element++; off2 = idx->offsets[element]; } while ( off2 == 0 && element < idx->count ); } } /* access element */ if ( off1 && off2 > off1 ) { *pbyte_len = off2 - off1; if ( idx->bytes ) { /* this index was completely loaded in memory, that's easy */ *pbytes = idx->bytes + off1 - 1; } else { /* this index is still on disk/file, access it through a frame */ if ( FT_STREAM_SEEK( idx->data_offset + off1 - 1 ) || FT_FRAME_EXTRACT( off2 - off1, *pbytes ) ) goto Exit; } } else { /* empty index element */ *pbytes = 0; *pbyte_len = 0; } } else error = CFF_Err_Invalid_Argument; Exit: return error; }
开发者ID:Ali-il,项目名称:gamekit,代码行数:83,
示例10: pfr_face_get_kerning pfr_face_get_kerning( PFR_Face face, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ) { FT_Error error; PFR_PhyFont phy_font = &face->phy_font; PFR_KernItem item = phy_font->kern_items; FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 ); kerning->x = 0; kerning->y = 0; /* find the kerning item containing our pair */ while ( item ) { if ( item->pair1 <= idx && idx <= item->pair2 ) goto Found_Item; item = item->next; } /* not found */ goto Exit; Found_Item: { /* perform simply binary search within the item */ FT_UInt min, mid, max; FT_Stream stream = face->root.stream; FT_Byte* p; if ( FT_STREAM_SEEK( item->offset ) || FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) goto Exit; min = 0; max = item->pair_count; while ( min < max ) { FT_UInt char1, char2, charcode; mid = ( min + max ) >> 1; p = stream->cursor + mid*item->pair_size; if ( item->flags & PFR_KERN_2BYTE_CHAR ) { char1 = FT_NEXT_USHORT( p ); char2 = FT_NEXT_USHORT( p ); } else { char1 = FT_NEXT_USHORT( p ); char2 = FT_NEXT_USHORT( p ); } charcode = PFR_KERN_INDEX( char1, char2 ); if ( idx == charcode ) { if ( item->flags & PFR_KERN_2BYTE_ADJ ) kerning->x = item->base_adj + FT_NEXT_SHORT( p ); else kerning->x = item->base_adj + FT_NEXT_CHAR( p ); break; } if ( idx > charcode ) min = mid + 1; else max = mid; } FT_FRAME_EXIT(); } Exit: return 0; }
开发者ID:8l,项目名称:inferno,代码行数:81,
示例11: pfr_face_get_kerningpfr_face_get_kerning( FT_Face pfrface, /* PFR_Face */ FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ){ PFR_Face face = (PFR_Face)pfrface; FT_Error error = FT_Err_Ok; PFR_PhyFont phy_font = &face->phy_font; FT_UInt32 code1, code2, pair; kerning->x = 0; kerning->y = 0; if ( glyph1 > 0 ) glyph1--; if ( glyph2 > 0 ) glyph2--; /* convert glyph indices to character codes */ if ( glyph1 > phy_font->num_chars || glyph2 > phy_font->num_chars ) goto Exit; code1 = phy_font->chars[glyph1].char_code; code2 = phy_font->chars[glyph2].char_code; pair = PFR_KERN_INDEX( code1, code2 ); /* now search the list of kerning items */ { PFR_KernItem item = phy_font->kern_items; FT_Stream stream = pfrface->stream; for ( ; item; item = item->next ) { if ( pair >= item->pair1 && pair <= item->pair2 ) goto FoundPair; } goto Exit;FoundPair: /* we found an item, now parse it and find the value if any */ if ( FT_STREAM_SEEK( item->offset ) || FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) goto Exit; { FT_UInt count = item->pair_count; FT_UInt size = item->pair_size; FT_UInt power = 1 << FT_MSB( count ); FT_UInt probe = power * size; FT_UInt extra = count - power; FT_Byte* base = stream->cursor; FT_Bool twobytes = FT_BOOL( item->flags & 1 ); FT_Bool twobyte_adj = FT_BOOL( item->flags & 2 ); FT_Byte* p; FT_UInt32 cpair; if ( extra > 0 ) { p = base + extra * size; if ( twobytes ) cpair = FT_NEXT_ULONG( p ); else cpair = PFR_NEXT_KPAIR( p ); if ( cpair == pair ) goto Found; if ( cpair < pair ) { if ( twobyte_adj ) p += 2; else p++; base = p; } } while ( probe > size ) { probe >>= 1; p = base + probe; if ( twobytes ) cpair = FT_NEXT_ULONG( p ); else cpair = PFR_NEXT_KPAIR( p ); if ( cpair == pair ) goto Found; if ( cpair < pair ) base += probe; } p = base;//.........这里部分代码省略.........
开发者ID:structuresound,项目名称:freetype,代码行数:101,
示例12: tt_face_inittt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ){ FT_Error error; FT_Library library; SFNT_Service sfnt; TT_Face face = (TT_Face)ttface; FT_TRACE2(( "TTF driver/n" )); library = ttface->driver->root.library; sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) { FT_ERROR(( "tt_face_init: cannot access `sfnt' module/n" )); error = FT_THROW( Missing_Module ); goto Exit; } /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; /* check that we have a valid TrueType file */ error = sfnt->init_face( stream, face, face_index, num_params, params ); /* Stream may have changed. */ stream = face->root.stream; if ( error ) goto Exit; /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ /* The 0x00020000 tag is completely undocumented; some fonts from */ /* Arphic made for Chinese Windows 3.1 have this. */ if ( face->format_tag != 0x00010000L && /* MS fonts */ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ face->format_tag != TTAG_true ) /* Mac fonts */ { FT_TRACE2(( " not a TTF font/n" )); goto Bad_Format; }#ifdef TT_USE_BYTECODE_INTERPRETER ttface->face_flags |= FT_FACE_FLAG_HINTER;#endif /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return FT_Err_Ok; /* Load font directory */ error = sfnt->load_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; if ( tt_check_trickyness( ttface ) ) ttface->face_flags |= FT_FACE_FLAG_TRICKY; error = tt_face_load_hdmx( face, stream ); if ( error ) goto Exit; if ( FT_IS_SCALABLE( ttface ) ) {#ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !ttface->internal->incremental_interface ) error = tt_face_load_loca( face, stream ); if ( !error ) error = tt_face_load_cvt( face, stream ); if ( !error ) error = tt_face_load_fpgm( face, stream ); if ( !error ) error = tt_face_load_prep( face, stream ); /* Check the scalable flag based on `loca'. */ if ( !ttface->internal->incremental_interface && ttface->num_fixed_sizes && face->glyph_locations && tt_check_single_notdef( ttface ) ) { FT_TRACE5(( "tt_face_init:" " Only the `.notdef' glyph has an outline./n" " " " Resetting scalable flag to FALSE./n" )); ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; }#else /* !FT_CONFIG_OPTION_INCREMENTAL */ if ( !error ) error = tt_face_load_loca( face, stream );//.........这里部分代码省略.........
开发者ID:Ruw-Van,项目名称:krkrz,代码行数:101,
示例13: t42_parser_init t42_parser_init( T42_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ) { FT_Error error = FT_Err_Ok; FT_Long size; psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory ); parser->stream = stream; parser->base_len = 0; parser->base_dict = 0; parser->in_memory = 0; /*******************************************************************/ /* */ /* Here a short summary of what is going on: */ /* */ /* When creating a new Type 42 parser, we try to locate and load */ /* the base dictionary, loading the whole font into memory. */ /* */ /* When `loading' the base dictionary, we only set up pointers */ /* in the case of a memory-based stream. Otherwise, we allocate */ /* and load the base dictionary in it. */ /* */ /* parser->in_memory is set if we have a memory stream. */ /* */ if ( FT_STREAM_SEEK( 0L ) || FT_FRAME_ENTER( 17 ) ) goto Exit; if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 ) { FT_TRACE2(( " not a Type42 font/n" )); error = FT_THROW( Unknown_File_Format ); } FT_FRAME_EXIT(); if ( error || FT_STREAM_SEEK( 0 ) ) goto Exit; size = stream->size; /* now, try to load `size' bytes of the `base' dictionary we */ /* found previously */ /* if it is a memory-based resource, set up pointers */ if ( !stream->read ) { parser->base_dict = (FT_Byte*)stream->base + stream->pos; parser->base_len = size; parser->in_memory = 1; /* check that the `size' field is valid */ if ( FT_STREAM_SKIP( size ) ) goto Exit; } else { /* read segment in memory */ if ( FT_ALLOC( parser->base_dict, size ) || FT_STREAM_READ( parser->base_dict, size ) ) goto Exit; parser->base_len = size; } parser->root.base = parser->base_dict; parser->root.cursor = parser->base_dict; parser->root.limit = parser->root.cursor + parser->base_len; Exit: if ( error && !parser->in_memory ) FT_FREE( parser->base_dict ); return error; }
开发者ID:03050903,项目名称:libgdx,代码行数:81,
示例14: cff_index_access_element cff_index_access_element( CFF_Index idx, FT_UInt element, FT_Byte** pbytes, FT_ULong* pbyte_len ) { FT_Error error = FT_Err_Ok; if ( idx && idx->count > element ) { /* compute start and end offsets */ FT_Stream stream = idx->stream; FT_ULong off1, off2 = 0; /* load offsets from file or the offset table */ if ( !idx->offsets ) { FT_ULong pos = element * idx->off_size; if ( FT_STREAM_SEEK( idx->start + 3 + pos ) ) goto Exit; off1 = cff_index_read_offset( idx, &error ); if ( error ) goto Exit; if ( off1 != 0 ) { do { element++; off2 = cff_index_read_offset( idx, &error ); } while ( off2 == 0 && element < idx->count ); } } else /* use offsets table */ { off1 = idx->offsets[element]; if ( off1 ) { do { element++; off2 = idx->offsets[element]; } while ( off2 == 0 && element < idx->count ); } } /* XXX: should check off2 does not exceed the end of this entry; */ /* at present, only truncate off2 at the end of this stream */ if ( off2 > stream->size + 1 || idx->data_offset > stream->size - off2 + 1 ) { FT_ERROR(( "cff_index_access_element:" " offset to next entry (%d)" " exceeds the end of stream (%d)/n", off2, stream->size - idx->data_offset + 1 )); off2 = stream->size - idx->data_offset + 1; } /* access element */ if ( off1 && off2 > off1 ) { *pbyte_len = off2 - off1; if ( idx->bytes ) { /* this index was completely loaded in memory, that's easy */ *pbytes = idx->bytes + off1 - 1; } else { /* this index is still on disk/file, access it through a frame */ if ( FT_STREAM_SEEK( idx->data_offset + off1 - 1 ) || FT_FRAME_EXTRACT( off2 - off1, *pbytes ) ) goto Exit; } } else { /* empty index element */ *pbytes = 0; *pbyte_len = 0; } } else error = FT_THROW( Invalid_Argument ); Exit: return error; }
开发者ID:ONLYOFFICE,项目名称:core,代码行数:95,
示例15: pfr_sort_kerning_pairs static FT_Error pfr_sort_kerning_pairs( FT_Stream stream, PFR_PhyFont phy_font ) { FT_Error error; FT_Memory memory = stream->memory; PFR_KernPair pairs; PFR_KernItem item; PFR_Char chars = phy_font->chars; FT_UInt num_chars = phy_font->num_chars; FT_UInt count; /* create kerning pairs array */ if ( FT_NEW_ARRAY( phy_font->kern_pairs, phy_font->num_kern_pairs ) ) goto Exit; /* load all kerning items into the array, * converting character codes into glyph indices */ pairs = phy_font->kern_pairs; item = phy_font->kern_items; count = 0; for ( ; item; item = item->next ) { FT_UInt limit = count + item->pair_count; FT_Byte* p; if ( limit > phy_font->num_kern_pairs ) { error = PFR_Err_Invalid_Table; goto Exit; } if ( FT_STREAM_SEEK( item->offset ) || FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) goto Exit; p = stream->cursor; for ( ; count < limit; count++ ) { PFR_KernPair pair = pairs + count; FT_UInt char1, char2; FT_Int kerning; if ( item->flags & PFR_KERN_2BYTE_CHAR ) { char1 = FT_NEXT_USHORT( p ); char2 = FT_NEXT_USHORT( p ); } else { char1 = FT_NEXT_BYTE( p ); char2 = FT_NEXT_BYTE( p ); } if ( item->flags & PFR_KERN_2BYTE_ADJ ) kerning = item->base_adj + FT_NEXT_SHORT( p ); else kerning = item->base_adj + FT_NEXT_CHAR( p ); pair->glyph1 = pfr_get_gindex( chars, num_chars, char1 ); pair->glyph2 = pfr_get_gindex( chars, num_chars, char2 ); pair->kerning = kerning; } FT_FRAME_EXIT(); } /* sort the resulting array */ ft_qsort( pairs, count, sizeof ( PFR_KernPairRec ), pfr_compare_kern_pairs ); Exit: if ( error ) { /* disable kerning data in case of error */ phy_font->num_kern_pairs = 0; } return error; }
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:90,
示例16: pcf_read_TOC static FT_Error pcf_read_TOC( FT_Stream stream, PCF_Face face ) { FT_Error error; PCF_Toc toc = &face->toc; PCF_Table tables; FT_Memory memory = FT_FACE(face)->memory; FT_UInt n; if ( FT_STREAM_SEEK ( 0 ) || FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) ) return PCF_Err_Cannot_Open_Resource; if ( toc->version != PCF_FILE_VERSION || toc->count > FT_ARRAY_MAX( face->toc.tables ) || toc->count == 0 ) return PCF_Err_Invalid_File_Format; if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) ) return PCF_Err_Out_Of_Memory; tables = face->toc.tables; for ( n = 0; n < toc->count; n++ ) { if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) ) goto Exit; tables++; } /* Sort tables and check for overlaps. Because they are almost */ /* always ordered already, an in-place bubble sort with simultaneous */ /* boundary checking seems appropriate. */ tables = face->toc.tables; for ( n = 0; n < toc->count - 1; n++ ) { FT_UInt i, have_change; have_change = 0; for ( i = 0; i < toc->count - 1 - n; i++ ) { PCF_TableRec tmp; if ( tables[i].offset > tables[i + 1].offset ) { tmp = tables[i]; tables[i] = tables[i + 1]; tables[i + 1] = tmp; have_change = 1; } if ( ( tables[i].size > tables[i + 1].offset ) || ( tables[i].offset > tables[i + 1].offset - tables[i].size ) ) return PCF_Err_Invalid_Offset; } if ( !have_change ) break; }#ifdef FT_DEBUG_LEVEL_TRACE { FT_UInt i, j; const char* name = "?"; FT_TRACE4(( "pcf_read_TOC:/n" )); FT_TRACE4(( " number of tables: %ld/n", face->toc.count )); tables = face->toc.tables; for ( i = 0; i < toc->count; i++ ) { for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] ); j++ ) if ( tables[i].type == (FT_UInt)( 1 << j ) ) name = tableNames[j]; FT_TRACE4(( " %d: type=%s, format=0x%X, " "size=%ld (0x%lX), offset=%ld (0x%lX)/n", i, name, tables[i].format, tables[i].size, tables[i].size, tables[i].offset, tables[i].offset )); } }#endif return PCF_Err_Ok; Exit://.........这里部分代码省略.........
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:101,
示例17: T1_New_Parser T1_New_Parser( T1_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ) { FT_Error error; FT_UShort tag; FT_ULong size; psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory ); parser->stream = stream; parser->base_len = 0; parser->base_dict = 0; parser->private_len = 0; parser->private_dict = 0; parser->in_pfb = 0; parser->in_memory = 0; parser->single_block = 0; /* check the header format */ error = check_type1_format( stream, "%!PS-AdobeFont", 14 ); if ( error ) { if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Exit; error = check_type1_format( stream, "%!FontType", 10 ); if ( error ) { FT_TRACE2(( " not a Type 1 font/n" )); goto Exit; } } /******************************************************************/ /* */ /* Here a short summary of what is going on: */ /* */ /* When creating a new Type 1 parser, we try to locate and load */ /* the base dictionary if this is possible (i.e., for PFB */ /* files). Otherwise, we load the whole font into memory. */ /* */ /* When `loading' the base dictionary, we only setup pointers */ /* in the case of a memory-based stream. Otherwise, we */ /* allocate and load the base dictionary in it. */ /* */ /* parser->in_pfb is set if we are in a binary (`.pfb') font. */ /* parser->in_memory is set if we have a memory stream. */ /* */ /* try to compute the size of the base dictionary; */ /* look for a Postscript binary file tag, i.e., 0x8001 */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; error = read_pfb_tag( stream, &tag, &size ); if ( error ) goto Exit; if ( tag != 0x8001U ) { /* assume that this is a PFA file for now; an error will */ /* be produced later when more things are checked */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; size = stream->size; } else parser->in_pfb = 1; /* now, try to load `size' bytes of the `base' dictionary we */ /* found previously */ /* if it is a memory-based resource, set up pointers */ if ( !stream->read ) { parser->base_dict = (FT_Byte*)stream->base + stream->pos; parser->base_len = size; parser->in_memory = 1; /* check that the `size' field is valid */ if ( FT_STREAM_SKIP( size ) ) goto Exit; } else { /* read segment in memory -- this is clumsy, but so does the format */ if ( FT_ALLOC( parser->base_dict, size ) || FT_STREAM_READ( parser->base_dict, size ) ) goto Exit; parser->base_len = size; } parser->root.base = parser->base_dict; parser->root.cursor = parser->base_dict; parser->root.limit = parser->root.cursor + parser->base_len; Exit://.........这里部分代码省略.........
开发者ID:PrinttingGroup,项目名称:SumatraPDF_SpecialPrint,代码行数:101,
示例18: tt_face_get_name//.........这里部分代码省略......... /* field only as a last solution when nothing else is */ /* available. */ /* */ found_unicode = n; break; case TT_PLATFORM_MACINTOSH: if ( rec->languageID == TT_MAC_LANGID_ENGLISH ) found_apple = n; break; case TT_PLATFORM_MICROSOFT: /* we only take a non-English name when there is nothing */ /* else available in the font */ /* */ if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 ) { switch ( rec->encodingID ) { case TT_MS_ID_SYMBOL_CS: case TT_MS_ID_UNICODE_CS: case TT_MS_ID_UCS_4: is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 ); found_win = n; break; default: ; } } break; default: ; } } } /* some fonts contain invalid Unicode or Macintosh formatted entries; */ /* we will thus favor names encoded in Windows formats if available */ /* (provided it is an English name) */ /* */ convert = NULL; if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) ) { rec = face->name_table.names + found_win; switch ( rec->encodingID ) { case TT_MS_ID_UNICODE_CS: case TT_MS_ID_SYMBOL_CS: convert = tt_name_entry_ascii_from_utf16; break; case TT_MS_ID_UCS_4: convert = tt_name_entry_ascii_from_ucs4; break; default: ; } } else if ( found_apple >= 0 ) { rec = face->name_table.names + found_apple; convert = tt_name_entry_ascii_from_other; } else if ( found_unicode >= 0 ) { rec = face->name_table.names + found_unicode; convert = tt_name_entry_ascii_from_utf16; } if ( rec && convert ) { if ( rec->string == NULL ) { FT_Error error = SFNT_Err_Ok; FT_Stream stream = face->name_table.stream; FT_UNUSED( error ); if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) || FT_STREAM_SEEK( rec->stringOffset ) || FT_STREAM_READ( rec->string, rec->stringLength ) ) { FT_FREE( rec->string ); rec->stringLength = 0; result = NULL; goto Exit; } } result = convert( rec, memory ); } Exit: return result; }
开发者ID:Bracket-,项目名称:psp-ports,代码行数:101,
示例19: T1_Get_Private_Dict T1_Get_Private_Dict( T1_Parser parser, PSAux_Service psaux ) { FT_Stream stream = parser->stream; FT_Memory memory = parser->root.memory; FT_Error error = FT_Err_Ok; FT_ULong size; if ( parser->in_pfb ) { /* in the case of the PFB format, the private dictionary can be */ /* made of several segments. We thus first read the number of */ /* segments to compute the total size of the private dictionary */ /* then re-read them into memory. */ FT_Long start_pos = FT_STREAM_POS(); FT_UShort tag; parser->private_len = 0; for (;;) { error = read_pfb_tag( stream, &tag, &size ); if ( error ) goto Fail; if ( tag != 0x8002U ) break; parser->private_len += size; if ( FT_STREAM_SKIP( size ) ) goto Fail; } /* Check that we have a private dictionary there */ /* and allocate private dictionary buffer */ if ( parser->private_len == 0 ) { FT_ERROR(( "T1_Get_Private_Dict:" " invalid private dictionary section/n" )); error = FT_THROW( Invalid_File_Format ); goto Fail; } if ( FT_STREAM_SEEK( start_pos ) || FT_ALLOC( parser->private_dict, parser->private_len ) ) goto Fail; parser->private_len = 0; for (;;) { error = read_pfb_tag( stream, &tag, &size ); if ( error || tag != 0x8002U ) { error = FT_Err_Ok; break; } if ( FT_STREAM_READ( parser->private_dict + parser->private_len, size ) ) goto Fail; parser->private_len += size; } } else { /* We have already `loaded' the whole PFA font file into memory; */ /* if this is a memory resource, allocate a new block to hold */ /* the private dict. Otherwise, simply overwrite into the base */ /* dictionary block in the heap. */ /* first of all, look at the `eexec' keyword */ FT_Byte* cur = parser->base_dict; FT_Byte* limit = cur + parser->base_len; FT_Byte c; Again: for (;;) { c = cur[0]; if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */ /* whitespace + 4 chars */ { if ( cur[1] == 'e' && cur[2] == 'x' && cur[3] == 'e' && cur[4] == 'c' ) break; } cur++; if ( cur >= limit ) { FT_ERROR(( "T1_Get_Private_Dict:" " could not find `eexec' keyword/n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; }//.........这里部分代码省略.........
开发者ID:PrinttingGroup,项目名称:SumatraPDF_SpecialPrint,代码行数:101,
示例20: cff_encoding_load static FT_Error cff_encoding_load( CFF_Encoding encoding, CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, FT_ULong offset ) { FT_Error error = CFF_Err_Ok; FT_UInt count; FT_UInt j; FT_UShort glyph_sid; FT_UInt glyph_code; /* Check for charset->sids. If we do not have this, we fail. */ if ( !charset->sids ) { error = CFF_Err_Invalid_File_Format; goto Exit; } /* Zero out the code to gid/sid mappings. */ for ( j = 0; j < 256; j++ ) { encoding->sids [j] = 0; encoding->codes[j] = 0; } /* Note: The encoding table in a CFF font is indexed by glyph index; */ /* the first encoded glyph index is 1. Hence, we read the character */ /* code (`glyph_code') at index j and make the assignment: */ /* */ /* encoding->codes[glyph_code] = j + 1 */ /* */ /* We also make the assignment: */ /* */ /* encoding->sids[glyph_code] = charset->sids[j + 1] */ /* */ /* This gives us both a code to GID and a code to SID mapping. */ if ( offset > 1 ) { encoding->offset = base_offset + offset; /* we need to parse the table to determine its size */ if ( FT_STREAM_SEEK( encoding->offset ) || FT_READ_BYTE( encoding->format ) || FT_READ_BYTE( count ) ) goto Exit; switch ( encoding->format & 0x7F ) { case 0: { FT_Byte* p; /* By convention, GID 0 is always ".notdef" and is never */ /* coded in the font. Hence, the number of codes found */ /* in the table is `count+1'. */ /* */ encoding->count = count + 1; if ( FT_FRAME_ENTER( count ) ) goto Exit; p = (FT_Byte*)stream->cursor; for ( j = 1; j <= count; j++ ) { glyph_code = *p++; /* Make sure j is not too big. */ if ( j < num_glyphs ) { /* Assign code to GID mapping. */ encoding->codes[glyph_code] = (FT_UShort)j; /* Assign code to SID mapping. */ encoding->sids[glyph_code] = charset->sids[j]; } } FT_FRAME_EXIT(); } break; case 1: { FT_UInt nleft; FT_UInt i = 1; FT_UInt k; encoding->count = 0; /* Parse the Format1 ranges. */ for ( j = 0; j < count; j++, i += nleft ) {//.........这里部分代码省略.........
开发者ID:Ali-il,项目名称:gamekit,代码行数:101,
示例21: cff_font_load cff_font_load( FT_Stream stream, FT_Int face_index, CFF_Font font, FT_Bool pure_cff ) { static const FT_Frame_Field cff_header_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE CFF_FontRec FT_FRAME_START( 4 ), FT_FRAME_BYTE( version_major ), FT_FRAME_BYTE( version_minor ), FT_FRAME_BYTE( header_size ), FT_FRAME_BYTE( absolute_offsize ), FT_FRAME_END }; FT_Error error; FT_Memory memory = stream->memory; FT_ULong base_offset; CFF_FontRecDict dict; FT_ZERO( font ); font->stream = stream; font->memory = memory; dict = &font->top_font.font_dict; base_offset = FT_STREAM_POS(); /* read CFF font header */ if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) ) goto Exit; /* check format */ if ( font->version_major != 1 || font->header_size < 4 || font->absolute_offsize > 4 ) { FT_TRACE2(( "[not a CFF font header!]/n" )); error = CFF_Err_Unknown_File_Format; goto Exit; } /* skip the rest of the header */ if ( FT_STREAM_SKIP( font->header_size - 4 ) ) goto Exit; /* read the name, top dict, string and global subrs index */ if ( FT_SET_ERROR( cff_index_init( &font->name_index, stream, 0 ) ) || FT_SET_ERROR( cff_index_init( &font->font_dict_index, stream, 0 ) ) || FT_SET_ERROR( cff_index_init( &font->string_index, stream, 0 ) ) || FT_SET_ERROR( cff_index_init( &font->global_subrs_index, stream, 1 ) ) ) goto Exit; /* well, we don't really forget the `disabled' fonts... */ font->num_faces = font->name_index.count; if ( face_index >= (FT_Int)font->num_faces ) { FT_ERROR(( "cff_font_load: incorrect face index = %d/n", face_index )); error = CFF_Err_Invalid_Argument; } /* in case of a font format check, simply exit now */ if ( face_index < 0 ) goto Exit; /* now, parse the top-level font dictionary */ error = cff_subfont_load( &font->top_font, &font->font_dict_index, face_index, stream, base_offset ); if ( error ) goto Exit; if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) ) goto Exit; error = cff_index_init( &font->charstrings_index, stream, 0 ); if ( error ) goto Exit; /* now, check for a CID font */ if ( dict->cid_registry != 0xFFFFU ) { CFF_IndexRec fd_index; CFF_SubFont sub; FT_UInt idx; /* this is a CID-keyed font, we must now allocate a table of */ /* sub-fonts, then load each of them separately */ if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )//.........这里部分代码省略.........
开发者ID:Ali-il,项目名称:gamekit,代码行数:101,
示例22: pfr_phy_font_load pfr_phy_font_load( PFR_PhyFont phy_font, FT_Stream stream, FT_UInt32 offset, FT_UInt32 size ) { FT_Error error; FT_Memory memory = stream->memory; FT_UInt flags; FT_ULong num_aux; FT_Byte* p; FT_Byte* limit; phy_font->memory = memory; phy_font->offset = offset; phy_font->kern_items = NULL; phy_font->kern_items_tail = &phy_font->kern_items; if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) ) goto Exit; phy_font->cursor = stream->cursor; p = stream->cursor; limit = p + size; PFR_CHECK( 15 ); phy_font->font_ref_number = PFR_NEXT_USHORT( p ); phy_font->outline_resolution = PFR_NEXT_USHORT( p ); phy_font->metrics_resolution = PFR_NEXT_USHORT( p ); phy_font->bbox.xMin = PFR_NEXT_SHORT( p ); phy_font->bbox.yMin = PFR_NEXT_SHORT( p ); phy_font->bbox.xMax = PFR_NEXT_SHORT( p ); phy_font->bbox.yMax = PFR_NEXT_SHORT( p ); phy_font->flags = flags = PFR_NEXT_BYTE( p ); /* get the standard advance for non-proportional fonts */ if ( !(flags & PFR_PHY_PROPORTIONAL) ) { PFR_CHECK( 2 ); phy_font->standard_advance = PFR_NEXT_SHORT( p ); } /* load the extra items when present */ if ( flags & PFR_PHY_EXTRA_ITEMS ) { error = pfr_extra_items_parse( &p, limit, pfr_phy_font_extra_items, phy_font ); if ( error ) goto Fail; } /* In certain fonts, the auxiliary bytes contain interesting */ /* information. These are not in the specification but can be */ /* guessed by looking at the content of a few PFR0 fonts. */ PFR_CHECK( 3 ); num_aux = PFR_NEXT_ULONG( p ); if ( num_aux > 0 ) { FT_Byte* q = p; FT_Byte* q2; PFR_CHECK_SIZE( num_aux ); p += num_aux; while ( num_aux > 0 ) { FT_UInt length, type; if ( q + 4 > p ) break; length = PFR_NEXT_USHORT( q ); if ( length < 4 || length > num_aux ) break; q2 = q + length - 2; type = PFR_NEXT_USHORT( q ); switch ( type ) { case 1: /* this seems to correspond to the font's family name, padded to */ /* an even number of bytes with a zero byte appended if needed */ error = pfr_aux_name_load( q, length - 4U, memory, &phy_font->family_name ); if ( error ) goto Exit; break; case 2: if ( q + 32 > q2 ) break;//.........这里部分代码省略.........
开发者ID:ImageMagick,项目名称:ttf,代码行数:101,
示例23: cff_charset_load static FT_Error cff_charset_load( CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, FT_ULong offset, FT_Bool invert ) { FT_Memory memory = stream->memory; FT_Error error = CFF_Err_Ok; FT_UShort glyph_sid; /* If the the offset is greater than 2, we have to parse the */ /* charset table. */ if ( offset > 2 ) { FT_UInt j; charset->offset = base_offset + offset; /* Get the format of the table. */ if ( FT_STREAM_SEEK( charset->offset ) || FT_READ_BYTE( charset->format ) ) goto Exit; /* Allocate memory for sids. */ if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; /* assign the .notdef glyph */ charset->sids[0] = 0; switch ( charset->format ) { case 0: if ( num_glyphs > 0 ) { if ( FT_FRAME_ENTER( ( num_glyphs - 1 ) * 2 ) ) goto Exit; for ( j = 1; j < num_glyphs; j++ ) charset->sids[j] = FT_GET_USHORT(); FT_FRAME_EXIT(); } break; case 1: case 2: { FT_UInt nleft; FT_UInt i; j = 1; while ( j < num_glyphs ) { /* Read the first glyph sid of the range. */ if ( FT_READ_USHORT( glyph_sid ) ) goto Exit; /* Read the number of glyphs in the range. */ if ( charset->format == 2 ) { if ( FT_READ_USHORT( nleft ) ) goto Exit; } else { if ( FT_READ_BYTE( nleft ) ) goto Exit; } /* Fill in the range of sids -- `nleft + 1' glyphs. */ for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ ) charset->sids[j] = glyph_sid; } } break; default: FT_ERROR(( "cff_charset_load: invalid table format!/n" )); error = CFF_Err_Invalid_File_Format; goto Exit; } } else { /* Parse default tables corresponding to offset == 0, 1, or 2. */ /* CFF specification intimates the following: */ /* */ /* In order to use a predefined charset, the following must be */ /* true: The charset constructed for the glyphs in the font's */ /* charstrings dictionary must match the predefined charset in */ /* the first num_glyphs. */ charset->offset = offset; /* record charset type *///.........这里部分代码省略.........
开发者ID:Ali-il,项目名称:gamekit,代码行数:101,
示例24: tt_face_load_font_dir tt_face_load_font_dir( TT_Face face, FT_Stream stream ) { SFNT_HeaderRec sfnt; FT_Error error; FT_Memory memory = stream->memory; TT_TableRec* entry; FT_Int nn; static const FT_Frame_Field offset_table_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE SFNT_HeaderRec FT_FRAME_START( 8 ), FT_FRAME_USHORT( num_tables ), FT_FRAME_USHORT( search_range ), FT_FRAME_USHORT( entry_selector ), FT_FRAME_USHORT( range_shift ), FT_FRAME_END }; FT_TRACE2(( "tt_face_load_font_dir: %08p/n", face )); /* read the offset table */ sfnt.offset = FT_STREAM_POS(); if ( FT_READ_ULONG( sfnt.format_tag ) || FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) ) goto Exit; /* many fonts don't have these fields set correctly */#if 0 if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) || sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 ) return FT_THROW( Unknown_File_Format );#endif /* load the table directory */ FT_TRACE2(( "-- Number of tables: %10u/n", sfnt.num_tables )); FT_TRACE2(( "-- Format version: 0x%08lx/n", sfnt.format_tag )); if ( sfnt.format_tag != TTAG_OTTO ) { /* check first */ error = check_table_dir( &sfnt, stream ); if ( error ) { FT_TRACE2(( "tt_face_load_font_dir:" " invalid table directory for TrueType/n" )); goto Exit; } } face->num_tables = sfnt.num_tables; face->format_tag = sfnt.format_tag; if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) ) goto Exit; if ( FT_STREAM_SEEK( sfnt.offset + 12 ) || FT_FRAME_ENTER( face->num_tables * 16L ) ) goto Exit; entry = face->dir_tables; FT_TRACE2(( "/n" " tag offset length checksum/n" " ----------------------------------/n" )); for ( nn = 0; nn < sfnt.num_tables; nn++ ) { entry->Tag = FT_GET_TAG4(); entry->CheckSum = FT_GET_ULONG(); entry->Offset = FT_GET_ULONG(); entry->Length = FT_GET_ULONG(); /* ignore invalid tables that can't be sanitized */ if ( entry->Offset > stream->size ) continue; else if ( entry->Length > stream->size - entry->Offset ) { if ( entry->Tag == TTAG_hmtx || entry->Tag == TTAG_vmtx ) {#ifdef FT_DEBUG_LEVEL_TRACE FT_ULong old_length = entry->Length;#endif /* make metrics table length a multiple of 4 */ entry->Length = ( stream->size - entry->Offset ) & ~3U; FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx" " (sanitized; original length %08lx)/n",//.........这里部分代码省略.........
开发者ID:Blitzker,项目名称:assfilter,代码行数:101,
示例25: pfr_log_font_load pfr_log_font_load( PFR_LogFont log_font, FT_Stream stream, FT_UInt idx, FT_UInt32 section_offset, FT_Bool size_increment ) { FT_UInt num_log_fonts; FT_UInt flags; FT_UInt32 offset; FT_UInt32 size; FT_Error error; if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( num_log_fonts ) ) goto Exit; if ( idx >= num_log_fonts ) return FT_THROW( Invalid_Argument ); if ( FT_STREAM_SKIP( idx * 5 ) || FT_READ_USHORT( size ) || FT_READ_UOFF3 ( offset ) ) goto Exit; /* save logical font size and offset */ log_font->size = size; log_font->offset = offset; /* now, check the rest of the table before loading it */ { FT_Byte* p; FT_Byte* limit; FT_UInt local; if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) ) goto Exit; p = stream->cursor; limit = p + size; PFR_CHECK( 13 ); log_font->matrix[0] = PFR_NEXT_LONG( p ); log_font->matrix[1] = PFR_NEXT_LONG( p ); log_font->matrix[2] = PFR_NEXT_LONG( p ); log_font->matrix[3] = PFR_NEXT_LONG( p ); flags = PFR_NEXT_BYTE( p ); local = 0; if ( flags & PFR_LOG_STROKE ) { local++; if ( flags & PFR_LOG_2BYTE_STROKE ) local++; if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER ) local += 3; } if ( flags & PFR_LOG_BOLD ) { local++; if ( flags & PFR_LOG_2BYTE_BOLD ) local++; } PFR_CHECK( local ); if ( flags & PFR_LOG_STROKE ) { log_font->stroke_thickness = ( flags & PFR_LOG_2BYTE_STROKE ) ? PFR_NEXT_SHORT( p ) : PFR_NEXT_BYTE( p ); if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER ) log_font->miter_limit = PFR_NEXT_LONG( p ); } if ( flags & PFR_LOG_BOLD ) { log_font->bold_thickness = ( flags & PFR_LOG_2BYTE_BOLD ) ? PFR_NEXT_SHORT( p ) : PFR_NEXT_BYTE( p ); } if ( flags & PFR_LOG_EXTRA_ITEMS ) { error = pfr_extra_items_skip( &p, limit ); if ( error ) goto Fail; } PFR_CHECK( 5 ); log_font->phys_size = PFR_NEXT_USHORT( p ); log_font->phys_offset = PFR_NEXT_ULONG( p ); if ( size_increment ) {//.........这里部分代码省略.........
开发者ID:ImageMagick,项目名称:ttf,代码行数:101,
示例26: check_table_dir static FT_Error check_table_dir( SFNT_Header sfnt, FT_Stream stream ) { FT_Error error; FT_UInt nn, valid_entries = 0; FT_UInt has_head = 0, has_sing = 0, has_meta = 0; FT_ULong offset = sfnt->offset + 12; static const FT_Frame_Field table_dir_entry_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE TT_TableRec FT_FRAME_START( 16 ), FT_FRAME_ULONG( Tag ), FT_FRAME_ULONG( CheckSum ), FT_FRAME_ULONG( Offset ), FT_FRAME_ULONG( Length ), FT_FRAME_END }; if ( FT_STREAM_SEEK( offset ) ) goto Exit; for ( nn = 0; nn < sfnt->num_tables; nn++ ) { TT_TableRec table; if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) ) { nn--; FT_TRACE2(( "check_table_dir:" " can read only %d table%s in font (instead of %d)/n", nn, nn == 1 ? "" : "s", sfnt->num_tables )); sfnt->num_tables = nn; break; } /* we ignore invalid tables */ if ( table.Offset + table.Length > stream->size ) { FT_TRACE2(( "check_table_dir: table entry %d invalid/n", nn )); continue; } else valid_entries++; if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed ) { FT_UInt32 magic;#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS if ( table.Tag == TTAG_head )#endif has_head = 1; /* * The table length should be 0x36, but certain font tools make it * 0x38, so we will just check that it is greater. * * Note that according to the specification, the table must be * padded to 32-bit lengths, but this doesn't apply to the value of * its `Length' field! * */ if ( table.Length < 0x36 ) { FT_TRACE2(( "check_table_dir: `head' table too small/n" )); error = SFNT_Err_Table_Missing; goto Exit; } if ( FT_STREAM_SEEK( table.Offset + 12 ) || FT_READ_ULONG( magic ) ) goto Exit; if ( magic != 0x5F0F3CF5UL ) { FT_TRACE2(( "check_table_dir:" " no magic number found in `head' table/n")); error = SFNT_Err_Table_Missing; goto Exit; } if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) ) goto Exit; } else if ( table.Tag == TTAG_SING ) has_sing = 1; else if ( table.Tag == TTAG_META ) has_meta = 1; } sfnt->num_tables = valid_entries; if ( sfnt->num_tables == 0 )//.........这里部分代码省略.........
开发者ID:howardgao-mt,项目名称:myd3dlib,代码行数:101,
示例27: tt_face_get_metrics tt_face_get_metrics( TT_Face face, FT_Bool vertical, FT_UInt gindex, FT_Short *abearing, FT_UShort *aadvance ) { FT_Error error; FT_Stream stream = face->root.stream; TT_HoriHeader* header; FT_ULong table_pos, table_size, table_end; FT_UShort k; if ( vertical ) { void* v = &face->vertical; header = (TT_HoriHeader*)v; table_pos = face->vert_metrics_offset; table_size = face->vert_metrics_size; } else { header = &face->horizontal; table_pos = face->horz_metrics_offset; table_size = face->horz_metrics_size; } table_end = table_pos + table_size; k = header->number_Of_HMetrics; if ( k > 0 ) { if ( gindex < (FT_UInt)k ) { table_pos += 4 * gindex; if ( table_pos + 4 > table_end ) goto NoData; if ( FT_STREAM_SEEK( table_pos ) || FT_READ_USHORT( *aadvance ) || FT_READ_SHORT( *abearing ) ) goto NoData; } else { table_pos += 4 * ( k - 1 ); if ( table_pos + 4 > table_end ) goto NoData; if ( FT_STREAM_SEEK( table_pos ) || FT_READ_USHORT( *aadvance ) ) goto NoData; table_pos += 4 + 2 * ( gindex - k ); if ( table_pos + 2 > table_end ) *abearing = 0; else { if ( !FT_STREAM_SEEK( table_pos ) ) (void)FT_READ_SHORT( *abearing ); } } } else { NoData: *abearing = 0; *aadvance = 0; } return SFNT_Err_Ok; }
开发者ID:sloopdoom,项目名称:ftgles-gles2,代码行数:75,
示例28: tt_face_load_font_dir tt_face_load_font_dir( TT_Face face, FT_Stream stream ) { SFNT_HeaderRec sfnt; FT_Error error; FT_Memory memory = stream->memory; TT_TableRec* entry; FT_Int nn; static const FT_Frame_Field offset_table_fields[] = {#undef FT_STRUCTURE#define FT_STRUCTURE SFNT_HeaderRec FT_FRAME_START( 8 ), FT_FRAME_USHORT( num_tables ), FT_FRAME_USHORT( search_range ), FT_FRAME_USHORT( entry_selector ), FT_FRAME_USHORT( range_shift ), FT_FRAME_END }; FT_TRACE2(( "tt_face_load_font_dir: %08p/n", face )); /* read the offset table */ sfnt.offset = FT_STREAM_POS(); if ( FT_READ_ULONG( sfnt.format_tag ) || FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) ) goto Exit; /* many fonts don't have these fields set correctly */#if 0 if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) || sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 ) return SFNT_Err_Unknown_File_Format;#endif /* load the table directory */ FT_TRACE2(( "-- Number of tables: %10u/n", sfnt.num_tables )); FT_TRACE2(( "-- Format version: 0x%08lx/n", sfnt.format_tag )); /* check first */ error = check_table_dir( &sfnt, stream ); if ( error ) { FT_TRACE2(( "tt_face_load_font_dir:" " invalid table directory for TrueType/n" )); goto Exit; } face->num_tables = sfnt.num_tables; face->format_tag = sfnt.format_tag; if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) ) goto Exit; if ( FT_STREAM_SEEK( sfnt.offset + 12 ) || FT_FRAME_ENTER( face->num_tables * 16L ) ) goto Exit; entry = face->dir_tables; for ( nn = 0; nn < sfnt.num_tables; nn++ ) { entry->Tag = FT_GET_TAG4(); entry->CheckSum = FT_GET_ULONG(); entry->Offset = FT_GET_LONG(); entry->Length = FT_GET_LONG(); /* ignore invalid tables */ if ( entry->Offset + entry->Length > stream->size ) continue; else { FT_TRACE2(( " %c%c%c%c - %08lx - %08lx/n", (FT_Char)( entry->Tag >> 24 ), (FT_Char)( entry->Tag >> 16 ), (FT_Char)( entry->Tag >> 8 ), (FT_Char)( entry->Tag ), entry->Offset, entry->Length )); entry++; } } FT_FRAME_EXIT(); FT_TRACE2(( "table directory loaded/n/n" )); Exit: return error; }
开发者ID:howardgao-mt,项目名称:myd3dlib,代码行数:97,
示例29: get_sfnt_postscript_name static const char* get_sfnt_postscript_name( TT_Face face ) { FT_Int n, found_win, found_apple; const char* result = NULL; /* shouldn't happen, but just in case to avoid memory leaks */ if ( face->root.internal->postscript_name ) return face->root.internal->postscript_name; /* scan the name table to see whether we have a Postscript name here, */ /* either in Macintosh or Windows platform encodings */ found_win = -1; found_apple = -1; for ( n = 0; n < face->num_names; n++ ) { TT_NameEntryRec* name = face->name_table.names + n; if ( name->nameID == 6 && name->stringLength > 0 ) { if ( name->platformID == 3 && name->encodingID == 1 && name->languageID == 0x409 ) found_win = n; if ( name->platformID == 1 && name->encodingID == 0 && name->languageID == 0 ) found_apple = n; } } if ( found_win != -1 ) { FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_win; FT_UInt len = name->stringLength / 2; FT_Error error; if ( !FT_ALLOC( result, name->stringLength + 1 ) ) { FT_Stream stream = face->name_table.stream; FT_String* r = (FT_String*)result; FT_Byte* p = (FT_Byte*)name->string; if ( FT_STREAM_SEEK( name->stringOffset ) || FT_FRAME_ENTER( name->stringLength ) ) { FT_FREE( result ); name->stringLength = 0; name->stringOffset = 0; FT_FREE( name->string ); goto Exit; } p = (FT_Byte*)stream->cursor; for ( ; len > 0; len--, p += 2 ) { if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 ) *r++ = p[1]; } *r = '/0'; FT_FRAME_EXIT(); } goto Exit; } if ( found_apple != -1 ) { FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_apple; FT_UInt len = name->stringLength; FT_Error error; if ( !FT_ALLOC( result, len + 1 ) ) { FT_Stream stream = face->name_table.stream; if ( FT_STREAM_SEEK( name->stringOffset ) || FT_STREAM_READ( result, len ) ) { name->stringOffset = 0; name->stringLength = 0; FT_FREE( name->string ); FT_FREE( result ); goto Exit; } ((char*)result)[len] = '/0'; } }//.........这里部分代码省略.........
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:101,
示例30: cid_face_init cid_face_init( FT_Stream stream, FT_Face cidface, /* CID_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { CID_Face face = (CID_Face)cidface; FT_Error error; PSAux_Service psaux; PSHinter_Service pshinter; FT_UNUSED( num_params ); FT_UNUSED( params ); FT_UNUSED( stream ); cidface->num_faces = 1; psaux = (PSAux_Service)face->psaux; if ( !psaux ) { psaux = (PSAux_Service)FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psaux" ); face->psaux = psaux; } pshinter = (PSHinter_Service)face->pshinter; if ( !pshinter ) { pshinter = (PSHinter_Service)FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "pshinter" ); face->pshinter = pshinter; } /* open the tokenizer; this will also check the font format */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; error = cid_face_open( face, face_index ); if ( error ) goto Exit; /* if we just wanted to check the format, leave successfully now */ if ( face_index < 0 ) goto Exit; /* check the face index */ /* XXX: handle CID fonts with more than a single face */ if ( face_index != 0 ) { FT_ERROR(( "cid_face_init: invalid face index/n" )); error = CID_Err_Invalid_Argument; goto Exit; } /* now load the font program into the face object */ /* initialize the face object fields */ /* set up root face fields */ { CID_FaceInfo cid = &face->cid; PS_FontInfo info = &cid->font_info; cidface->num_glyphs = cid->cid_count; cidface->num_charmaps = 0; cidface->face_index = face_index; cidface->face_flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ FT_FACE_FLAG_HINTER; /* has native hinter */ if ( info->is_fixed_pitch ) cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; /* XXX: TODO: add kerning with .afm support */ /* get style name -- be careful, some broken fonts only */ /* have a /FontName dictionary entry! */ cidface->family_name = info->family_name; /* assume "Regular" style if we don't know better */ cidface->style_name = (char *)"Regular"; if ( cidface->family_name ) { char* full = info->full_name; char* family = cidface->family_name; if ( full ) { while ( *full ) { if ( *full == *family ) { family++; full++; }//.........这里部分代码省略.........
开发者ID:0uyangsheng,项目名称:xbmc,代码行数:101,
注:本文中的FT_STREAM_SEEK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FT_STREAM_SKIP函数代码示例 C++ FT_STREAM_READ_FIELDS函数代码示例 |