25#include FT_INTERNAL_OBJECTS_H
40#define FT_FRAME_OP_SHIFT 2
41#define FT_FRAME_OP_SIGNED 1
42#define FT_FRAME_OP_LITTLE 2
43#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT )
45#define FT_MAKE_FRAME_OP( command, little, sign ) \
46 ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign )
48#define FT_FRAME_OP_END 0
49#define FT_FRAME_OP_START 1
50#define FT_FRAME_OP_BYTE 2
51#define FT_FRAME_OP_SHORT 3
52#define FT_FRAME_OP_LONG 4
53#define FT_FRAME_OP_OFF3 5
54#define FT_FRAME_OP_BYTES 6
99#define FT_FIELD_SIZE( f ) \
100 (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f )
102#define FT_FIELD_SIZE_DELTA( f ) \
103 (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] )
105#define FT_FIELD_OFFSET( f ) \
106 (FT_UShort)( offsetof( FT_STRUCTURE, f ) )
108#define FT_FRAME_FIELD( frame_op, field ) \
111 FT_FIELD_SIZE( field ), \
112 FT_FIELD_OFFSET( field ) \
115#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 }
117#define FT_FRAME_START( size ) { ft_frame_start, 0, size }
118#define FT_FRAME_END { ft_frame_end, 0, 0 }
120#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f )
121#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f )
122#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f )
123#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f )
124#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f )
125#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f )
126#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f )
127#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f )
129#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f )
130#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f )
131#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f )
132#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f )
133#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f )
134#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f )
136#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 }
137#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 }
138#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 }
140#define FT_FRAME_BYTES( field, count ) \
144 FT_FIELD_OFFSET( field ) \
147#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 }
156#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] )
158#define FT_INT16( x ) ( (FT_Int16)(x) )
159#define FT_UINT16( x ) ( (FT_UInt16)(x) )
160#define FT_INT32( x ) ( (FT_Int32)(x) )
161#define FT_UINT32( x ) ( (FT_UInt32)(x) )
164#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) )
165#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) )
168#define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \
169 FT_BYTE_U16( p, 1, 0 ) )
171#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \
172 FT_BYTE_U16( p, 1, 0 ) )
174#define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \
175 FT_BYTE_U32( p, 1, 16 ) | \
176 FT_BYTE_U32( p, 2, 8 ) | \
177 FT_BYTE_U32( p, 3, 0 ) )
179#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \
180 FT_BYTE_U32( p, 1, 16 ) | \
181 FT_BYTE_U32( p, 2, 8 ) | \
182 FT_BYTE_U32( p, 3, 0 ) )
184#define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \
185 FT_BYTE_U32( p, 1, 8 ) | \
186 FT_BYTE_U32( p, 2, 0 ) )
188#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \
189 FT_BYTE_U32( p, 1, 8 ) | \
190 FT_BYTE_U32( p, 2, 0 ) )
192#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \
193 FT_BYTE_U16( p, 0, 0 ) )
195#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \
196 FT_BYTE_U16( p, 0, 0 ) )
198#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \
199 FT_BYTE_U32( p, 2, 16 ) | \
200 FT_BYTE_U32( p, 1, 8 ) | \
201 FT_BYTE_U32( p, 0, 0 ) )
203#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \
204 FT_BYTE_U32( p, 2, 16 ) | \
205 FT_BYTE_U32( p, 1, 8 ) | \
206 FT_BYTE_U32( p, 0, 0 ) )
208#define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_BYTE_U32( p, 2, 16 ) | \
209 FT_BYTE_U32( p, 1, 8 ) | \
210 FT_BYTE_U32( p, 0, 0 ) )
212#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \
213 FT_BYTE_U32( p, 1, 8 ) | \
214 FT_BYTE_U32( p, 0, 0 ) )
217#define FT_NEXT_CHAR( buffer ) \
218 ( (signed char)*buffer++ )
220#define FT_NEXT_BYTE( buffer ) \
221 ( (unsigned char)*buffer++ )
223#define FT_NEXT_SHORT( buffer ) \
224 ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) )
226#define FT_NEXT_USHORT( buffer ) \
227 ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) )
229#define FT_NEXT_OFF3( buffer ) \
230 ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) )
232#define FT_NEXT_UOFF3( buffer ) \
233 ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) )
235#define FT_NEXT_LONG( buffer ) \
236 ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) )
238#define FT_NEXT_ULONG( buffer ) \
239 ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) )
242#define FT_NEXT_SHORT_LE( buffer ) \
243 ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) )
245#define FT_NEXT_USHORT_LE( buffer ) \
246 ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) )
248#define FT_NEXT_OFF3_LE( buffer ) \
249 ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) )
251#define FT_NEXT_UOFF3_LE( buffer ) \
252 ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) )
254#define FT_NEXT_LONG_LE( buffer ) \
255 ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) )
257#define FT_NEXT_ULONG_LE( buffer ) \
258 ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) )
266#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor )
268#define FT_GET_CHAR() FT_GET_MACRO( CHAR )
269#define FT_GET_BYTE() FT_GET_MACRO( BYTE )
270#define FT_GET_SHORT() FT_GET_MACRO( SHORT )
271#define FT_GET_USHORT() FT_GET_MACRO( USHORT )
272#define FT_GET_OFF3() FT_GET_MACRO( OFF3 )
273#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 )
274#define FT_GET_LONG() FT_GET_MACRO( LONG )
275#define FT_GET_ULONG() FT_GET_MACRO( ULONG )
276#define FT_GET_TAG4() FT_GET_MACRO( ULONG )
278#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE )
279#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE )
280#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE )
281#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE )
284#define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
286#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char )
287#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte )
288#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short )
289#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort )
290#define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_Long )
291#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong )
292#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long )
293#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
294#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
296#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short )
297#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort )
298#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long )
299#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong )
302#define FT_READ_MACRO( func, type, var ) \
303 ( var = (type)func( stream, &error ), \
306#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var )
307#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var )
308#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var )
309#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var )
310#define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_Long, var )
311#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var )
312#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var )
313#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var )
315#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var )
316#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var )
317#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var )
318#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var )
321#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
326 const char* filepathname );
486#define FT_STREAM_POS() \
487 FT_Stream_Pos( stream )
489#define FT_STREAM_SEEK( position ) \
490 FT_SET_ERROR( FT_Stream_Seek( stream, \
491 (FT_ULong)(position) ) )
493#define FT_STREAM_SKIP( distance ) \
494 FT_SET_ERROR( FT_Stream_Skip( stream, \
495 (FT_Long)(distance) ) )
497#define FT_STREAM_READ( buffer, count ) \
498 FT_SET_ERROR( FT_Stream_Read( stream, \
499 (FT_Byte*)(buffer), \
500 (FT_ULong)(count) ) )
502#define FT_STREAM_READ_AT( position, buffer, count ) \
503 FT_SET_ERROR( FT_Stream_ReadAt( stream, \
504 (FT_ULong)(position), \
505 (FT_Byte*)(buffer), \
506 (FT_ULong)(count) ) )
508#define FT_STREAM_READ_FIELDS( fields, object ) \
509 FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) )
512#define FT_FRAME_ENTER( size ) \
514 FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \
515 (FT_ULong)(size) ) ) )
517#define FT_FRAME_EXIT() \
518 FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
520#define FT_FRAME_EXTRACT( size, bytes ) \
522 FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \
524 (FT_Byte**)&(bytes) ) ) )
526#define FT_FRAME_RELEASE( bytes ) \
527 FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \
528 (FT_Byte**)&(bytes) ) )
FT_Stream_ReadFields(FT_Stream stream, const FT_Frame_Field *fields, void *structure)
FT_Stream_ReadUShortLE(FT_Stream stream, FT_Error *error)
FT_Stream_GetUOffset(FT_Stream stream)
FT_Stream_ReadULongLE(FT_Stream stream, FT_Error *error)
FT_Stream_TryRead(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
FT_Stream_Close(FT_Stream stream)
FT_Stream_ReadChar(FT_Stream stream, FT_Error *error)
FT_Stream_ReadAt(FT_Stream stream, FT_ULong pos, FT_Byte *buffer, FT_ULong count)
FT_Stream_EnterFrame(FT_Stream stream, FT_ULong count)
FT_Stream_GetULongLE(FT_Stream stream)
FT_Stream_ExtractFrame(FT_Stream stream, FT_ULong count, FT_Byte **pbytes)
FT_Stream_ExitFrame(FT_Stream stream)
#define FT_FRAME_OP_SHORT
FT_Stream_GetChar(FT_Stream stream)
FT_Stream_ReadUOffset(FT_Stream stream, FT_Error *error)
FT_Stream_Open(FT_Stream stream, const char *filepathname)
#define FT_MAKE_FRAME_OP(command, little, sign)
FT_Stream_Pos(FT_Stream stream)
FT_Stream_New(FT_Library library, const FT_Open_Args *args, FT_Stream *astream)
FT_Stream_Read(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
enum FT_Frame_Op_ FT_Frame_Op
FT_Stream_ReadULong(FT_Stream stream, FT_Error *error)
FT_Stream_Free(FT_Stream stream, FT_Int external)
FT_Stream_ReleaseFrame(FT_Stream stream, FT_Byte **pbytes)
FT_Stream_GetUShortLE(FT_Stream stream)
struct FT_Frame_Field_ FT_Frame_Field
#define FT_FRAME_OP_START
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
FT_Stream_GetUShort(FT_Stream stream)
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
#define FT_FRAME_OP_BYTES
FT_Stream_GetULong(FT_Stream stream)
FT_Stream_Skip(FT_Stream stream, FT_Long distance)
FT_Stream_ReadUShort(FT_Stream stream, FT_Error *error)
GLuint GLuint GLsizei count
GLsizei GLsizei GLfloat distance