* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove

unused `max_points' and `max_contours'.

* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.

* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.

* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.

* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.

* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.

* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)

For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'.  Here, we try to
make this work for _all_ tables.

* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit.  Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.

* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.

* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.

* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
This commit is contained in:
Wu, Chia-I (吳佳一) 2006-02-15 07:44:31 +00:00
parent 5225402a52
commit 0d565fdc1d
18 changed files with 259 additions and 303 deletions

View File

@ -1,3 +1,51 @@
2006-02-15 Chia-I Wu <b90201047@ntu.edu.tw>
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-14 Werner Lemberg <wl@gnu.org>
* include/freetype/ftoutln.h (FT_Outline_Embolden): Mention in

View File

@ -213,9 +213,6 @@ FT_BEGIN_HEADER
/* */
typedef struct FT_Face_InternalRec_
{
FT_UShort max_points;
FT_Short max_contours;
FT_Matrix transform_matrix;
FT_Vector transform_delta;
FT_Int transform_flags;

View File

@ -1102,10 +1102,6 @@ FT_BEGIN_HEADER
/* table. We thus define additional fields */
/* below to hold the computed maxima. */
/* */
/* max_components :: The maximum number of glyph components */
/* required to load any composite glyph from */
/* this font. Used to size the load stack. */
/* */
/* vertical_info :: A boolean which is set when the font file */
/* contains vertical metrics. If not, the */
/* value of the `vertical' field is */
@ -1277,7 +1273,6 @@ FT_BEGIN_HEADER
#endif
TT_MaxProfile max_profile;
FT_ULong max_components;
FT_Bool vertical_info;
TT_VertHeader vertical; /* TT Vertical header, if present */

View File

@ -116,10 +116,14 @@ FT_BEGIN_HEADER
cff_size_request( FT_Size size,
FT_Size_Request req );
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
FT_LOCAL( FT_Error )
cff_size_select( FT_Size size,
FT_ULong index );
#endif
FT_LOCAL( void )
cff_slot_done( FT_GlyphSlot slot );

View File

@ -429,9 +429,6 @@
cidface->underline_position = (FT_Short)info->underline_position;
cidface->underline_thickness = (FT_Short)info->underline_thickness;
cidface->internal->max_points = 0;
cidface->internal->max_contours = 0;
}
Exit:

View File

@ -434,6 +434,7 @@
0,
0,
0,
0,
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */

View File

@ -481,9 +481,36 @@
}
#undef LOAD_
#define LOAD_( x ) ( ( error = sfnt->load_##x( face, stream ) ) \
!= SFNT_Err_Ok )
#define LOAD_( x ) \
do { \
FT_TRACE2(( "`" #x "' " )); \
FT_TRACE3(( "-->\n" )); \
\
error = sfnt->load_##x( face, stream ); \
\
FT_TRACE2(( "%s\n", ( !error ) \
? "loaded" \
: ( error == SFNT_Err_Table_Missing ) \
? "missing" \
: "failed to load" )); \
FT_TRACE3(( "\n" )); \
} while ( 0 )
#define LOADM_( x, vertical ) \
do { \
FT_TRACE2(( "`%s" #x "' ", \
vertical ? "vertical " : "" )); \
FT_TRACE3(( "-->\n" )); \
\
error = sfnt->load_##x( face, stream, vertical ); \
\
FT_TRACE2(( "%s\n", ( !error ) \
? "loaded" \
: ( error == SFNT_Err_Table_Missing ) \
? "missing" \
: "failed to load" )); \
FT_TRACE3(( "\n" )); \
} while ( 0 )
FT_LOCAL_DEF( FT_Error )
@ -521,6 +548,8 @@
/* it doesn't contain outlines. */
/* */
FT_TRACE2(( "sfnt_load_face: %08p\n\n", face ));
/* do we have outlines in there? */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 ||
@ -533,40 +562,50 @@
is_apple_sbit = 0;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* if this font doesn't contain outlines, we try to load */
/* a `bhed' table */
if ( !has_outline )
is_apple_sbit = FT_BOOL( !LOAD_( bhed ) );
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
if ( !has_outline && sfnt->load_bhed )
{
LOAD_( bhed );
is_apple_sbit = !error;
}
/* load the font header (`head' table) if this isn't an Apple */
/* sbit font file */
if ( !is_apple_sbit && LOAD_( head ) )
if ( !is_apple_sbit )
{
LOAD_( head );
if ( error )
goto Exit;
}
if ( face->header.Units_Per_EM == 0 )
{
error = SFNT_Err_Invalid_Table;
goto Exit;
}
/* the following tables are often not present in embedded TrueType */
/* fonts within PDF documents, so don't check for them. */
(void)LOAD_( maxp );
(void)LOAD_( cmap );
LOAD_( maxp );
LOAD_( cmap );
/* the following tables are optional in PCL fonts -- */
/* don't check for errors */
(void)LOAD_( name );
psnames_error = LOAD_( post );
LOAD_( name );
LOAD_( post );
psnames_error = error;
/* do not load the metrics headers and tables if this is an Apple */
/* sbit font file */
if ( !is_apple_sbit )
{
/* load the `hhea' and `hmtx' tables */
error = sfnt->load_hhea( face, stream, 0 );
LOADM_( hhea, 0 );
if ( !error )
{
error = sfnt->load_hmtx( face, stream, 0 );
LOADM_( hmtx, 0 );
if ( error == SFNT_Err_Table_Missing )
{
error = SFNT_Err_Hmtx_Table_Missing;
@ -590,6 +629,7 @@
if ( face->format_tag == TTAG_true )
{
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
has_outline = 0;
error = SFNT_Err_Ok;
}
else
@ -600,10 +640,10 @@
goto Exit;
/* try to load the `vhea' and `vmtx' tables */
error = sfnt->load_hhea( face, stream, 1 );
LOADM_( hhea, 1 );
if ( !error )
{
error = sfnt->load_hmtx( face, stream, 1 );
LOADM_( hmtx, 1 );
if ( !error )
face->vertical_info = 1;
}
@ -611,35 +651,50 @@
if ( error && error != SFNT_Err_Table_Missing )
goto Exit;
if ( LOAD_( os2 ) )
goto Exit;
LOAD_( os2 );
if ( error )
{
if ( error != SFNT_Err_Table_Missing )
goto Exit;
face->os2.version = 0xFFFFU;
}
}
/* the optional tables */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* embedded bitmap support. */
if ( sfnt->load_eblc && LOAD_( eblc ) )
if ( sfnt->load_eblc )
{
/* return an error if this font file has no outlines */
if ( error == SFNT_Err_Table_Missing && has_outline )
error = SFNT_Err_Ok;
else
goto Exit;
LOAD_( eblc );
if ( error )
{
/* return an error if this font file has no outlines */
if ( error == SFNT_Err_Table_Missing && has_outline )
error = SFNT_Err_Ok;
else
goto Exit;
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
LOAD_( pclt );
if ( error )
{
if ( error != SFNT_Err_Table_Missing )
goto Exit;
if ( LOAD_( pclt ) )
goto Exit;
face->pclt.Version = 0;
}
/* consider the kerning and gasp tables as optional */
(void)LOAD_( gasp );
(void)LOAD_( kern );
LOAD_( gasp );
LOAD_( kern );
error = SFNT_Err_Ok;
face->root.num_glyphs = face->max_profile.numGlyphs;
face->root.family_name = tt_face_get_name( face,
TT_NAME_ID_PREFERRED_FAMILY );
if ( !face->root.family_name )
@ -847,18 +902,80 @@
root->underline_position = face->postscript.underlinePosition;
root->underline_thickness = face->postscript.underlineThickness;
/* root->max_points -- already set up */
/* root->max_contours -- already set up */
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/*
* Now allocate the root array of FT_Bitmap_Size records and
* populate them. Unfortunately, it isn't possible to indicate bit
* depths in the FT_Bitmap_Size record. This is a design error.
*/
{
FT_UInt i, count;
#ifdef FT_OPTIMIZE_MEMORY
count = face->sbit_num_strikes;
#else
count = (FT_UInt)face->num_sbit_strikes;
#endif
if ( count > 0 )
{
FT_Memory memory = face->root.stream->memory;
FT_UShort em_size = face->header.Units_Per_EM;
FT_Short avgwidth = face->os2.xAvgCharWidth;
FT_Size_Metrics metrics;
if ( em_size == 0 || face->os2.version == 0xFFFFU )
{
avgwidth = 0;
em_size = 1;
}
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
goto Exit;
for ( i = 0; i < count; i++ )
{
FT_Bitmap_Size* bsize = root->available_sizes + i;
error = sfnt->load_strike_metrics( face, i, &metrics );
if ( error )
goto Exit;
bsize->height = metrics.height >> 6;
bsize->width = (FT_Short)(
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
bsize->x_ppem = metrics.x_ppem << 6;
bsize->y_ppem = metrics.y_ppem << 6;
/* assume 72dpi */
bsize->size = metrics.y_ppem << 6;
}
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
root->num_fixed_sizes = (FT_Int)count;
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
}
Exit:
FT_TRACE2(( "sfnt_load_face: done\n" ));
return error;
}
#undef LOAD_
#undef LOADM_
FT_LOCAL_DEF( void )

View File

@ -2291,7 +2291,7 @@
ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
FT_VALIDATE_DEFAULT );
valid.num_glyphs = (FT_UInt)face->root.num_glyphs;
valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 )
{

View File

@ -60,7 +60,7 @@
TT_Table limit;
FT_TRACE3(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ",
FT_TRACE4(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ",
face,
(FT_Char)( tag >> 24 ),
(FT_Char)( tag >> 16 ),
@ -76,12 +76,12 @@
/* tables the same as missing tables. */
if ( entry->Tag == tag && entry->Length != 0 )
{
FT_TRACE3(( "found table.\n" ));
FT_TRACE4(( "found table.\n" ));
return entry;
}
}
FT_TRACE3(( "could not find table!\n" ));
FT_TRACE4(( "could not find table!\n" ));
return 0;
}
@ -493,29 +493,17 @@
};
FT_TRACE2(( "tt_face_load_generic_header: "
"%08p, looking up font table `%c%c%c%c'.\n",
face,
(FT_Char)( tag >> 24 ),
(FT_Char)( tag >> 16 ),
(FT_Char)( tag >> 8 ),
(FT_Char)( tag ) ));
error = face->goto_table( face, tag, stream, 0 );
if ( error )
{
FT_TRACE2(( "tt_face_load_generic_header: Font table is missing!\n" ));
goto Exit;
}
header = &face->header;
if ( FT_STREAM_READ_FIELDS( header_fields, header ) )
goto Exit;
FT_TRACE2(( " Units per EM: %8u\n", header->Units_Per_EM ));
FT_TRACE2(( " IndexToLoc: %8d\n", header->Index_To_Loc_Format ));
FT_TRACE2(( "tt_face_load_generic_header: Font table loaded.\n" ));
FT_TRACE3(( "Units per EM: %4u\n", header->Units_Per_EM ));
FT_TRACE3(( "IndexToLoc: %4d\n", header->Index_To_Loc_Format ));
Exit:
return error;
@ -596,8 +584,6 @@
};
FT_TRACE2(( "Load_TT_MaxProfile: %08p\n", face ));
error = face->goto_table( face, TTAG_maxp, stream, 0 );
if ( error )
goto Exit;
@ -605,8 +591,6 @@
if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
goto Exit;
face->root.num_glyphs = maxProfile->numGlyphs;
maxProfile->maxPoints = 0;
maxProfile->maxContours = 0;
maxProfile->maxCompositePoints = 0;
@ -634,30 +618,9 @@
if ( maxProfile->maxFunctionDefs == 0 )
maxProfile->maxFunctionDefs = 64;
face->root.internal->max_points =
(FT_UShort)FT_MAX( maxProfile->maxCompositePoints,
maxProfile->maxPoints );
face->root.internal->max_contours =
(FT_Short)FT_MAX( maxProfile->maxCompositeContours,
maxProfile->maxContours );
face->max_components = (FT_ULong)maxProfile->maxComponentElements +
maxProfile->maxComponentDepth;
/* XXX: some fonts have maxComponents set to 0; we will */
/* then use 16 of them by default. */
if ( face->max_components == 0 )
face->max_components = 16;
/* We also increase maxPoints and maxContours in order to support */
/* some broken fonts. */
face->root.internal->max_points += (FT_UShort)8;
face->root.internal->max_contours += (FT_Short) 4;
}
FT_TRACE2(( "MAXP loaded.\n" ));
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
Exit:
return error;
@ -722,16 +685,9 @@
table = &face->name_table;
table->stream = stream;
FT_TRACE2(( "Names " ));
error = face->goto_table( face, TTAG_name, stream, &table_len );
if ( error )
{
/* The name table is required so indicate failure. */
FT_TRACE2(( "is missing!\n" ));
error = SFNT_Err_Name_Table_Missing;
goto Exit;
}
table_pos = FT_STREAM_POS();
@ -751,7 +707,7 @@
if ( storage_start > storage_limit )
{
FT_ERROR(( "tt_face_load_names: invalid `name' table\n" ));
FT_ERROR(( "invalid `name' table\n" ));
error = SFNT_Err_Name_Table_Missing;
goto Exit;
}
@ -798,8 +754,6 @@
FT_FRAME_EXIT();
FT_TRACE2(( "loaded\n" ));
/* everything went well, update face->num_names */
face->num_names = (FT_UShort) table->numNameRecords;
@ -873,19 +827,10 @@
error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
if ( error )
{
FT_TRACE2(( "No `cmap' table in font !\n" ));
error = SFNT_Err_CMap_Table_Missing;
goto Exit;
}
if ( !FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
FT_TRACE2(( "`cmap' table loaded\n" ));
else
{
FT_ERROR(( "`cmap' table is too short!\n" ));
if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
face->cmap_size = 0;
}
Exit:
return error;
@ -988,19 +933,12 @@
};
FT_TRACE2(( "OS/2 Table " ));
/* We now support old Mac fonts where the OS/2 table doesn't */
/* exist. Simply put, we set the `version' field to 0xFFFF */
/* and test this value each time we need to access the table. */
error = face->goto_table( face, TTAG_OS2, stream, 0 );
if ( error )
{
FT_TRACE2(( "is missing!\n" ));
face->os2.version = 0xFFFFU;
error = SFNT_Err_Ok;
goto Exit;
}
os2 = &face->os2;
@ -1029,7 +967,11 @@
}
}
FT_TRACE2(( "loaded\n" ));
FT_TRACE3(( "sTypoAscender: %4d\n", os2->sTypoAscender ));
FT_TRACE3(( "sTypoDescender: %4d\n", os2->sTypoDescender ));
FT_TRACE3(( "usWinAscent: %4u\n", os2->usWinAscent ));
FT_TRACE3(( "usWinDescent: %4u\n", os2->usWinDescent ));
FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection ));
Exit:
return error;
@ -1078,18 +1020,19 @@
};
FT_TRACE2(( "PostScript " ));
error = face->goto_table( face, TTAG_post, stream, 0 );
if ( error )
return SFNT_Err_Post_Table_Missing;
return error;
if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
return error;
/* we don't load the glyph names, we do that in another */
/* module (ttpost). */
FT_TRACE2(( "loaded\n" ));
FT_TRACE3(( "FormatType: 0x%x\n", post->FormatType ));
FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
? " yes" : " no" ));
return SFNT_Err_Ok;
}
@ -1142,22 +1085,14 @@
TT_PCLT* pclt = &face->pclt;
FT_TRACE2(( "PCLT " ));
/* optional table */
error = face->goto_table( face, TTAG_PCLT, stream, 0 );
if ( error )
{
FT_TRACE2(( "missing (optional)\n" ));
pclt->Version = 0;
return SFNT_Err_Ok;
}
goto Exit;
if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
goto Exit;
FT_TRACE2(( "loaded\n" ));
Exit:
return error;
}
@ -1190,12 +1125,10 @@
TT_GaspRange gaspranges;
FT_TRACE2(( "tt_face_load_gasp: %08p\n", face ));
/* the gasp table is optional */
error = face->goto_table( face, TTAG_gasp, stream, 0 );
if ( error )
return SFNT_Err_Ok;
goto Exit;
if ( FT_FRAME_ENTER( 4L ) )
goto Exit;
@ -1206,7 +1139,7 @@
FT_FRAME_EXIT();
num_ranges = face->gasp.numRanges;
FT_TRACE3(( "number of ranges = %d\n", num_ranges ));
FT_TRACE3(( "numRanges: %u\n", num_ranges ));
if ( FT_QNEW_ARRAY( gaspranges, num_ranges ) ||
FT_FRAME_ENTER( num_ranges * 4L ) )
@ -1219,14 +1152,13 @@
gaspranges[j].maxPPEM = FT_GET_USHORT();
gaspranges[j].gaspFlag = FT_GET_USHORT();
FT_TRACE3(( " [max:%d flag:%d]",
gaspranges[j].maxPPEM,
gaspranges[j].gaspFlag ));
FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n",
j,
gaspranges[j].maxPPEM,
gaspranges[j].gaspFlag ));
}
FT_TRACE3(( "\n" ));
FT_FRAME_EXIT();
FT_TRACE2(( "GASP loaded\n" ));
Exit:
return error;

View File

@ -66,8 +66,6 @@
FT_ULong* ptable_size;
FT_TRACE2(( "%cmtx ", vertical ? 'v' : 'h' ));
if ( vertical )
{
error = face->goto_table( face, TTAG_vmtx, stream, &table_size );
@ -92,14 +90,7 @@
*ptable_size = table_size;
return SFNT_Err_Ok;
Fail:
if ( error == SFNT_Err_Table_Missing )
FT_TRACE2(( "missing\n" ));
else
FT_TRACE2(( "failed\n" ));
return error;
}
@ -120,47 +111,34 @@
TT_ShortMetrics** shorts;
FT_TRACE2(( "%cmtx ", vertical ? 'v' : 'h' ));
if ( vertical )
{
error = face->goto_table( face, TTAG_vmtx, stream, &table_len );
if ( error )
{
/* Set number_Of_VMetrics to 0! */
face->vertical.number_Of_VMetrics = 0;
goto Fail;
}
num_longs = face->vertical.number_Of_VMetrics;
if ( num_longs > table_len / 4 )
{
num_longs = table_len / 4;
face->vertical.number_Of_VMetrics = num_longs;
}
longs = (TT_LongMetrics *) &face->vertical.long_metrics;
face->vertical.number_Of_VMetrics = 0;
longs = (TT_LongMetrics *)&face->vertical.long_metrics;
shorts = (TT_ShortMetrics**)&face->vertical.short_metrics;
}
else
{
error = face->goto_table( face, TTAG_hmtx, stream, &table_len );
if ( error )
{
face->horizontal.number_Of_HMetrics = 0;
goto Fail;
}
num_longs = face->horizontal.number_Of_HMetrics;
if ( num_longs > table_len / 4 )
{
num_longs = table_len / 4;
face->horizontal.number_Of_HMetrics = num_longs;
}
longs = (TT_LongMetrics *) &face->horizontal.long_metrics;
face->horizontal.number_Of_HMetrics = 0;
longs = (TT_LongMetrics *)&face->horizontal.long_metrics;
shorts = (TT_ShortMetrics**)&face->horizontal.short_metrics;
}
@ -171,8 +149,7 @@
if ( num_shorts < 0 )
{
FT_ERROR(( "%cmtx: more metrics than glyphs!\n",
vertical ? 'v' : 'h' ));
FT_ERROR(( "%cmtx has more metrics than glyphs.\n" ));
/* Adobe simply ignores this problem. So we shall do the same. */
#if 0
@ -229,16 +206,12 @@
FT_FRAME_EXIT();
FT_TRACE2(( "loaded\n" ));
return SFNT_Err_Ok;
if ( vertical )
face->vertical.number_Of_VMetrics = num_longs;
else
face->horizontal.number_Of_HMetrics = num_longs;
Fail:
if ( error == SFNT_Err_Table_Missing )
FT_TRACE2(( "missing\n" ));
else
FT_TRACE2(( "failed\n" ));
return error;
}
@ -298,8 +271,6 @@
};
FT_TRACE2(( "%chea ", vertical ? 'v' : 'h' ));
if ( vertical )
{
error = face->goto_table( face, TTAG_vhea, stream, 0 );
@ -320,19 +291,14 @@
if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) )
goto Fail;
FT_TRACE3(( "Ascender: %5d\n", header->Ascender ));
FT_TRACE3(( "Descenter: %5d\n", header->Descender ));
FT_TRACE3(( "number_Of_Metrics: %5u\n", header->number_Of_HMetrics ));
header->long_metrics = NULL;
header->short_metrics = NULL;
FT_TRACE2(( "loaded\n" ));
return SFNT_Err_Ok;
Fail:
if ( error == SFNT_Err_Table_Missing )
FT_TRACE2(( "missing\n" ));
else
FT_TRACE2(( "failed\n" ));
return error;
}
@ -438,7 +404,8 @@
FT_UShort k = header->number_Of_HMetrics;
if ( k == 0 || gindex >= (FT_UInt)face->max_profile.numGlyphs )
if ( k == 0 || !header->long_metrics ||
gindex >= (FT_UInt)face->max_profile.numGlyphs )
{
*abearing = *aadvance = 0;
return SFNT_Err_Ok;

View File

@ -175,7 +175,7 @@
/* There already exist fonts which have more than 32768 glyph names */
/* in this table, so the test for this threshold has been dropped. */
if ( num_glyphs > face->root.num_glyphs )
if ( num_glyphs > face->max_profile.numGlyphs )
{
error = SFNT_Err_Invalid_File_Format;
goto Exit;
@ -286,7 +286,7 @@
goto Exit;
/* check the number of glyphs */
if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 )
if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 )
{
error = SFNT_Err_Invalid_File_Format;
goto Exit;
@ -448,7 +448,7 @@
if ( !face )
return SFNT_Err_Invalid_Face_Handle;
if ( idx >= (FT_UInt)face->root.num_glyphs )
if ( idx >= (FT_UInt)face->max_profile.numGlyphs )
return SFNT_Err_Invalid_Glyph_Index;
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES

View File

@ -584,40 +584,6 @@
}
}
/* now set up the root fields to indicate the strikes */
if ( face->num_sbit_strikes )
{
FT_ULong n;
FT_Face root = FT_FACE( face );
if ( FT_NEW_ARRAY( root->available_sizes, face->num_sbit_strikes ) )
goto Exit;
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
{
FT_Bitmap_Size* bsize = root->available_sizes + n;
TT_SBit_Strike strike = face->sbit_strikes + n;
FT_UShort fupem = face->header.Units_Per_EM;
FT_Short avg = face->os2.xAvgCharWidth;
/* XXX: Is this correct? */
bsize->height = strike->hori.ascender - strike->hori.descender;
bsize->width =
(FT_Short)( ( avg * strike->y_ppem + fupem / 2 ) / fupem );
/* assume 72dpi */
bsize->size = strike->y_ppem << 6;
bsize->x_ppem = strike->x_ppem << 6;
bsize->y_ppem = strike->y_ppem << 6;
}
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
root->num_fixed_sizes = (FT_Int)face->num_sbit_strikes;
}
Exit:
return error;
}

View File

@ -94,7 +94,7 @@
FT_ULong num_strikes, table_size;
FT_Byte* p;
FT_Byte* p_limit;
FT_UInt nn, count;
FT_UInt count;
face->sbit_num_strikes = 0;
@ -142,50 +142,7 @@
face->sbit_num_strikes = count;
/*
* Now allocate the root array of FT_Bitmap_Size records and
* populate them. Unfortunately, it isn't possible to indicate bit
* depths in the FT_Bitmap_Size record. This is a design error.
*/
{
FT_Memory memory = face->root.stream->memory;
FT_UInt em_size = (FT_UInt)face->header.Units_Per_EM;
FT_Short avgwidth = face->os2.xAvgCharWidth;
if ( FT_NEW_ARRAY( face->root.available_sizes, count ) )
goto Fail;
for ( nn = 0; nn < count; nn++ )
{
FT_Bitmap_Size* bsize = face->root.available_sizes + nn;
FT_UInt x_ppem, y_ppem;
FT_Char ascender, descender;
ascender = (FT_Char)p[16];
descender = (FT_Char)p[17];
x_ppem = p[44];
y_ppem = p[45];
bsize->x_ppem = (FT_Pos)( x_ppem << 6 );
bsize->y_ppem = (FT_Pos)( y_ppem << 6 );
/* XXX: Is this correct? */
bsize->height = (FT_Short)( ascender - descender );
bsize->width = (FT_Short)( ( avgwidth * y_ppem + em_size / 2 ) /
em_size );
/* assume 72dpi */
bsize->size = bsize->y_ppem;
p += 48;
}
face->root.face_flags |= FT_FACE_FLAG_FIXED_SIZES;
face->root.num_fixed_sizes = count;
}
FT_TRACE3(( "sbit_num_strikes: %u\n", count ));
Exit:
return error;
@ -222,22 +179,20 @@
FT_ULong strike_index,
FT_Size_Metrics* metrics )
{
FT_Bitmap_Size* bsize;
FT_Byte* strike;
if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
return SFNT_Err_Invalid_Argument;
bsize = ( (FT_Face)face )->available_sizes + strike_index;
strike = face->sbit_table + 8 + strike_index * 48;
metrics->x_ppem = (FT_UShort)( bsize->x_ppem >> 6 );
metrics->y_ppem = (FT_UShort)( bsize->y_ppem >> 6 );
metrics->height = (FT_UShort)( bsize->height << 6 );
metrics->x_ppem = (FT_UShort)strike[44];
metrics->y_ppem = (FT_UShort)strike[45];
metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
metrics->height = metrics->ascender - metrics->descender;
/* XXX: Is this correct? */
metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */

View File

@ -175,7 +175,6 @@
tt_size_request( FT_Size size,
FT_Size_Request req )
{
TT_Face ttface = (TT_Face)size->face;
TT_Size ttsize = (TT_Size)size;
FT_Error error = TT_Err_Ok;
@ -184,6 +183,7 @@
if ( FT_HAS_FIXED_SIZES( size->face ) )
{
TT_Face ttface = (TT_Face)size->face;
SFNT_Service sfnt = ttface->sfnt;
FT_ULong index;

View File

@ -394,10 +394,6 @@
FT_Memory memory = exec->memory;
/* free composite load stack */
FT_FREE( exec->loadStack );
exec->loadSize = 0;
/* points zone */
exec->maxPoints = 0;
exec->maxContours = 0;
@ -462,11 +458,9 @@
exec->maxContours = 0;
exec->stackSize = 0;
exec->loadSize = 0;
exec->glyphSize = 0;
exec->stack = NULL;
exec->loadStack = NULL;
exec->glyphIns = NULL;
exec->face = NULL;
@ -594,14 +588,6 @@
exec->twilight = size->twilight;
}
error = Update_Max( exec->memory,
&exec->loadSize,
sizeof ( TT_SubGlyphRec ),
(void**)&exec->loadStack,
exec->face->max_components + 1 );
if ( error )
return error;
/* XXX: We reserve a little more elements on the stack to deal safely */
/* with broken fonts like arialbs, courbs, timesbs, etc. */
tmp = exec->stackSize;

View File

@ -216,9 +216,6 @@ FT_BEGIN_HEADER
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
FT_ULong loadSize;
TT_SubGlyph_Stack loadStack; /* loading subglyph stack */
FT_Bool grayscale; /* are we hinting for grayscale? */
} TT_ExecContextRec;

View File

@ -439,9 +439,6 @@
root->underline_position = (FT_Short)info->underline_position;
root->underline_thickness = (FT_Short)info->underline_thickness;
root->internal->max_points = 0;
root->internal->max_contours = 0;
}
{

View File

@ -302,9 +302,6 @@
root->underline_position = (FT_Short)info->underline_position;
root->underline_thickness = (FT_Short)info->underline_thickness;
root->internal->max_points = 0;
root->internal->max_contours = 0;
/* compute style flags */
root->style_flags = 0;
if ( info->italic_angle )