本文整理汇总了C++中FT_STREAM_READ_FIELDS函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_STREAM_READ_FIELDS函数的具体用法?C++ FT_STREAM_READ_FIELDS怎么用?C++ FT_STREAM_READ_FIELDS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FT_STREAM_READ_FIELDS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: check_table_dir
static FT_Error
check_table_dir( SFNT_Header sfnt,
FT_Stream stream )
{
FT_Error error;
FT_UShort 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 )
{
//BUGID: 53876, the cmap table is invalid, the font file couldn't be used.
if (table.Tag == TTAG_cmap) break;
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 = FT_THROW( 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 = FT_THROW( 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;
//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,代码来源:ttload.c
示例2: 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_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 %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->CheckSum ));
entry++;
}
}
FT_FRAME_EXIT();
//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,代码来源:ttload.c
示例3: fnt_face_get_dll_fonts
static FT_Error
fnt_face_get_dll_fonts( FNT_Face face )
{
FT_Error error;
FT_Stream stream = FT_FACE( face )->stream;
FT_Memory memory = FT_FACE( face )->memory;
WinMZ_HeaderRec mz_header;
face->fonts = 0;
face->num_fonts = 0;
/* does it begin with a MZ header? */
if ( FT_STREAM_SEEK( 0 ) ||
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
goto Exit;
error = FNT_Err_Unknown_File_Format;
if ( mz_header.magic == WINFNT_MZ_MAGIC )
{
/* yes, now look for a NE header in the file */
WinNE_HeaderRec ne_header;
if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
goto Exit;
error = FNT_Err_Unknown_File_Format;
if ( ne_header.magic == WINFNT_NE_MAGIC )
{
/* good, now look in the resource table for each FNT resource */
FT_ULong res_offset = mz_header.lfanew +
ne_header.resource_tab_offset;
FT_UShort size_shift;
FT_UShort font_count = 0;
FT_ULong font_offset = 0;
if ( FT_STREAM_SEEK( res_offset ) ||
FT_FRAME_ENTER( ne_header.rname_tab_offset -
ne_header.resource_tab_offset ) )
goto Exit;
size_shift = FT_GET_USHORT_LE();
for (;;)
{
FT_UShort type_id, count;
type_id = FT_GET_USHORT_LE();
if ( !type_id )
break;
count = FT_GET_USHORT_LE();
if ( type_id == 0x8008 )
{
font_count = count;
font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
( stream->cursor - stream->limit ) );
break;
}
stream->cursor += 4 + count * 12;
}
FT_FRAME_EXIT();
if ( !font_count || !font_offset )
{
FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
error = FNT_Err_Unknown_File_Format;
goto Exit;
}
if ( FT_STREAM_SEEK( font_offset ) ||
FT_NEW_ARRAY( face->fonts, font_count ) )
goto Exit;
face->num_fonts = font_count;
if ( FT_FRAME_ENTER( (FT_Long)font_count * 12 ) )
goto Exit;
/* now read the offset and position of each FNT font */
{
FNT_Font cur = face->fonts;
FNT_Font limit = cur + font_count;
for ( ; cur < limit; cur++ )
{
cur->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
cur->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
cur->size_shift = size_shift;
stream->cursor += 8;
}
}
//.........这里部分代码省略.........
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:101,代码来源:winfnt.c
示例4: sfnt_open_font
/* synthesized into a TTC with one offset table. */
static FT_Error
sfnt_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
static const FT_Frame_Field ttc_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TTC_HeaderRec
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
FT_FRAME_LONG( count ),
FT_FRAME_END
};
face->ttc_header.tag = 0;
face->ttc_header.version = 0;
face->ttc_header.count = 0;
offset = FT_STREAM_POS();
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) &&
tag != TTAG_true &&
tag != 0x00020000UL )
return SFNT_Err_Unknown_File_Format;
face->ttc_header.tag = TTAG_ttcf;
if ( tag == TTAG_ttcf )
{
FT_Int n;
FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
return error;
for ( n = 0; n < face->ttc_header.count; n++ )
face->ttc_header.offsets[n] = FT_GET_ULONG();
FT_FRAME_EXIT();
}
else
{
FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
face->ttc_header.version = 1 << 16;
face->ttc_header.count = 1;
if ( FT_NEW( face->ttc_header.offsets) )
return error;
face->ttc_header.offsets[0] = offset;
}
return error;
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:76,代码来源:sfobjs.c
示例5: 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:sheldonrobinson,项目名称:VcXsrv,代码行数:101,代码来源:pcfread.c
示例6: 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;
FT_ULong size;
if ( FT_STREAM_SEEK( 0 ) ||
FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
return FT_THROW( Cannot_Open_Resource );
if ( toc->version != PCF_FILE_VERSION ||
toc->count > FT_ARRAY_MAX( face->toc.tables ) ||
toc->count == 0 )
return FT_THROW( Invalid_File_Format );
if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
return FT_THROW( 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 ) )
{
error = FT_THROW( Invalid_Offset );
goto Exit;
}
}
if ( !have_change )
break;
}
/*
* We now check whether the `size' and `offset' values are reasonable:
* `offset' + `size' must not exceed the stream size.
*
* Note, however, that X11's `pcfWriteFont' routine (used by the
* `bdftopcf' program to create PDF font files) has two special
* features.
*
* - It always assigns the accelerator table a size of 100 bytes in the
* TOC, regardless of its real size, which can vary between 34 and 72
* bytes.
*
* - Due to the way the routine is designed, it ships out the last font
* table with its real size, ignoring the TOC's size value. Since
* the TOC size values are always rounded up to a multiple of 4, the
* difference can be up to three bytes for all tables except the
* accelerator table, for which the difference can be as large as 66
* bytes.
*
*/
tables = face->toc.tables;
size = stream->size;
for ( n = 0; n < toc->count - 1; n++ )
{
/* we need two checks to avoid overflow */
if ( ( tables->size > size ) ||
//.........这里部分代码省略.........
开发者ID:OpenTechEngine,项目名称:OpenTechBFG,代码行数:101,代码来源:pcfread.c
示例7: sfnt_open_font
/* synthesized into a TTC with one offset table. */
static FT_Error
sfnt_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
static const FT_Frame_Field ttc_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TTC_HeaderRec
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
FT_FRAME_LONG( count ), /* this is ULong in the specs */
FT_FRAME_END
};
face->ttc_header.tag = 0;
face->ttc_header.version = 0;
face->ttc_header.count = 0;
offset = FT_STREAM_POS();
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
tag != 0x00020000UL )
{
FT_TRACE2(( " not a font using the SFNT container format\n" ));
return FT_THROW( Unknown_File_Format );
}
face->ttc_header.tag = TTAG_ttcf;
if ( tag == TTAG_ttcf )
{
FT_Int n;
FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
if ( face->ttc_header.count == 0 )
return FT_THROW( Invalid_Table );
/* a rough size estimate: let's conservatively assume that there */
/* is just a single table info in each subfont header (12 + 16*1 = */
/* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
/* size of the TTC header plus `28*count' bytes for all subfont */
/* headers */
if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
return FT_THROW( Array_Too_Large );
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
return error;
for ( n = 0; n < face->ttc_header.count; n++ )
face->ttc_header.offsets[n] = FT_GET_ULONG();
FT_FRAME_EXIT();
}
else
{
FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
face->ttc_header.version = 1 << 16;
face->ttc_header.count = 1;
if ( FT_NEW( face->ttc_header.offsets ) )
return error;
face->ttc_header.offsets[0] = offset;
}
return error;
}
开发者ID:kobolabs,项目名称:qt-everywhere-4.8.0,代码行数:91,代码来源:sfobjs.c
示例8: tt_face_load_os2
tt_face_load_os2( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_OS2* os2;
static const FT_Frame_Field os2_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_OS2
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
};
static const FT_Frame_Field os2_fields_extra[] =
{
FT_FRAME_START( 8 ),
FT_FRAME_ULONG( ulCodePageRange1 ),
FT_FRAME_ULONG( ulCodePageRange2 ),
FT_FRAME_END
};
static 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
};
/* 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 )
goto Exit;
os2 = &face->os2;
if ( FT_STREAM_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 )
{
//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,代码来源:ttload.c
示例9: tt_face_load_maxp
tt_face_load_maxp( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_MaxProfile* maxProfile = &face->max_profile;
const FT_Frame_Field maxp_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_MaxProfile
FT_FRAME_START( 6 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( numGlyphs ),
FT_FRAME_END
};
const FT_Frame_Field maxp_fields_extra[] =
{
FT_FRAME_START( 26 ),
FT_FRAME_USHORT( maxPoints ),
FT_FRAME_USHORT( maxContours ),
FT_FRAME_USHORT( maxCompositePoints ),
FT_FRAME_USHORT( maxCompositeContours ),
FT_FRAME_USHORT( maxZones ),
FT_FRAME_USHORT( maxTwilightPoints ),
FT_FRAME_USHORT( maxStorage ),
FT_FRAME_USHORT( maxFunctionDefs ),
FT_FRAME_USHORT( maxInstructionDefs ),
FT_FRAME_USHORT( maxStackElements ),
FT_FRAME_USHORT( maxSizeOfInstructions ),
FT_FRAME_USHORT( maxComponentElements ),
FT_FRAME_USHORT( maxComponentDepth ),
FT_FRAME_END
};
error = face->goto_table( face, TTAG_maxp, stream, 0 );
if ( error )
goto Exit;
if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
goto Exit;
maxProfile->maxPoints = 0;
maxProfile->maxContours = 0;
maxProfile->maxCompositePoints = 0;
maxProfile->maxCompositeContours = 0;
maxProfile->maxZones = 0;
maxProfile->maxTwilightPoints = 0;
maxProfile->maxStorage = 0;
maxProfile->maxFunctionDefs = 0;
maxProfile->maxInstructionDefs = 0;
maxProfile->maxStackElements = 0;
maxProfile->maxSizeOfInstructions = 0;
maxProfile->maxComponentElements = 0;
maxProfile->maxComponentDepth = 0;
if ( maxProfile->version >= 0x10000L )
{
if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
goto Exit;
/* XXX: an adjustment that is necessary to load certain */
/* broken fonts like `Keystrokes MT' :-( */
/* */
/* We allocate 64 function entries by default when */
/* the maxFunctionDefs field is null. */
if ( maxProfile->maxFunctionDefs == 0 )
maxProfile->maxFunctionDefs = 64;
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
Exit:
return error;
}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:78,代码来源:ttload.c
示例10: cff_font_load
cff_font_load( FT_Stream stream,
FT_Int face_index,
CFF_Font font )
{
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_new_index( &font->name_index, stream, 0 )) ||
FT_SET_ERROR( cff_new_index( &font->font_dict_index, stream, 0 )) ||
FT_SET_ERROR( cff_new_index( &font->string_index, stream, 0 )) ||
FT_SET_ERROR( cff_new_index( &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;
/* now, check for a CID font */
if ( dict->cid_registry )
{
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 ) )
goto Exit;
error = cff_new_index( &fd_index, stream, 0 );
if ( error )
goto Exit;
if ( fd_index.count > CFF_MAX_CID_FONTS )
{
FT_ERROR(( "cff_font_load: FD array too large in CID font\n" ));
goto Fail_CID;
}
/* allocate & read each font dict independently */
//.........这里部分代码省略.........
开发者ID:1tgr,项目名称:mobius,代码行数:101,代码来源:cffload.c
示例11: 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;
TT_TableRec* limit;
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 ) )
return error;
/* 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(( "-- Tables count: %12u\n", sfnt.num_tables ));
FT_TRACE2(( "-- Format version: %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!\n" ));
return error;
}
face->num_tables = sfnt.num_tables;
face->format_tag = sfnt.format_tag;
if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )
return error;
if ( FT_STREAM_SEEK( sfnt.offset + 12 ) ||
FT_FRAME_ENTER( face->num_tables * 16L ) )
return error;
entry = face->dir_tables;
limit = entry + face->num_tables;
for ( ; entry < limit; entry++ )
{
entry->Tag = FT_GET_TAG4();
entry->CheckSum = FT_GET_ULONG();
entry->Offset = FT_GET_LONG();
entry->Length = FT_GET_LONG();
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 ));
}
FT_FRAME_EXIT();
FT_TRACE2(( "table directory loaded\n\n" ));
return error;
}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:89,代码来源:ttload.c
示例12: check_table_dir
static FT_Error
check_table_dir( SFNT_Header sfnt,
FT_Stream stream )
{
FT_Error error;
FT_UInt nn;
FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
FT_ULong offset = sfnt->offset + 12;
const FT_ULong glyx_tag = FT_MAKE_TAG( 'g', 'l', 'y', 'x' );
const FT_ULong locx_tag = FT_MAKE_TAG( 'l', 'o', 'c', 'x' );
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 ( sfnt->num_tables == 0 ||
offset + sfnt->num_tables * 16 > stream->size )
return SFNT_Err_Unknown_File_Format;
if ( FT_STREAM_SEEK( offset ) )
return error;
for ( nn = 0; nn < sfnt->num_tables; nn++ )
{
TT_TableRec table;
if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )
return error;
if ( table.Offset + table.Length > stream->size &&
table.Tag != glyx_tag &&
table.Tag != locx_tag )
return SFNT_Err_Unknown_File_Format;
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 )
return SFNT_Err_Unknown_File_Format;
if ( FT_STREAM_SEEK( table.Offset + 12 ) ||
FT_READ_ULONG( magic ) )
return error;
if ( magic != 0x5F0F3CF5UL )
return SFNT_Err_Unknown_File_Format;
if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )
return error;
}
else if ( table.Tag == TTAG_SING )
has_sing = 1;
else if ( table.Tag == TTAG_META )
has_meta = 1;
}
/* if `sing' and `meta' tables are present, there is no `head' table */
if ( has_head || ( has_sing && has_meta ) )
return SFNT_Err_Ok;
else
return SFNT_Err_Unknown_File_Format;
}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:90,代码来源:ttload.c
示例13: woff_open_font
static FT_Error
woff_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error = FT_Err_Ok;
WOFF_HeaderRec woff;
WOFF_Table tables = NULL;
WOFF_Table* indices = NULL;
FT_ULong woff_offset;
FT_Byte* sfnt = NULL;
FT_Stream sfnt_stream = NULL;
FT_Byte* sfnt_header;
FT_ULong sfnt_offset;
FT_Int nn;
FT_ULong old_tag = 0;
static const FT_Frame_Field woff_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE WOFF_HeaderRec
FT_FRAME_START( 44 ),
FT_FRAME_ULONG ( signature ),
FT_FRAME_ULONG ( flavor ),
FT_FRAME_ULONG ( length ),
FT_FRAME_USHORT( num_tables ),
FT_FRAME_USHORT( reserved ),
FT_FRAME_ULONG ( totalSfntSize ),
FT_FRAME_USHORT( majorVersion ),
FT_FRAME_USHORT( minorVersion ),
FT_FRAME_ULONG ( metaOffset ),
FT_FRAME_ULONG ( metaLength ),
FT_FRAME_ULONG ( metaOrigLength ),
FT_FRAME_ULONG ( privOffset ),
FT_FRAME_ULONG ( privLength ),
FT_FRAME_END
};
FT_ASSERT( stream == face->root.stream );
FT_ASSERT( FT_STREAM_POS() == 0 );
if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
return error;
/* Make sure we don't recurse back here or hit TTC code. */
if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
return FT_THROW( Invalid_Table );
/* Miscellaneous checks. */
if ( woff.length != stream->size ||
woff.num_tables == 0 ||
44 + woff.num_tables * 20UL >= woff.length ||
12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
( woff.totalSfntSize & 3 ) != 0 ||
( woff.metaOffset == 0 && ( woff.metaLength != 0 ||
woff.metaOrigLength != 0 ) ) ||
( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
( woff.privOffset == 0 && woff.privLength != 0 ) )
return FT_THROW( Invalid_Table );
if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||
FT_NEW( sfnt_stream ) )
goto Exit;
sfnt_header = sfnt;
/* Write sfnt header. */
{
FT_UInt searchRange, entrySelector, rangeShift, x;
x = woff.num_tables;
entrySelector = 0;
while ( x )
{
x >>= 1;
entrySelector += 1;
}
entrySelector--;
searchRange = ( 1 << entrySelector ) * 16;
rangeShift = woff.num_tables * 16 - searchRange;
WRITE_ULONG ( sfnt_header, woff.flavor );
WRITE_USHORT( sfnt_header, woff.num_tables );
WRITE_USHORT( sfnt_header, searchRange );
WRITE_USHORT( sfnt_header, entrySelector );
WRITE_USHORT( sfnt_header, rangeShift );
}
/* While the entries in the sfnt header must be sorted by the */
/* tag value, the tables themselves are not. We thus have to */
/* sort them by offset and check that they don't overlap. */
//.........这里部分代码省略.........
开发者ID:johndpope,项目名称:Medusa,代码行数:101,代码来源:sfobjs.c
示例14: tt_face_load_maxp
tt_face_load_maxp( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_MaxProfile* maxProfile = &face->max_profile;
static const FT_Frame_Field maxp_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_MaxProfile
FT_FRAME_START( 6 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( numGlyphs ),
FT_FRAME_END
};
static const FT_Frame_Field maxp_fields_extra[] =
{
FT_FRAME_START( 26 ),
FT_FRAME_USHORT( maxPoints ),
FT_FRAME_USHORT( maxContours ),
FT_FRAME_USHORT( maxCompositePoints ),
FT_FRAME_USHORT( maxCompositeContours ),
FT_FRAME_USHORT( maxZones ),
FT_FRAME_USHORT( maxTwilightPoints ),
FT_FRAME_USHORT( maxStorage ),
FT_FRAME_USHORT( maxFunctionDefs ),
FT_FRAME_USHORT( maxInstructionDefs ),
FT_FRAME_USHORT( maxStackElements ),
FT_FRAME_USHORT( maxSizeOfInstructions ),
FT_FRAME_USHORT( maxComponentElements ),
FT_FRAME_USHORT( maxComponentDepth ),
FT_FRAME_END
};
error = face->goto_table( face, TTAG_maxp, stream, 0 );
if ( error )
goto Exit;
if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
goto Exit;
maxProfile->maxPoints = 0;
maxProfile->maxContours = 0;
maxProfile->maxCompositePoints = 0;
maxProfile->maxCompositeContours = 0;
maxProfile->maxZones = 0;
maxProfile->maxTwilightPoints = 0;
maxProfile->maxStorage = 0;
maxProfile->maxFunctionDefs = 0;
maxProfile->maxInstructionDefs = 0;
maxProfile->maxStackElements = 0;
maxProfile->maxSizeOfInstructions = 0;
maxProfile->maxComponentElements = 0;
maxProfile->maxComponentDepth = 0;
if ( maxProfile->version >= 0x10000L )
{
if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
goto Exit;
/* XXX: an adjustment that is necessary to load certain */
/* broken fonts like `Keystrokes MT' :-( */
/* */
/* We allocate 64 function entries by default when */
/* the maxFunctionDefs value is smaller. */
if ( maxProfile->maxFunctionDefs < 64 )
maxProfile->maxFunctionDefs = 64;
/* we add 4 phantom points later */
if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
{
FT_TRACE0(( "tt_face_load_maxp:"
" too much twilight points in `maxp' table;\n"
" "
" some glyphs might be rendered incorrectly\n" ));
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
/* we arbitrarily limit recursion to avoid stack exhaustion */
if ( maxProfile->maxComponentDepth > 100 )
{
FT_TRACE0(( "tt_face_load_maxp:"
" abnormally large component depth (%d) set to 100\n",
maxProfile->maxComponentDepth ));
maxProfile->maxComponentDepth = 100;
}
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
Exit:
return error;
}
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:98,代码来源:ttload.c
示例15: fnt_face_get_dll_font
static FT_Error
fnt_face_get_dll_font( FNT_Face face,
FT_Int face_index )
{
FT_Error error;
FT_Stream stream = FT_FACE( face )->stream;
FT_Memory memory = FT_FACE( face )->memory;
WinMZ_HeaderRec mz_header;
face->font = 0;
/* does it begin with an MZ header? */
if ( FT_STREAM_SEEK( 0 ) ||
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
goto Exit;
error = FNT_Err_Unknown_File_Format;
if ( mz_header.magic == WINFNT_MZ_MAGIC )
{
/* yes, now look for an NE header in the file */
WinNE_HeaderRec ne_header;
if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
goto Exit;
error = FNT_Err_Unknown_File_Format;
if ( ne_header.magic == WINFNT_NE_MAGIC )
{
/* good, now look into the resource table for each FNT resource */
FT_ULong res_offset = mz_header.lfanew +
ne_header.resource_tab_offset;
FT_UShort size_shift;
FT_UShort font_count = 0;
FT_ULong font_offset = 0;
if ( FT_STREAM_SEEK( res_offset ) ||
FT_FRAME_ENTER( ne_header.rname_tab_offset -
ne_header.resource_tab_offset ) )
goto Exit;
size_shift = FT_GET_USHORT_LE();
for (;;)
{
FT_UShort type_id, count;
type_id = FT_GET_USHORT_LE();
if ( !type_id )
break;
count = FT_GET_USHORT_LE();
if ( type_id == 0x8008U )
{
font_count = count;
font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
( stream->cursor - stream->limit ) );
break;
}
stream->cursor += 4 + count * 12;
}
FT_FRAME_EXIT();
if ( !font_count || !font_offset )
{
FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
error = FNT_Err_Unknown_File_Format;
goto Exit;
}
face->root.num_faces = font_count;
if ( face_index >= font_count )
{
error = FNT_Err_Bad_Argument;
goto Exit;
}
if ( FT_NEW( face->font ) )
goto Exit;
if ( FT_STREAM_SEEK(
|
请发表评论