#undef QALLOC /* just in case */
#define QALLOC(ptr,size) ( (ptr) = ftglue_qalloc( memory, (size), &error ), error != 0 )
+#define FREE(_ptr) \
+ do { \
+ if ( (_ptr) ) \
+ { \
+ ftglue_free( memory, _ptr ); \
+ _ptr = NULL; \
+ } \
+ } while (0)
-FTGLUE_APIDEF( FT_Pointer )
-ftglue_alloc( FT_Memory memory,
- FT_ULong size,
- FT_Error *perror )
-{
- FT_Error error = 0;
- FT_Pointer block = NULL;
-
- if ( size > 0 )
- {
- block = memory->alloc( memory, size );
- if ( !block )
- error = FT_Err_Out_Of_Memory;
- else
- memset( (char*)block, 0, (size_t)size );
- }
-
- *perror = error;
- return block;
-}
-
-
-FTGLUE_APIDEF( FT_Pointer )
-ftglue_realloc( FT_Memory memory,
- FT_Pointer block,
- FT_ULong old_size,
- FT_ULong new_size,
- FT_Error *perror )
-{
- FT_Pointer block2 = NULL;
- FT_Error error = 0;
-
- if ( old_size == 0 || block == NULL )
- {
- block2 = ftglue_alloc( memory, new_size, &error );
- }
- else if ( new_size == 0 )
- {
- ftglue_free( memory, block );
- }
- else
- {
- block2 = memory->realloc( memory, old_size, new_size, block );
- if ( block2 == NULL )
- error = FT_Err_Out_Of_Memory;
- else if ( new_size > old_size )
- memset( (char*)block2 + old_size, 0, (size_t)(new_size - old_size) );
- }
-
- if ( !error )
- block = block2;
-
- *perror = error;
- return block;
-}
-
-
-FTGLUE_APIDEF( void )
+static void
ftglue_free( FT_Memory memory,
FT_Pointer block )
{
memory->free( memory, block );
}
-
FTGLUE_APIDEF( FT_Long )
ftglue_stream_pos( FT_Stream stream )
{
}
-FTGLUE_APIDEF( FT_Byte )
-ftglue_stream_get_byte( FT_Stream stream )
-{
- FT_Byte result = 0;
-
- if ( stream->cursor < stream->limit )
- result = *stream->cursor++;
-
- return result;
-}
-
-
-FTGLUE_APIDEF( FT_Short )
-ftglue_stream_get_short( FT_Stream stream )
-{
- FT_Byte* p;
- FT_Short result = 0;
-
- p = stream->cursor;
- if ( p + 2 <= stream->limit )
- {
- result = (FT_Short)((p[0] << 8) | p[1]);
- stream->cursor = p+2;
- }
- return result;
-}
-
-
-FTGLUE_APIDEF( FT_Long )
-ftglue_stream_get_long( FT_Stream stream )
-{
- FT_Byte* p;
- FT_Long result = 0;
-
- p = stream->cursor;
- if ( p + 4 <= stream->limit )
- {
- result = (FT_Long)(((FT_Long)p[0] << 24) |
- ((FT_Long)p[1] << 16) |
- ((FT_Long)p[2] << 8) |
- p[3] );
- stream->cursor = p+4;
- }
- return result;
-}
-
-
FTGLUE_APIDEF( FT_Error )
ftglue_face_goto_table( FT_Face face,
FT_ULong the_tag,
/* parse the directory table directly, without using
* FreeType's built-in data structures
*/
- FT_ULong offset = 0;
+ FT_ULong offset = 0, sig;
FT_UInt count, nn;
- if ( face->num_faces > 1 )
+ if ( FILE_Seek( 0 ) || ACCESS_Frame( 4 ) )
+ goto Exit;
+
+ sig = GET_Tag4();
+
+ FORGET_Frame();
+
+ if ( sig == FT_MAKE_TAG( 't', 't', 'c', 'f' ) )
{
/* deal with TrueType collections */
- FT_ULong offset;
LOG(( ">> This is a TrueType Collection\n" ));
if ( tag == the_tag )
{
LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size ));
- error = ftglue_stream_seek( stream, offset+start );
+ error = ftglue_stream_seek( stream, start );
goto FoundIt;
}
}
- error = TT_Err_Table_Missing;
+ error = FT_Err_Table_Missing;
FoundIt:
FORGET_Frame();
}
#undef QALLOC
+#define __ftglue__
+#include "fcaliastail.h"
+#undef __ftglue__