Added FT_FRAME_SKIP_xxx to skip fields.

More use of READ_Fields() in ttsbit.c

Other minor fixes.
This commit is contained in:
Werner Lemberg 2000-06-07 00:00:08 +00:00
parent 1c0d4acb25
commit 61bd4b9dd1
6 changed files with 67 additions and 57 deletions

View File

@ -83,6 +83,11 @@ typedef struct FT_Frame_Field_
#define FT_FRAME_SHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_short_le, s, f ) #define FT_FRAME_SHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_short_le, s, f )
#define FT_FRAME_USHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_ushort_le, s, f ) #define FT_FRAME_USHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_ushort_le, s, f )
#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 }
#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 }
#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 }
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* integer extraction macros - the `buffer' parameter must ALWAYS be of */ /* integer extraction macros - the `buffer' parameter must ALWAYS be of */

View File

@ -373,7 +373,7 @@
else else
a = 0x7FFFFFFFL; a = 0x7FFFFFFFL;
return ( s < 0 ) ? -a : a; return ( s < 0 ? -a : a );
} }
@ -648,14 +648,14 @@
else else
q = 0x7FFFFFFFL; q = 0x7FFFFFFFL;
return ( s < 0 ) ? -(FT_Int32)q : (FT_Int32)q; return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
} }
r = x->hi; r = x->hi;
lo = x->lo; lo = x->lo;
if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */ if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */
return ( s < 0 ) ? 0x80000001UL : 0x7FFFFFFFUL; return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
/* Return Max/Min Int32 if division overflow. */ /* Return Max/Min Int32 if division overflow. */
/* This includes division by zero! */ /* This includes division by zero! */
q = 0; q = 0;
@ -673,7 +673,7 @@
lo <<= 1; lo <<= 1;
} }
return ( s < 0 ) ? -(FT_Int32)q : (FT_Int32)q; return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
} }

View File

@ -1371,7 +1371,7 @@
{ {
/* the arc is y-monotonous, either ascending or descending */ /* the arc is y-monotonous, either ascending or descending */
/* detect a change of direction */ /* detect a change of direction */
state_bez = y1 < y3 ? Ascending : Descending; state_bez = y1 < y3 ? Ascending : Descending;
if ( ras.state != state_bez ) if ( ras.state != state_bez )
{ {
/* finalize current profile if any */ /* finalize current profile if any */
@ -1498,7 +1498,7 @@
} }
else else
{ {
state_bez = ( y1 <= y4 ) ? Ascending : Descending; state_bez = y1 <= y4 ? Ascending : Descending;
/* detect a change of direction */ /* detect a change of direction */
if ( ras.state != state_bez ) if ( ras.state != state_bez )

View File

@ -531,38 +531,35 @@
switch ( fields->value ) switch ( fields->value )
{ {
case ft_frame_start: /* access a new frame */ case ft_frame_start: /* access a new frame */
{ error = FT_Access_Frame( stream, fields->offset );
error = FT_Access_Frame( stream, fields->offset ); if ( error )
if ( error ) goto Exit;
goto Exit;
frame_accessed = 1; frame_accessed = 1;
fields++; fields++;
continue; /* loop! */ continue; /* loop! */
}
case ft_frame_byte: case ft_frame_byte:
case ft_frame_schar: /* read a single byte */ case ft_frame_schar: /* read a single byte */
{ value = GET_Byte();
value = GET_Byte(); sign_shift = 24;
sign_shift = 24; break;
break;
}
case ft_frame_short_be: case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */ case ft_frame_ushort_be: /* read a 2-byte big-endian short */
{ value = GET_UShort();
value = GET_UShort(); sign_shift = 16;
sign_shift = 16; break;
break;
}
case ft_frame_short_le: case ft_frame_short_le:
case ft_frame_ushort_le: /* read a 2-byte little-endian short */ case ft_frame_ushort_le: /* read a 2-byte little-endian short */
{ {
char* p; char* p;
value = 0; value = 0;
p = stream->cursor; p = stream->cursor;
if ( p + 1 < stream->limit ) if ( p + 1 < stream->limit )
{ {
value = ( FT_UShort)p[0] | ((FT_UShort)p[1] << 8 ); value = ( FT_UShort)p[0] | ((FT_UShort)p[1] << 8 );
@ -574,11 +571,9 @@
case ft_frame_long_be: case ft_frame_long_be:
case ft_frame_ulong_be: /* read a 4-byte big-endian long */ case ft_frame_ulong_be: /* read a 4-byte big-endian long */
{ value = GET_ULong();
value = GET_ULong(); sign_shift = 0;
sign_shift = 0; break;
break;
}
case ft_frame_long_le: case ft_frame_long_le:
case ft_frame_ulong_le: /* read a 4-byte little-endian long */ case ft_frame_ulong_le: /* read a 4-byte little-endian long */
@ -588,12 +583,13 @@
value = 0; value = 0;
p = stream->cursor; p = stream->cursor;
if ( p + 3 < stream->limit ) if ( p + 3 < stream->limit )
{ {
value = (FT_ULong)p[0] | value = (FT_ULong)p[0] |
( (FT_ULong)p[1] << 8 ) | ( (FT_ULong)p[1] << 8 ) |
( (FT_ULong)p[2] << 16 ) | ( (FT_ULong)p[2] << 16 ) |
( (FT_ULong)p[3] << 24 ); ( (FT_ULong)p[3] << 24 );
stream->cursor += 4; stream->cursor += 4;
} }
sign_shift = 0; sign_shift = 0;
@ -602,11 +598,9 @@
case ft_frame_off3_be: case ft_frame_off3_be:
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */ case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
{ value = GET_UOffset();
value = GET_UOffset(); sign_shift = 8;
sign_shift = 8; break;
break;
}
case ft_frame_off3_le: case ft_frame_off3_le:
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */ case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
@ -616,12 +610,13 @@
value = 0; value = 0;
p = stream->cursor; p = stream->cursor;
if ( p + 3 < stream->limit ) if ( p + 3 < stream->limit )
{ {
value = (FT_ULong)p[0] | value = (FT_ULong)p[0] |
( (FT_ULong)p[1] << 8 ) | ( (FT_ULong)p[1] << 8 ) |
( (FT_ULong)p[2] << 16 ) | ( (FT_ULong)p[2] << 16 ) |
( (FT_ULong)p[3] << 24 ); ( (FT_ULong)p[3] << 24 );
stream->cursor += 4; stream->cursor += 4;
} }
sign_shift = 8; sign_shift = 8;

View File

@ -130,7 +130,7 @@
/* load subheaders */ /* load subheaders */
cmap2->numGlyphId = l = cmap2->numGlyphId = l =
( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xffff ) / 2; ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2;
if ( ALLOC_ARRAY( cmap2->subHeaders, if ( ALLOC_ARRAY( cmap2->subHeaders,
num_SH + 1, num_SH + 1,

View File

@ -403,6 +403,28 @@
FT_FRAME_END FT_FRAME_END
}; };
const FT_Frame_Field strike_start_fields[] =
{
/* no FT_FRAME_START */
FT_FRAME_ULONG( TT_SBit_Strike, ranges_offset ),
FT_FRAME_SKIP_LONG,
FT_FRAME_ULONG( TT_SBit_Strike, num_ranges ),
FT_FRAME_ULONG( TT_SBit_Strike, color_ref ),
FT_FRAME_END
};
const FT_Frame_Field strike_end_fields[] =
{
/* no FT_FRAME_START */
FT_FRAME_USHORT( TT_SBit_Strike, start_glyph ),
FT_FRAME_USHORT( TT_SBit_Strike, end_glyph ),
FT_FRAME_BYTE ( TT_SBit_Strike, x_ppem ),
FT_FRAME_BYTE ( TT_SBit_Strike, y_ppem ),
FT_FRAME_BYTE ( TT_SBit_Strike, bit_depth ),
FT_FRAME_CHAR ( TT_SBit_Strike, flags ),
FT_FRAME_END
};
face->num_sbit_strikes = 0; face->num_sbit_strikes = 0;
@ -450,24 +472,12 @@
while ( count > 0 ) while ( count > 0 )
{ {
TT_ULong indexTablesSize; (void)READ_Fields( strike_start_fields, strike );
strike->ranges_offset = GET_ULong();
indexTablesSize = GET_ULong(); /* don't save */
strike->num_ranges = GET_ULong();
strike->color_ref = GET_ULong();
(void)READ_Fields( sbit_line_metrics_fields, &strike->hori ); (void)READ_Fields( sbit_line_metrics_fields, &strike->hori );
(void)READ_Fields( sbit_line_metrics_fields, &strike->vert ); (void)READ_Fields( sbit_line_metrics_fields, &strike->vert );
strike->start_glyph = GET_UShort(); (void)READ_Fields( strike_end_fields, strike );
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--; count--;
strike++; strike++;