Fine-tuned a lot of tracing levels to make them more functional with ftview.

Added a lot of \n to tracing messages.

Fixed a serious bug in loading SBit offsets (missing parentheses around a
xxx ? yyy : zzz construct).

Replaced most GET_xxx() functions with calls to READ_Frame() in ttsbit.c
This commit is contained in:
Werner Lemberg 2000-06-06 20:41:48 +00:00
parent 920d41e038
commit 1c0d4acb25
11 changed files with 100 additions and 218 deletions

View File

@ -77,7 +77,7 @@
registry->cur_offset = 0;
driver->extensions = registry;
FT_TRACE2(( "FT_Init_Extensions: success" ));
FT_TRACE2(( "FT_Init_Extensions: success\n" ));
return FT_Err_Ok;
}
@ -153,7 +153,7 @@
registry->num_extensions++;
registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT;
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered",
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n",
cur->id ));
}
@ -204,7 +204,7 @@
{
*extension_interface = cur->interface;
FT_TRACE1(( "FT_Get_Extension: got `%s'", extension_id ));
FT_TRACE1(( "FT_Get_Extension: got `%s'\n", extension_id ));
return (void*)((char*)face->extensions + cur->offset);
}
@ -212,7 +212,7 @@
/* could not find the extension id */
FT_ERROR(( "FT_Get_Extension: couldn't find `%s'", extension_id ));
FT_ERROR(( "FT_Get_Extension: couldn't find `%s'\n", extension_id ));
*extension_interface = 0;

View File

@ -130,7 +130,7 @@ const FT_DriverInterface* ft_default_drivers[] =
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType:" ));
FT_ERROR(( " cannot find memory manager" ));
FT_ERROR(( " cannot find memory manager\n" ));
return FT_Err_Unimplemented_Feature;
}

View File

@ -565,7 +565,7 @@
break;
default:
FT_ERROR(( "Invalid profile direction in Raster:New_Profile !!\n" ));
FT_ERROR(( "New_Profile: invalid profile direction!\n" ));
ras.error = Raster_Err_Invalid;
return FAILURE;
}
@ -609,7 +609,7 @@
if ( h < 0 )
{
FT_ERROR(( "Negative height encountered in End_Profile!\n" ));
FT_ERROR(( "End_Profile: negative height encountered!\n" ));
ras.error = Raster_Err_Neg_Height;
return FAILURE;
}

View File

@ -138,7 +138,7 @@
if ( read_bytes < count )
{
FT_ERROR(( "FT_Read_Stream_At:" ));
FT_ERROR(( " invalid read; expected %lu bytes, got %lu",
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
error = FT_Err_Invalid_Stream_Operation;
@ -208,7 +208,7 @@
if ( read_bytes < count )
{
FT_ERROR(( "FT_Access_Frame:" ));
FT_ERROR(( " invalid read; expected %lu bytes, got %lu",
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FREE( stream->base );
@ -225,7 +225,7 @@
stream->pos + count > stream->size )
{
FT_ERROR(( "FT_Access_Frame:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx",
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
@ -364,7 +364,7 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Char:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@ -410,7 +410,7 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Short:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@ -456,7 +456,7 @@
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Offset:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
@ -501,7 +501,7 @@
Fail:
FT_ERROR(( "FT_Read_Long:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx",
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
*error = FT_Err_Invalid_Stream_Operation;

View File

@ -85,7 +85,7 @@
/* We must also be able to accept Mac/GX fonts, as well as OT ones */
if ( face->format_tag != 0x4f54544f ) /* OpenType/CFF font */
{
FT_TRACE2(( "[not a valid OpenType/CFF font]" ));
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
goto Bad_Format;
}

View File

@ -868,7 +868,7 @@
if ( strncmp( stream->cursor, "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
{
FT_ERROR(( "Not a valid CID-keyed font\n" ));
FT_ERROR(( "[not a valid CID-keyed font]\n" ));
error = FT_Err_Unknown_File_Format;
}

View File

@ -58,7 +58,7 @@
TT_Table* limit;
FT_TRACE3(( "TT_LookUp_Table: %08p, `%c%c%c%c' )\n",
FT_TRACE3(( "TT_LookUp_Table: %08p, `%c%c%c%c'\n",
face,
(TT_Char)( tag >> 24 ),
(TT_Char)( tag >> 16 ),

View File

@ -31,19 +31,12 @@ extern "C" {
#define TT_Err_Invalid_Post_Table_Format 0x0B00
#define TT_Err_Invalid_Post_Table 0x0B01
#if 0
/* the 258 standard Mac glyph names, used for format 1.0 and 2.5 */
LOCAL_DEF
const TT_String* TT_Mac_Postscript_Names[];
#endif
LOCAL_DEF
TT_Error TT_Get_PS_Name( TT_Face face,
TT_UInt index,
TT_String** PSname );
LOCAL_DEF
void TT_Free_Post_Names( TT_Face face );

View File

@ -170,96 +170,21 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_Small_SBit_Metrics */
/* */
/* <Description> */
/* Loads a small bitmap metrics record. */
/* */
/* <Input> */
/* stream :: The input stream. */
/* */
/* <Output> */
/* metrics :: A small metrics structure. */
/* */
static
void TT_Load_Small_SBit_Metrics( TT_SBit_Small_Metrics* metrics,
FT_Stream stream )
const FT_Frame_Field sbit_metrics_fields[] =
{
metrics->height = GET_Byte();
metrics->width = GET_Byte();
metrics->bearingX = GET_Char();
metrics->bearingY = GET_Char();
metrics->advance = GET_Byte();
}
FT_FRAME_START( 8 ),
FT_FRAME_BYTE( TT_SBit_Metrics, height ),
FT_FRAME_BYTE( TT_SBit_Metrics, width ),
FT_FRAME_CHAR( TT_SBit_Metrics, horiBearingX ),
FT_FRAME_CHAR( TT_SBit_Metrics, horiBearingY ),
FT_FRAME_BYTE( TT_SBit_Metrics, horiAdvance ),
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_SBit_Metrics */
/* */
/* <Description> */
/* Loads a bitmap metrics record. */
/* */
/* <Input> */
/* stream :: The input stream. */
/* */
/* <Output> */
/* metrics :: A metrics structure. */
/* */
static
void TT_Load_SBit_Metrics( TT_SBit_Metrics* metrics,
FT_Stream stream )
{
metrics->height = GET_Byte();
metrics->width = GET_Byte();
metrics->horiBearingX = GET_Char();
metrics->horiBearingY = GET_Char();
metrics->horiAdvance = GET_Byte();
metrics->vertBearingX = GET_Char();
metrics->vertBearingY = GET_Char();
metrics->vertAdvance = GET_Byte();
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_SBit_Line_Metrics */
/* */
/* <Description> */
/* Loads a bitmap line metrics record. */
/* */
/* <Input> */
/* stream :: The input stream. */
/* */
/* <Output> */
/* metrics :: A line metrics structure. */
/* */
static
void TT_Load_SBit_Line_Metrics( TT_SBit_Line_Metrics* metrics,
FT_Stream stream )
{
metrics->ascender = GET_Char();
metrics->descender = GET_Char();
metrics->max_width = GET_Byte();
metrics->caret_slope_numerator = GET_Char();
metrics->caret_slope_denominator = GET_Char();
metrics->caret_offset = GET_Char();
metrics->min_origin_SB = GET_Char();
metrics->min_advance_SB = GET_Char();
metrics->max_before_BL = GET_Char();
metrics->min_after_BL = GET_Char();
metrics->pads[0] = GET_Char();
metrics->pads[1] = GET_Char();
}
FT_FRAME_CHAR( TT_SBit_Metrics, vertBearingX ),
FT_FRAME_CHAR( TT_SBit_Metrics, vertBearingY ),
FT_FRAME_BYTE( TT_SBit_Metrics, vertAdvance ),
FT_FRAME_END
};
/*************************************************************************/
@ -285,15 +210,10 @@
TT_Error error;
if ( !ACCESS_Frame( 12L ) )
{
range->image_size = GET_ULong();
TT_Load_SBit_Metrics( &range->metrics, stream );
if ( READ_ULong( range->image_size ) )
return error;
FORGET_Frame();
}
return error;
return READ_Fields( sbit_metrics_fields, &range->metrics );
}
@ -400,7 +320,7 @@
range->num_glyphs = num_glyphs;
num_glyphs++; /* XXX: BEWARE - see spec */
size_elem = large ? 4 : 2;
size_elem = large ? 4 : 2;
if ( ALLOC_ARRAY( range->glyph_offsets,
num_glyphs, TT_ULong ) ||
@ -409,7 +329,8 @@
for ( n = 0; n < num_glyphs; n++ )
range->glyph_offsets[n] = (TT_ULong)( range->image_offset +
large ? GET_ULong() : GET_UShort() );
( large ? GET_ULong()
: GET_UShort() ) );
FORGET_Frame();
}
break;
@ -462,6 +383,26 @@
TT_ULong num_strikes;
TT_ULong table_base;
const FT_Frame_Field sbit_line_metrics_fields[] =
{
/* no FT_FRAME_START */
FT_FRAME_CHAR( TT_SBit_Line_Metrics, ascender ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, descender ),
FT_FRAME_BYTE( TT_SBit_Line_Metrics, max_width ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, caret_slope_numerator ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, caret_slope_denominator ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, caret_offset ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, min_origin_SB ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, min_advance_SB ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, max_before_BL ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, min_after_BL ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, pads[0] ),
FT_FRAME_CHAR( TT_SBit_Line_Metrics, pads[1] ),
FT_FRAME_END
};
face->num_sbit_strikes = 0;
@ -483,8 +424,8 @@
FORGET_Frame();
/* check version number and strike count */
if ( version != 0x00020000 ||
num_strikes >= 0x10000 )
if ( version != 0x00020000L ||
num_strikes >= 0x10000L )
{
FT_ERROR(( "TT_Load_SBit_Strikes: invalid table version!\n" ));
error = TT_Err_Invalid_File_Format;
@ -512,21 +453,21 @@
TT_ULong indexTablesSize;
strike->ranges_offset = GET_ULong();
indexTablesSize = GET_ULong(); /* don't save */
strike->ranges_offset = GET_ULong();
indexTablesSize = GET_ULong(); /* don't save */
strike->num_ranges = GET_ULong();
strike->color_ref = GET_ULong();
strike->num_ranges = GET_ULong();
strike->color_ref = GET_ULong();
TT_Load_SBit_Line_Metrics( &strike->hori, stream );
TT_Load_SBit_Line_Metrics( &strike->vert, stream );
(void)READ_Fields( sbit_line_metrics_fields, &strike->hori );
(void)READ_Fields( sbit_line_metrics_fields, &strike->vert );
strike->start_glyph = GET_UShort();
strike->end_glyph = GET_UShort();
strike->x_ppem = GET_Byte();
strike->y_ppem = GET_Byte();
strike->bit_depth = GET_Byte();
strike->flags = GET_Char();
strike->start_glyph = GET_UShort();
strike->end_glyph = GET_UShort();
strike->x_ppem = GET_Byte();
strike->y_ppem = GET_Byte();
strike->bit_depth = GET_Byte();
strike->flags = GET_Char();
count--;
strike++;
@ -799,7 +740,8 @@
TT_Error error;
error = Find_SBit_Range( glyph_index, strike, arange, aglyph_offset );
error = Find_SBit_Range( glyph_index, strike,
arange, aglyph_offset );
if ( error )
goto Fail;
@ -859,16 +801,25 @@
case 1:
case 2:
case 8:
/* variable small metrics */
/* variable small metrics */
{
TT_SBit_Small_Metrics smetrics;
const FT_Frame_Field sbit_small_metrics_fields[] =
{
FT_FRAME_START( 5 ),
FT_FRAME_BYTE( TT_SBit_Small_Metrics, height ),
FT_FRAME_BYTE( TT_SBit_Small_Metrics, width ),
FT_FRAME_CHAR( TT_SBit_Small_Metrics, bearingX ),
FT_FRAME_CHAR( TT_SBit_Small_Metrics, bearingY ),
FT_FRAME_BYTE( TT_SBit_Small_Metrics, advance ),
FT_FRAME_END
};
/* read small metrics */
if ( ACCESS_Frame( 5L ) )
if ( READ_Fields( sbit_small_metrics_fields, &smetrics ) )
goto Exit;
TT_Load_Small_SBit_Metrics( &smetrics, stream );
FORGET_Frame();
/* convert it to a big metrics */
metrics->height = smetrics.height;
@ -889,12 +840,7 @@
case 7:
case 9:
/* variable big metrics */
{
if ( ACCESS_Frame( 8L ) )
goto Exit;
TT_Load_SBit_Metrics( metrics, stream );
FORGET_Frame();
}
(void)READ_Fields( sbit_metrics_fields, metrics );
break;
case 5:
@ -1167,8 +1113,8 @@
case 2:
case 5:
case 7:
line_bits = glyph_width * pix_bits;
glyph_size = (glyph_height * line_bits + 7) >> 3;
line_bits = glyph_width * pix_bits;
glyph_size = ( glyph_height * line_bits + 7 ) >> 3;
break;
default: /* invalid format */
@ -1225,8 +1171,8 @@
TT_Long size;
map->width = metrics->width;
map->rows = metrics->height;
map->width = metrics->width;
map->rows = metrics->height;
switch ( strike->bit_depth )
{
@ -1234,14 +1180,17 @@
map->pixel_mode = ft_pixel_mode_mono;
map->pitch = ( map->width + 7 ) >> 3;
break;
case 2:
map->pixel_mode = ft_pixel_mode_pal2;
map->pitch = ( map->width + 3 ) >> 2;
break;
case 4:
map->pixel_mode = ft_pixel_mode_pal4;
map->pitch = ( map->width + 1 ) >> 1;
break;
case 8:
map->pixel_mode = ft_pixel_mode_grays;
map->pitch = map->width;

View File

@ -22,72 +22,13 @@
#include <ttload.h>
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_SBit_Strikes */
/* */
/* <Description> */
/* Loads the table of embedded bitmap sizes for this face. */
/* */
/* <Input> */
/* face :: The target face object. */
/* stream :: The input stream. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Load_SBit_Strikes( TT_Face face,
FT_Stream stream );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Free_SBit_Strikes */
/* */
/* <Description> */
/* Releases the embedded bitmap tables. */
/* */
/* <Input> */
/* face :: The target face object. */
/* */
LOCAL_DEF
void TT_Free_SBit_Strikes( TT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_SBit_Image */
/* */
/* <Description> */
/* Loads a given glyph sbit image from the font resource. This also */
/* returns its metrics. */
/* */
/* <Input> */
/* face :: The target face object. */
/* */
/* x_ppem :: The horizontal resolution in points per EM. */
/* */
/* y_ppem :: The vertical resolution in points per EM. */
/* */
/* glyph_index :: The current glyph index. */
/* */
/* stream :: The input stream. */
/* */
/* <Output> */
/* map :: The target pixmap. */
/* metrics :: A big sbit metrics structure for the glyph image. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. Returns an error if no */
/* glyph sbit exists for the index. */
/* */
/* <Note> */
/* The `map.buffer' field is always freed before the glyph is loaded. */
/* */
LOCAL_DEF
TT_Error TT_Load_SBit_Image( TT_Face face,
TT_Int x_ppem,

View File

@ -241,7 +241,7 @@
goto Fail;
}
FT_TRACE4(( "Instructions size : %d\n", n_ins ));
FT_TRACE5(( " Instructions size: %d\n", n_ins ));
if ( n_ins > face->max_profile.maxSizeOfInstructions )
{
@ -552,13 +552,12 @@
FORGET_Frame();
FT_TRACE6(( "Glyph %ld\n", index ));
FT_TRACE6(( " # of contours : %d\n", num_contours ));
FT_TRACE6(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
loader->bbox.xMax ));
FT_TRACE6(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
loader->bbox.yMax ));
FT_TRACE6(( "-" ));
FT_TRACE5(( "Glyph %ld\n", index ));
FT_TRACE5(( " # of contours: %d\n", contours_count ));
FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
loader->bbox.xMax ));
FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
loader->bbox.yMax ));
count -= 10;
@ -868,7 +867,7 @@
/* read size of instructions */
if ( FILE_Seek( ins_offset ) ||
READ_UShort(n_ins) ) goto Fail;
FT_TRACE4(( "Instructions size = %d\n", n_ins ));
FT_TRACE5(( " Instructions size = %d\n", n_ins ));
/* check it */
if ( n_ins > face->max_profile.maxSizeOfInstructions )