ftcalc.c, ftextend.c, ftoutln.c, ftraster.c, ftstream.c:

Removing trailing spaces.

ftlist.h:
  Removing duplicated documentation (which is in ftlist.c also).

ftinit.c, ftlist.c, ftobjs.c:
  Formatting, adding documentation.
This commit is contained in:
Werner Lemberg 2000-01-10 17:19:45 +00:00
parent ecbfb5fa9a
commit 7880dd6630
9 changed files with 466 additions and 493 deletions

View File

@ -55,7 +55,7 @@
{ {
FT_ULong val, root, newroot, mask; FT_ULong val, root, newroot, mask;
root = 0; root = 0;
mask = 0x40000000; mask = 0x40000000;
val = (FT_ULong)x; val = (FT_ULong)x;
@ -73,11 +73,11 @@
mask >>= 2; mask >>= 2;
} }
while ( mask != 0 ); while ( mask != 0 );
return root; return root;
} }
#ifdef LONG64 #ifdef LONG64
@ -203,7 +203,7 @@
/* check for divide by 0 */ /* check for divide by 0 */
q = 0x7FFFFFFF; q = 0x7FFFFFFF;
else else
/* compute result directly */ /* compute result directly */
q = ((FT_Int64)a << 16) / b; q = ((FT_Int64)a << 16) / b;
@ -481,7 +481,7 @@
{ {
FT_Word32 lo1, hi1, lo2, hi2, lo, hi, i1, i2; FT_Word32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
lo1 = x & 0x0000FFFF; hi1 = x >> 16; lo1 = x & 0x0000FFFF; hi1 = x >> 16;
lo2 = y & 0x0000FFFF; hi2 = y >> 16; lo2 = y & 0x0000FFFF; hi2 = y >> 16;

View File

@ -37,7 +37,7 @@
FT_Int num_extensions; FT_Int num_extensions;
FT_Long cur_offset; FT_Long cur_offset;
FT_Extension_Class classes[FT_MAX_EXTENSIONS]; FT_Extension_Class classes[FT_MAX_EXTENSIONS];
} FT_Extension_Registry; } FT_Extension_Registry;
@ -94,7 +94,7 @@
{ {
FT_Memory memory = driver->memory; FT_Memory memory = driver->memory;
FREE( driver->extensions ); FREE( driver->extensions );
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -128,11 +128,11 @@
FT_Int n = registry->num_extensions; FT_Int n = registry->num_extensions;
FT_Extension_Class* cur = registry->classes + n; FT_Extension_Class* cur = registry->classes + n;
if ( n >= FT_MAX_EXTENSIONS ) if ( n >= FT_MAX_EXTENSIONS )
return FT_Err_Too_Many_Extensions; return FT_Err_Too_Many_Extensions;
*cur = *class; *cur = *class;
cur->offset = registry->cur_offset; cur->offset = registry->cur_offset;
@ -167,18 +167,18 @@
EXPORT_FUNC EXPORT_FUNC
void* FT_Get_Extension( FT_Face face, void* FT_Get_Extension( FT_Face face,
const char* extension_id, const char* extension_id,
void* *extension_interface ) void* *extension_interface )
{ {
FT_Extension_Registry* registry; FT_Extension_Registry* registry;
registry = (FT_Extension_Registry*)face->driver->extensions; registry = (FT_Extension_Registry*)face->driver->extensions;
if ( registry && face->extensions ) if ( registry && face->extensions )
{ {
FT_Extension_Class* cur = registry->classes; FT_Extension_Class* cur = registry->classes;
FT_Extension_Class* limit = cur + registry->num_extensions; FT_Extension_Class* limit = cur + registry->num_extensions;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
if ( strcmp( cur->id, extension_id ) == 0 ) if ( strcmp( cur->id, extension_id ) == 0 )
{ {
@ -186,7 +186,7 @@
return (void*)((char*)face->extensions + cur->offset); return (void*)((char*)face->extensions + cur->offset);
} }
} }
/* could not find the extension id */ /* could not find the extension id */
*extension_interface = 0; *extension_interface = 0;
@ -217,22 +217,22 @@
FT_Extension_Registry* registry; FT_Extension_Registry* registry;
FT_Memory memory; FT_Memory memory;
registry = (FT_Extension_Registry*)face->driver->extensions; registry = (FT_Extension_Registry*)face->driver->extensions;
if ( registry && face->extensions ) if ( registry && face->extensions )
{ {
FT_Extension_Class* cur = registry->classes; FT_Extension_Class* cur = registry->classes;
FT_Extension_Class* limit = cur + registry->num_extensions; FT_Extension_Class* limit = cur + registry->num_extensions;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
char* ext = (char*)face->extensions + cur->offset; char* ext = (char*)face->extensions + cur->offset;
if ( cur->finalize ) if ( cur->finalize )
cur->finalize( ext, face ); cur->finalize( ext, face );
} }
memory = face->driver->memory; memory = face->driver->memory;
FREE( face->extensions ); FREE( face->extensions );
} }
@ -266,28 +266,28 @@
FT_Memory memory; FT_Memory memory;
FT_Error error; FT_Error error;
face->extensions = 0; face->extensions = 0;
/* load extensions registry, exit successfully if none is there */ /* load extensions registry, exit successfully if none is there */
registry = (FT_Extension_Registry*)face->driver->extensions; registry = (FT_Extension_Registry*)face->driver->extensions;
if ( !registry ) if ( !registry )
return FT_Err_Ok; return FT_Err_Ok;
memory = face->driver->memory; memory = face->driver->memory;
if ( ALLOC( face->extensions, registry->cur_offset ) ) if ( ALLOC( face->extensions, registry->cur_offset ) )
return error; return error;
{ {
FT_Extension_Class* cur = registry->classes; FT_Extension_Class* cur = registry->classes;
FT_Extension_Class* limit = cur + registry->num_extensions; FT_Extension_Class* limit = cur + registry->num_extensions;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
char* ext = (char*)face->extensions + cur->offset; char* ext = (char*)face->extensions + cur->offset;
if ( cur->init ) if ( cur->init )
{ {
error = cur->init( ext, face ); error = cur->init( ext, face );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType initialisation layer (body). */ /* FreeType initialisation layer (body). */
/* */ /* */
/* Copyright 1996-1999 by */ /* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used */ /* This file is part of the FreeType project, and may only be used */
@ -15,37 +15,31 @@
/* */ /* */
/***************************************************************************/ /***************************************************************************/
/************************************************************************** /*************************************************************************/
* /* */
* The purpose of this file is to implement the three following /* The purpose of this file is to implement the three following */
* functions: /* functions: */
* /* */
* FT_Default_Drivers: /* FT_Default_Drivers: */
* This function is used to add the set of default drivers /* This function is used to add the set of default drivers to a */
* to a fresh new library object. The set is computed at compile /* fresh new library object. The set is computed at compile time */
* time from the Makefiles inclusions in Makefile.lib. See the /* from the Makefiles inclusions in Makefile.lib. See the document */
* document "FreeType Internals" for more info. /* `FreeType Internals' for more info. */
* /* */
* /* FT_Init_FreeType: */
* FT_Init_FreeType: /* This function creates a system object for the current platform, */
* This function creates a system object for the current platform, /* builds a library out of it, then calls FT_Default_Drivers(). */
* builds a library out of it, then calls FT_Default_Drivers /* */
* /* FT_Done_FreeType: */
* /* This function simply finalizes the library and the corresponding */
* FT_Done_FreeType: /* system object. */
* This function simply finalise the library and the corresponding /* */
* system object. /* Note that even if FT_Init_FreeType() uses the implementation of the */
* /* system object defined at build time, client applications are still */
* /* able to provide their own `ftsystem.c'. */
* Note that even if FT_Init_FreeType uses the implementation of the /* */
* system object defined at build time, client applications are still /*************************************************************************/
* able to provide their own "ftsystem.c"
*
*
*
*
*
************************************************************************/
#include <ftobjs.h> #include <ftobjs.h>
#include <ftconfig.h> #include <ftconfig.h>
@ -56,17 +50,20 @@
#define FT_COMPONENT trace_init #define FT_COMPONENT trace_init
#undef FT_DRIVER #undef FT_DRIVER
#define FT_DRIVER(x) extern FT_DriverInterface x; #define FT_DRIVER( x ) extern FT_DriverInterface x;
#include <ftmodule.h> #include <ftmodule.h>
#undef FT_DRIVER #undef FT_DRIVER
#define FT_DRIVER(x) &x, #define FT_DRIVER( x ) &x,
static static
const FT_DriverInterface* ft_default_drivers[] = { const FT_DriverInterface* ft_default_drivers[] =
{
#include <ftmodule.h> #include <ftmodule.h>
0 0
}; };
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@ -76,7 +73,7 @@ const FT_DriverInterface* ft_default_drivers[] = {
/* <Description> */ /* <Description> */
/* Adds the set of default drivers to a given library object. */ /* Adds the set of default drivers to a given library object. */
/* */ /* */
/* <Input> */ /* <InOut> */
/* library :: A handle to a new library object. */ /* library :: A handle to a new library object. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
@ -85,16 +82,15 @@ const FT_DriverInterface* ft_default_drivers[] = {
FT_Error error; FT_Error error;
const FT_DriverInterface* *cur; const FT_DriverInterface* *cur;
cur = ft_default_drivers; cur = ft_default_drivers;
while (*cur) while ( *cur )
{ {
error = FT_Add_Driver( library, *cur ); error = FT_Add_Driver( library, *cur );
/* notify errors, but don't stop */ /* notify errors, but don't stop */
if (error) if ( error )
{ FT_ERROR(( "FT.Default_Drivers: Cannot install `%s', error = %x\n",
FT_ERROR(( "FT.Default_Drivers: cannot install `%s', error = %x\n",
(*cur)->driver_name, error )); (*cur)->driver_name, error ));
}
cur++; cur++;
} }
} }
@ -113,7 +109,7 @@ const FT_DriverInterface* ft_default_drivers[] = {
/* library :: A handle to a new library object. */ /* library :: A handle to a new library object. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeTyoe error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Init_FreeType( FT_Library* library ) FT_Error FT_Init_FreeType( FT_Library* library )
@ -121,22 +117,25 @@ const FT_DriverInterface* ft_default_drivers[] = {
FT_Error error; FT_Error error;
FT_Memory memory; FT_Memory memory;
/* First of all, allocate a new system object -this function is part */
/* of the system-specific component, i.e. ftsystem.c */ /* First of all, allocate a new system object - -this function is part */
/* of the system-specific component, i.e. `ftsystem.c'. */
memory = FT_New_Memory(); memory = FT_New_Memory();
if (!memory) if ( !memory )
{ {
FT_ERROR(( "FT_Init_FreeType:" )); FT_ERROR(( "FT_Init_FreeType:" ));
FT_ERROR(( " cannot find memory manager" )); FT_ERROR(( " cannot find memory manager" ));
return FT_Err_Unimplemented_Feature; return FT_Err_Unimplemented_Feature;
} }
/* builds a library out of it, then fill it with the set of */ /* builds a library out of it, then fill it with the set of */
/* default drivers.. */ /* default drivers. */
error = FT_New_Library( memory, library ); error = FT_New_Library( memory, library );
if ( !error ) if ( !error )
FT_Default_Drivers(*library); FT_Default_Drivers( *library );
return error; return error;
} }

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Generic list support for FreeType (body). */ /* Generic list support for FreeType (body). */
/* */ /* */
/* Copyright 1996-1999 by */ /* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used */ /* This file is part of the FreeType project, and may only be used */
@ -15,11 +15,10 @@
/* */ /* */
/***************************************************************************/ /***************************************************************************/
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* This file implements functions relative to list processing. Its */ /* This file implements functions relative to list processing. Its */
/* data structures are defined in freetype.h. */ /* data structures are defined in `freetype.h'. */
/* */ /* */
/*************************************************************************/ /*************************************************************************/
@ -54,7 +53,7 @@
cur = list->head; cur = list->head;
while ( cur ) while ( cur )
{ {
if (cur->data == data) if ( cur->data == data )
return cur; return cur;
cur = cur->next; cur = cur->next;
@ -70,7 +69,7 @@
/* FT_List_Add */ /* FT_List_Add */
/* */ /* */
/* <Description> */ /* <Description> */
/* Appends an element at the end of a list. */ /* Appends an element to the end of a list. */
/* */ /* */
/* <InOut> */ /* <InOut> */
/* list :: A pointer to the parent list. */ /* list :: A pointer to the parent list. */
@ -222,7 +221,7 @@
/* argument to the iterator. */ /* argument to the iterator. */
/* */ /* */
/* <Return> */ /* <Return> */
/* The result of the last iterator call. */ /* The result (an error code) of the last iterator call. */
/* */ /* */
BASE_FUNC BASE_FUNC
FT_Error FT_List_Iterate( FT_List list, FT_Error FT_List_Iterate( FT_List list,
@ -270,10 +269,10 @@
/* argument to the destructor. */ /* argument to the destructor. */
/* */ /* */
BASE_FUNC BASE_FUNC
void FT_List_Finalize( FT_List list, void FT_List_Finalize( FT_List list,
FT_List_Destructor destroy, FT_List_Destructor destroy,
FT_Memory memory, FT_Memory memory,
void* user ) void* user )
{ {
FT_ListNode cur; FT_ListNode cur;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Generic list support for FreeType (specification). */ /* Generic list support for FreeType (specification). */
/* */ /* */
/* Copyright 1996-1999 by */ /* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used */ /* This file is part of the FreeType project, and may only be used */
@ -15,11 +15,10 @@
/* */ /* */
/***************************************************************************/ /***************************************************************************/
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* This file implements functions relative to list processing. Its */ /* This file implements functions relative to list processing. Its */
/* data structures are defined in freetype.h. */ /* data structures are defined in `freetype.h'. */
/* */ /* */
/*************************************************************************/ /*************************************************************************/
@ -34,93 +33,22 @@
#endif #endif
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Find */
/* */
/* <Description> */
/* Finds the list node for a given listed object. */
/* */
/* <Input> */
/* list :: A pointer to the parent list. */
/* data :: The address of the listed object. */
/* */
/* <Return> */
/* List node. NULL if it wasn't found. */
/* */
EXPORT_DEF EXPORT_DEF
FT_ListNode FT_List_Find( FT_List list, FT_ListNode FT_List_Find( FT_List list,
void* data ); void* data );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Add */
/* */
/* <Description> */
/* Appends an element at the end of a list. */
/* */
/* <InOut> */
/* list :: A pointer to the parent list. */
/* node :: The node to append. */
/* */
EXPORT_DEF EXPORT_DEF
void FT_List_Add( FT_List list, void FT_List_Add( FT_List list,
FT_ListNode node ); FT_ListNode node );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Insert */
/* */
/* <Description> */
/* Inserts an element at the head of a list. */
/* */
/* <InOut> */
/* list :: A pointer to parent list. */
/* node :: The node to insert. */
/* */
EXPORT_DEF EXPORT_DEF
void FT_List_Insert( FT_List list, void FT_List_Insert( FT_List list,
FT_ListNode node ); FT_ListNode node );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Remove */
/* */
/* <Description> */
/* Removes a node from a list. This function doesn't check whether */
/* the node is in the list! */
/* */
/* <Input> */
/* node :: The node to remove. */
/* */
/* <InOut> */
/* list :: A pointer to the parent list. */
/* */
EXPORT_DEF EXPORT_DEF
void FT_List_Remove( FT_List list, void FT_List_Remove( FT_List list,
FT_ListNode node ); FT_ListNode node );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Up */
/* */
/* <Description> */
/* Moves a node to the head/top of a list. Used to maintain LRU */
/* lists. */
/* */
/* <InOut> */
/* list :: A pointer to the parent list. */
/* node :: The node to move. */
/* */
EXPORT_DEF EXPORT_DEF
void FT_List_Up( FT_List list, void FT_List_Up( FT_List list,
FT_ListNode node ); FT_ListNode node );
@ -144,26 +72,6 @@
void* user ); void* user );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Iterate */
/* */
/* <Description> */
/* Parses a list and calls a given iterator function on each element. */
/* Note that parsing is stopped as soon as one of the iterator calls */
/* returns a non-zero value. */
/* */
/* <Input> */
/* list :: A handle to the list. */
/* iterator :: An interator function, called on each node of the */
/* list. */
/* user :: A user-supplied field which is passed as the second */
/* argument to the iterator. */
/* */
/* <Return> */
/* The result of the last iterator call. */
/* */
EXPORT_DEF EXPORT_DEF
FT_Error FT_List_Iterate( FT_List list, FT_Error FT_List_Iterate( FT_List list,
FT_List_Iterator iterator, FT_List_Iterator iterator,
@ -177,40 +85,20 @@
/* */ /* */
/* <Description> */ /* <Description> */
/* An FT_List iterator function which is called during a list */ /* An FT_List iterator function which is called during a list */
/* finalisation by FT_List_Finalize() to destroy all elements in a */ /* finalization by FT_List_Finalize() to destroy all elements in a */
/* given list. */ /* given list. */
/* */ /* */
/* <Input> */ /* <Input> */
/* system :: The current system object. */ /* system :: The current system object. */
/* data :: The current object to destroy. */ /* data :: The current object to destroy. */
/* user :: A typeless pointer passed to FT_List_Iterate(). It can */ /* user :: A typeless pointer passed to FT_List_Iterate(). It can */
/* used to point to the iteration's state. */ /* be used to point to the iteration's state. */
/* */ /* */
typedef void (*FT_List_Destructor)( FT_Memory memory, typedef void (*FT_List_Destructor)( FT_Memory memory,
void* data, void* data,
void* user ); void* user );
/*************************************************************************/
/* */
/* <Function> */
/* FT_List_Finalize */
/* */
/* <Description> */
/* Destroys all elements in the list as well as the list itself. */
/* */
/* <Input> */
/* list :: A handle to the list. */
/* */
/* destroy :: A list destructor that will be applied to each element */
/* of the list. */
/* */
/* system :: The current system object where destructions take */
/* place. */
/* */
/* user :: A user-supplied field which is passed as the last */
/* argument to the destructor. */
/* */
EXPORT_DEF EXPORT_DEF
void FT_List_Finalize( FT_List list, void FT_List_Finalize( FT_List list,
FT_List_Destructor destroy, FT_List_Destructor destroy,

View File

@ -4,7 +4,7 @@
/* */ /* */
/* The FreeType private base classes (base). */ /* The FreeType private base classes (base). */
/* */ /* */
/* Copyright 1996-1999 by */ /* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */ /* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */ /* */
/* This file is part of the FreeType project, and may only be used */ /* This file is part of the FreeType project, and may only be used */
@ -20,6 +20,8 @@
#include <ftdebug.h> #include <ftdebug.h>
#include <ftstream.h> #include <ftstream.h>
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -35,7 +37,7 @@
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the PTRACE() and PERROR() macros, used to print/log */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */ /* messages during execution. */
/* */ /* */
#undef FT_COMPONENT #undef FT_COMPONENT
@ -71,13 +73,13 @@
{ {
FT_Assert( P != 0 ); FT_Assert( P != 0 );
if (size > 0) if ( size > 0 )
{ {
*P = memory->alloc( memory, size ); *P = memory->alloc( memory, size );
if (!*P) if ( !*P )
{ {
FT_ERROR(( "FT.Alloc:" )); FT_ERROR(( "FT.Alloc:" ));
FT_ERROR(( " out of memory ? (%ld requested)\n", FT_ERROR(( " Out of memory? (%ld requested)\n",
size )); size ));
return FT_Err_Out_Of_Memory; return FT_Err_Out_Of_Memory;
@ -109,7 +111,7 @@
/* occurs. */ /* occurs. */
/* */ /* */
/* current :: current block size in bytes */ /* current :: current block size in bytes */
/* size :: the new block size in bytes */ /* size :: the new block size in bytes */
/* */ /* */
/* <InOut> */ /* <InOut> */
/* P :: A pointer to the fresh new block. It should be set to */ /* P :: A pointer to the fresh new block. It should be set to */
@ -122,10 +124,10 @@
/* All callers of FT_Realloc _must_ provide the current block size */ /* All callers of FT_Realloc _must_ provide the current block size */
/* as well as the new one. */ /* as well as the new one. */
/* */ /* */
/* When the memory object's flag FT_SYSTEM_FLAG_NO_REALLOC is */ /* If the memory object's flag FT_SYSTEM_FLAG_NO_REALLOC is set, this */
/* set, this function will try to emulate a realloc through uses */ /* function will try to emulate a reallocation using FT_Alloc() and */
/* of FT_Alloc and FT_Free. Otherwise, it will call the system- */ /* FT_Free(). Otherwise, it will call the system-specific `realloc' */
/* specific "realloc" implementation. */ /* implementation. */
/* */ /* */
/* (Some embedded systems do not have a working realloc). */ /* (Some embedded systems do not have a working realloc). */
/* */ /* */
@ -137,6 +139,7 @@
{ {
void* Q; void* Q;
FT_Assert( P != 0 ); FT_Assert( P != 0 );
/* if the original pointer is NULL, call FT_Alloc() */ /* if the original pointer is NULL, call FT_Alloc() */
@ -151,14 +154,15 @@
} }
Q = memory->realloc( memory, current, size, *P ); Q = memory->realloc( memory, current, size, *P );
if ( !Q ) goto Fail; if ( !Q )
goto Fail;
*P = Q; *P = Q;
return FT_Err_Ok; return FT_Err_Ok;
Fail: Fail:
FT_ERROR(( "FT.Realloc:" )); FT_ERROR(( "FT.Realloc:" ));
FT_ERROR(( " failed (current %ld, requested %ld)\n", FT_ERROR(( " Failed (current %ld, requested %ld)\n",
current, size )); current, size ));
return FT_Err_Out_Of_Memory; return FT_Err_Out_Of_Memory;
} }
@ -189,14 +193,14 @@
/* */ /* */
BASE_FUNC BASE_FUNC
void FT_Free( FT_Memory memory, void FT_Free( FT_Memory memory,
void* *P ) void* *P )
{ {
FT_TRACE2(( "FT_Free:" )); FT_TRACE2(( "FT_Free:" ));
FT_TRACE2(( " Freeing block 0x%08lx, ref 0x%08lx\n", FT_TRACE2(( " Freeing block 0x%08lx, ref 0x%08lx\n",
(long)P, (P ? (long)*P : -1) )); (long)P, (P ? (long)*P : -1) ));
FT_Assert( P != 0 ); FT_Assert( P != 0 );
if ( *P ) if ( *P )
{ {
memory->free( memory, *P ); memory->free( memory, *P );
@ -204,6 +208,8 @@
} }
} }
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@ -216,46 +222,46 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/* destructor for sizes list */ /* destructor for sizes list */
static static
void destroy_size( FT_Memory memory, void destroy_size( FT_Memory memory,
FT_Size size, FT_Size size,
FT_Driver driver ) FT_Driver driver )
{ {
/* finalize format-specific stuff */ /* finalize format-specific stuff */
driver->interface.done_size( size ); driver->interface.done_size( size );
FREE( size ); FREE( size );
} }
/* destructor for faces list */ /* destructor for faces list */
static static
void destroy_face( FT_Memory memory, void destroy_face( FT_Memory memory,
FT_Face face, FT_Face face,
FT_Driver driver ) FT_Driver driver )
{ {
/* Discard glyph slots for this face */ /* Discard glyph slots for this face */
/* XXX: Beware! FT_Done_GlyphSlot() changes the field `face->slot' */ /* XXX: Beware! FT_Done_GlyphSlot() changes the field `face->slot' */
while ( face->glyph ) while ( face->glyph )
FT_Done_GlyphSlot( face->glyph ); FT_Done_GlyphSlot( face->glyph );
/* Discard all sizes for this face */ /* Discard all sizes for this face */
FT_List_Finalize( &face->sizes_list, FT_List_Finalize( &face->sizes_list,
(FT_List_Destructor)destroy_size, (FT_List_Destructor)destroy_size,
memory, memory,
driver ); driver );
face->size = 0; face->size = 0;
/* finalize format-specific stuff */ /* finalize format-specific stuff */
driver->interface.done_face( face ); driver->interface.done_face( face );
/* Now discard client data */ /* Now discard client data */
if ( face->generic.finalizer ) if ( face->generic.finalizer )
face->generic.finalizer( face ); face->generic.finalizer( face );
/* get rid of it */ /* get rid of it */
FREE( face ); FREE( face );
} }
/*************************************************************************/ /*************************************************************************/
@ -267,19 +273,17 @@
/* Destroys a given driver object. This also destroys all child */ /* Destroys a given driver object. This also destroys all child */
/* faces. */ /* faces. */
/* */ /* */
/* <Input> */ /* <InOut> */
/* driver :: A handle to the target driver object. */ /* driver :: A handle to the target driver object. */
/* */ /* */
/* <Return> */
/* Error code. 0 means success. */
/* */
/* <Note> */ /* <Note> */
/* The driver _must_ be LOCKED! */ /* The driver _must_ be LOCKED! */
/* */ /* */
static static
void Destroy_Driver( FT_Driver driver ) void Destroy_Driver( FT_Driver driver )
{ {
FT_Memory memory = driver->memory; FT_Memory memory = driver->memory;
/* now, finalize all faces in the driver list */ /* now, finalize all faces in the driver list */
FT_List_Finalize( &driver->faces_list, FT_List_Finalize( &driver->faces_list,
@ -288,34 +292,47 @@
driver ); driver );
/* finalize the driver object */ /* finalize the driver object */
if (driver->interface.done_driver) if ( driver->interface.done_driver )
driver->interface.done_driver(driver); driver->interface.done_driver( driver );
/* finalize client-data */ /* finalize client-data */
if (driver->generic.finalizer) if ( driver->generic.finalizer )
driver->generic.finalizer(driver); driver->generic.finalizer( driver );
/* discard it */ /* discard it */
FREE( driver ); FREE( driver );
} }
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Glyph_Format */
/* */
/* <Description> */
/* Gets the glyph format for a given format tag. */
/* */
/* <Input> */
/* library :: A handle to the library object. */
/* format_tag :: A tag identifying the glyph format. */
/* */
/* <Return> */
/* A pointer to a glyph format. 0 if `format_tag' isn't defined. */
/* */
BASE_FUNC BASE_FUNC
FT_Glyph_Format* FT_Get_Glyph_Format( FT_Library library, FT_Glyph_Format* FT_Get_Glyph_Format( FT_Library library,
FT_Glyph_Tag format_tag ) FT_Glyph_Tag format_tag )
{ {
FT_Glyph_Format* cur = library->glyph_formats; FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur ++ ) for ( ; cur < limit; cur ++ )
{ {
if ( cur->format_tag == format_tag ) if ( cur->format_tag == format_tag )
return cur; return cur;
} }
return 0; return 0;
} }
@ -326,18 +343,19 @@
/* FT_Set_Raster */ /* FT_Set_Raster */
/* */ /* */
/* <Description> */ /* <Description> */
/* This function is used to change the raster module used to convert */ /* This function changes the raster module used to convert from a */
/* from a given memory object. It is thus possible to use libraries */ /* given memory object. It is thus possible to use libraries with */
/* with distinct memory allocators within the same program. */ /* distinct memory allocators within the same program. */
/* */ /* */
/* <Input> */ /* <Input> */
/* memory :: A handle to the original memory object. */ /* library :: A handle to the library object. */
/* interface :: A pointer to the interface of the new raster module. */
/* */ /* */
/* <Output> */ /* <Output> */
/* library :: A handle to a new library object. */ /* raster :: A handle to the raster object. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Set_Raster( FT_Library library, FT_Error FT_Set_Raster( FT_Library library,
@ -348,6 +366,7 @@
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Glyph_Format* format; FT_Glyph_Format* format;
/* allocate the render pool if necessary */ /* allocate the render pool if necessary */
if ( !library->raster_pool && if ( !library->raster_pool &&
ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
@ -355,37 +374,37 @@
/* find the glyph formatter for the raster's format */ /* find the glyph formatter for the raster's format */
format = FT_Get_Glyph_Format( library, interface->format_tag ); format = FT_Get_Glyph_Format( library, interface->format_tag );
if (!format) if ( !format )
{ {
error = FT_Err_Invalid_Argument; error = FT_Err_Invalid_Argument;
goto Exit; goto Exit;
} }
/* free previous raster object if necessary */ /* free previous raster object if necessary */
if (format->raster_allocated) if ( format->raster_allocated )
{ {
FREE( format->raster ); FREE( format->raster );
format->raster_allocated = 0; format->raster_allocated = 0;
} }
/* allocate new raster object is necessary */ /* allocate new raster object is necessary */
if (!raster) if ( !raster )
{ {
if ( ALLOC( raster, interface->size ) ) if ( ALLOC( raster, interface->size ) )
goto Exit; goto Exit;
format->raster_allocated = 1; format->raster_allocated = 1;
} }
format->raster = raster; format->raster = raster;
format->raster_interface = interface; format->raster_interface = interface;
/* initialize the raster object */ /* initialize the raster object */
error = interface->init( raster, error = interface->init( raster,
(char*)library->raster_pool, (char*)library->raster_pool,
FT_RENDER_POOL_SIZE ); FT_RENDER_POOL_SIZE );
if (error) if ( error )
{ {
if (format->raster_allocated) if ( format->raster_allocated )
{ {
FREE( format->raster ); FREE( format->raster );
format->raster_allocated = 0; format->raster_allocated = 0;
@ -396,54 +415,106 @@
return error; return error;
} }
/*************************************************************************/
/* */
/* <Function> */
/* FT_Set_Debug_Hook */
/* */
/* <Description> */
/* Sets a debug hook function for debugging the interpreter of a */
/* font format. */
/* */
/* <Input> */
/* library :: A handle to the library object. */
/* hook_index :: The index of the debug hook. You should use the */
/* values defined in ftobjs.h, e.g. */
/* FT_DEBUG_HOOK_TRUETYPE */
/* debug_hook :: The function used to debug the interpreter. */
/* */
/* <Note> */
/* Currently, four debug hook slots are available, but only two (for */
/* the TrueType and the Type 1 interpreter) are defined. */
/* */
EXPORT_FUNC EXPORT_FUNC
void FT_Set_Debug_Hook( FT_Library library, void FT_Set_Debug_Hook( FT_Library library,
FT_UInt hook_index, FT_UInt hook_index,
FT_DebugHook_Func debug_hook ) FT_DebugHook_Func debug_hook )
{ {
if (hook_index < (sizeof(library->debug_hooks)/sizeof(void*))) if ( hook_index < ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
{
library->debug_hooks[hook_index] = debug_hook; library->debug_hooks[hook_index] = debug_hook;
}
} }
/*************************************************************************/
/* */
/* <Function> */
/* FT_Add_Glyph_Format */
/* */
/* <Description> */
/* Adds a glyph format to the library. */
/* */
/* <InOut> */
/* library :: A handle to the library object. */
/* */
/* <Input> */
/* format :: A pointer to the new glyph format. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
BASE_FUNC BASE_FUNC
FT_Error FT_Add_Glyph_Format( FT_Library library, FT_Error FT_Add_Glyph_Format( FT_Library library,
FT_Glyph_Format* format ) FT_Glyph_Format* format )
{ {
FT_Glyph_Format* new = 0; FT_Glyph_Format* new = 0;
{ {
FT_Glyph_Format* cur = library->glyph_formats; FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
/* return an error if the format is already registered */ /* return an error if the format is already registered */
if ( cur->format_tag == format->format_tag ) if ( cur->format_tag == format->format_tag )
return FT_Err_Invalid_Glyph_Format; return FT_Err_Invalid_Glyph_Format;
if ( cur->format_tag == 0 && new == 0 ) if ( cur->format_tag == 0 && new == 0 )
new = cur; new = cur;
} }
} }
/* if there is no place to hold the new format, return an error */ /* if there is no place to hold the new format, return an error */
if (!new) if (!new)
return FT_Err_Too_Many_Glyph_Formats; return FT_Err_Too_Many_Glyph_Formats;
*new = *format; *new = *format;
/* now, create a raster object if we need to */ /* now, create a raster object if we need to */
return FT_Set_Raster( library, return FT_Set_Raster( library,
format->raster_interface, format->raster_interface,
format->raster ); format->raster );
} }
/*************************************************************************/
/* */
/* <Function> */
/* FT_Remove_Glyph_Format */
/* */
/* <Description> */
/* Removes a glyph format from the library. */
/* */
/* <InOut> */
/* library :: A handle to the library object. */
/* */
/* <Input> */
/* format_tag :: A tag identifying the format to be removed. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
BASE_FUNC BASE_FUNC
FT_Error FT_Remove_Glyph_Format( FT_Library library, FT_Error FT_Remove_Glyph_Format( FT_Library library,
FT_Glyph_Tag format_tag ) FT_Glyph_Tag format_tag )
@ -451,14 +522,15 @@
FT_Memory memory; FT_Memory memory;
FT_Glyph_Format* cur = library->glyph_formats; FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
memory = library->memory; memory = library->memory;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
if (cur->format_tag == format_tag) if ( cur->format_tag == format_tag )
{ {
if (cur->raster_allocated) if ( cur->raster_allocated )
{ {
FREE( cur->raster ); FREE( cur->raster );
cur->raster_allocated = 0; cur->raster_allocated = 0;
@ -467,7 +539,7 @@
return FT_Err_Ok; return FT_Err_Ok;
} }
} }
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
} }
@ -483,13 +555,13 @@
/* with distinct memory allocators within the same program. */ /* with distinct memory allocators within the same program. */
/* */ /* */
/* <Input> */ /* <Input> */
/* memory :: A handle to the original memory object. */ /* memory :: A handle to the original memory object. */
/* */ /* */
/* <Output> */ /* <Output> */
/* library :: A handle to a new library object. */ /* alibrary :: A pointer to handle of a new library object. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_New_Library( FT_Memory memory, FT_Error FT_New_Library( FT_Memory memory,
@ -498,6 +570,7 @@
FT_Library library = 0; FT_Library library = 0;
FT_Error error; FT_Error error;
/* First of all, allocate the library object */ /* First of all, allocate the library object */
if ( ALLOC( library, sizeof ( *library ) ) ) if ( ALLOC( library, sizeof ( *library ) ) )
return error; return error;
@ -513,7 +586,8 @@
0, 0,
0 0
}; };
error = FT_Add_Glyph_Format( library, &outline_format ); error = FT_Add_Glyph_Format( library, &outline_format );
} }
@ -537,7 +611,7 @@
/* library :: A handle to the target library */ /* library :: A handle to the target library */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Done_Library( FT_Library library ) FT_Error FT_Done_Library( FT_Library library )
@ -552,7 +626,7 @@
memory = library->memory; memory = library->memory;
/* Discard client-data */ /* Discard client-data */
if( library->generic.finalizer ) if ( library->generic.finalizer )
library->generic.finalizer( library ); library->generic.finalizer( library );
/* Close all drivers in the library */ /* Close all drivers in the library */
@ -560,6 +634,7 @@
{ {
FT_Driver driver = library->drivers[n]; FT_Driver driver = library->drivers[n];
if ( driver ) if ( driver )
{ {
Destroy_Driver( driver ); Destroy_Driver( driver );
@ -569,11 +644,12 @@
/* Destroy raster object */ /* Destroy raster object */
FREE( library->raster_pool ); FREE( library->raster_pool );
{ {
FT_Glyph_Format* cur = library->glyph_formats; FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
if ( cur->raster_allocated ) if ( cur->raster_allocated )
@ -596,15 +672,18 @@
/* FT_Set_Raster_Mode */ /* FT_Set_Raster_Mode */
/* */ /* */
/* <Description> */ /* <Description> */
/* Set a raster-specific mode. */ /* Sets a raster-specific mode. */
/* */
/* <InOut> */
/* library :: A handle to a target library object. */
/* */ /* */
/* <Input> */ /* <Input> */
/* library :: A handle to a target library object. */ /* format :: The glyph format used to select the raster. */
/* format :: the glyph format used to select the raster */ /* mode :: The raster-specific mode descriptor. */
/* mode :: the raster-specific mode descriptor */ /* args :: The mode arguments. */
/* args :: the mode arguments */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Set_Raster_Mode( FT_Library library, FT_Error FT_Set_Raster_Mode( FT_Library library,
@ -616,13 +695,15 @@
FT_Error error; FT_Error error;
FT_Glyph_Format* format = 0; FT_Glyph_Format* format = 0;
{ {
FT_Glyph_Format* cur = library->glyph_formats; FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for (; cur < limit; cur++)
for ( ; cur < limit; cur++ )
{ {
if (cur->format_tag == format_tag) if ( cur->format_tag == format_tag )
{ {
format = cur; format = cur;
break; break;
@ -630,14 +711,15 @@
} }
} }
if (!format) if ( !format )
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
memory = library->memory; memory = library->memory;
error = FT_Err_Ok; error = FT_Err_Ok;
if (format->raster) if ( format->raster )
error = format->raster_interface->set_mode( format->raster, mode, args ); error = format->raster_interface->set_mode( format->raster,
mode, args );
return error; return error;
} }
@ -650,16 +732,17 @@
/* */ /* */
/* <Description> */ /* <Description> */
/* Registers a new driver in a given library object. This function */ /* Registers a new driver in a given library object. This function */
/* takes only a pointer to a driver interface. It uses it to create */ /* takes only a pointer to a driver interface; it uses it to create */
/* the new driver, then sets up some important fields. */ /* the new driver, then sets up some important fields. */
/* */ /* */
/* <Input> */ /* <InOut> */
/* library :: A handle to the target library object. */ /* library :: A handle to the target library object. */
/* */ /* */
/* <Input> */
/* driver_interface :: A pointer to a driver interface table. */ /* driver_interface :: A pointer to a driver interface table. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
/* <Note> */ /* <Note> */
/* This function doesn't check whether the driver is already */ /* This function doesn't check whether the driver is already */
@ -673,6 +756,7 @@
FT_Driver driver; FT_Driver driver;
FT_Memory memory; FT_Memory memory;
if ( !library || !driver_interface ) if ( !library || !driver_interface )
return FT_Err_Invalid_Library_Handle; return FT_Err_Invalid_Library_Handle;
@ -690,10 +774,11 @@
driver->memory = memory; driver->memory = memory;
driver->interface = *driver_interface; driver->interface = *driver_interface;
if (driver_interface->init_driver) if ( driver_interface->init_driver )
{ {
error = driver_interface->init_driver( driver ); error = driver_interface->init_driver( driver );
if ( error ) goto Fail; if ( error )
goto Fail;
} }
library->drivers[library->num_drivers++] = driver; library->drivers[library->num_drivers++] = driver;
@ -714,7 +799,7 @@
/* FT_Remove_Driver */ /* FT_Remove_Driver */
/* */ /* */
/* <Description> */ /* <Description> */
/* Unregister a given driver. This closes the driver, which in turn */ /* Unregisters a given driver. This closes the driver, which in turn */
/* destroys all faces, sizes, slots, etc. associated with it. */ /* destroys all faces, sizes, slots, etc. associated with it. */
/* */ /* */
/* This function also DESTROYS the driver object. */ /* This function also DESTROYS the driver object. */
@ -723,7 +808,7 @@
/* driver :: A handle to target driver object. */ /* driver :: A handle to target driver object. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Remove_Driver( FT_Driver driver ) FT_Error FT_Remove_Driver( FT_Driver driver )
@ -756,7 +841,7 @@
Destroy_Driver( driver ); Destroy_Driver( driver );
/* now move the last driver in the table to the vacant slot */ /* now move the last driver in the table to the vacant slot */
if (cur < last) if ( cur < last )
{ {
*cur = *last; *cur = *last;
*last = 0; *last = 0;
@ -778,25 +863,26 @@
/* FT_Get_Driver */ /* FT_Get_Driver */
/* */ /* */
/* <Description> */ /* <Description> */
/* returns the handle of the driver responsible for a given format */ /* Returns the handle of the driver responsible for a given format */
/* (or service) according to its `name'. */ /* (or service) according to its `name'. */
/* */ /* */
/* <Input> */ /* <Input> */
/* library :: handle to library object. */ /* library :: A handle to the library object. */
/* driver_name :: name of driver to look-up. */ /* driver_name :: The name of the driver to look up. */
/* */ /* */
/* <Return> */ /* <Return> */
/* handle to driver object. 0 otherwise */ /* A handle to the driver object, 0 otherwise. */
/* */ /* */
EXPORT_FUNC EXPORT_FUNC
FT_Driver FT_Get_Driver( FT_Library library, FT_Driver FT_Get_Driver( FT_Library library,
char* driver_name ) char* driver_name )
{ {
FT_Driver *cur, *limit; FT_Driver *cur, *limit;
if (!library || !driver_name)
if ( !library || !driver_name )
return 0; return 0;
cur = library->drivers; cur = library->drivers;
limit = cur + library->num_drivers; limit = cur + library->num_drivers;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
@ -808,7 +894,6 @@
} }
static static
FT_Error open_face( FT_Driver driver, FT_Error open_face( FT_Driver driver,
FT_Stream stream, FT_Stream stream,
@ -868,7 +953,7 @@
/* face :: A handle to a new face object. */ /* face :: A handle to a new face object. */
/* */ /* */
/* <Return> */ /* <Return> */
/* Error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
/* <Note> */ /* <Note> */
/* Unlike FreeType 1.1, this function automatically creates a glyph */ /* Unlike FreeType 1.1, this function automatically creates a glyph */
@ -894,29 +979,31 @@
FT_Stream stream; FT_Stream stream;
FT_Memory memory; FT_Memory memory;
FT_Error error; FT_Error error;
memory = library->memory; memory = library->memory;
if ( ALLOC( stream, sizeof(*stream) ) ) if ( ALLOC( stream, sizeof ( *stream ) ) )
goto Fail; goto Fail;
stream->memory = memory; stream->memory = memory;
error = FT_New_Stream( pathname, stream ); error = FT_New_Stream( pathname, stream );
if (error) goto Fail_Stream; if (error) goto Fail_Stream;
error = FT_Open_Face( library, stream, face_index, aface ); error = FT_Open_Face( library, stream, face_index, aface );
if (!error) if ( !error )
return error; return error;
/* close stream in case of error */ /* close stream in case of error */
stream->close( stream ); stream->close( stream );
Fail_Stream: Fail_Stream:
FREE(stream); FREE( stream );
Fail: Fail:
return error; return error;
} }
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_New_Memory_Face( FT_Library library, FT_Error FT_New_Memory_Face( FT_Library library,
void* file_base, void* file_base,
@ -927,15 +1014,15 @@
FT_Stream stream; FT_Stream stream;
FT_Memory memory; FT_Memory memory;
FT_Error error; FT_Error error;
memory = library->memory; memory = library->memory;
if ( ALLOC( stream, sizeof(*stream) ) ) if ( ALLOC( stream, sizeof(*stream) ) )
goto Fail; goto Fail;
stream->memory = memory; stream->memory = memory;
FT_New_Memory_Stream( library, (void*)file_base, file_size, stream ); FT_New_Memory_Stream( library, (void*)file_base, file_size, stream );
error = FT_Open_Face( library, stream, face_index, face ); error = FT_Open_Face( library, stream, face_index, face );
if (!error) if (!error)
return error; return error;
@ -945,7 +1032,7 @@
return error; return error;
} }
EXPORT_FUNC EXPORT_FUNC
FT_Error FT_Open_Face( FT_Library library, FT_Error FT_Open_Face( FT_Library library,
FT_Stream stream, FT_Stream stream,
@ -967,8 +1054,8 @@
{ {
/* check each font driver for an appropriate format */ /* check each font driver for an appropriate format */
FT_Driver* cur = library->drivers; FT_Driver* cur = library->drivers;
FT_Driver* limit = cur + library->num_drivers; FT_Driver* limit = cur + library->num_drivers;
for ( ; cur < limit; cur++ ) for ( ; cur < limit; cur++ )
{ {
@ -1019,7 +1106,7 @@
error = FT_New_GlyphSlot( face, &slot ); error = FT_New_GlyphSlot( face, &slot );
if ( error ) goto Fail; if ( error ) goto Fail;
} }
/****************************************************************/ /****************************************************************/
/* finally allocate a size object for the face */ /* finally allocate a size object for the face */
{ {
@ -1029,7 +1116,7 @@
error = FT_New_Size( face, &size ); error = FT_New_Size( face, &size );
if ( error ) goto Fail; if ( error ) goto Fail;
} }
*aface = face; *aface = face;
goto Exit; goto Exit;
@ -1037,7 +1124,7 @@
FT_Done_Face( face ); FT_Done_Face( face );
Bad_Resource: Bad_Resource:
Exit: Exit:
FT_TRACE4(( "FT_Open_Face: Return %d\n", error )); FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
return error; return error;
@ -1148,7 +1235,7 @@
*asize = size; *asize = size;
node->data = size; node->data = size;
FT_List_Add( &face->sizes_list, node ); FT_List_Add( &face->sizes_list, node );
/* record as current size for the face */ /* record as current size for the face */
face->size = size; face->size = size;
} }
@ -1259,13 +1346,13 @@
if (!char_width) if (!char_width)
char_width = char_height; char_width = char_height;
else if (!char_height) else if (!char_height)
char_height = char_width; char_height = char_width;
if (!horz_resolution) if (!horz_resolution)
horz_resolution = 72; horz_resolution = 72;
if (!vert_resolution) if (!vert_resolution)
vert_resolution = 72; vert_resolution = 72;
@ -1367,7 +1454,7 @@
goto Exit; goto Exit;
slot->face = face; slot->face = face;
slot->max_subglyphs = 0; slot->max_subglyphs = 0;
slot->num_subglyphs = 0; slot->num_subglyphs = 0;
slot->subglyphs = 0; slot->subglyphs = 0;
@ -1497,13 +1584,13 @@
FT_Error error; FT_Error error;
FT_Driver driver; FT_Driver driver;
FT_UInt glyph_index; FT_UInt glyph_index;
if (!face || !face->size || !face->glyph || !face->charmap ) if (!face || !face->size || !face->glyph || !face->charmap )
return FT_Err_Invalid_Face_Handle; return FT_Err_Invalid_Face_Handle;
driver = face->driver; driver = face->driver;
glyph_index = FT_Get_Char_Index( face, char_code ); glyph_index = FT_Get_Char_Index( face, char_code );
if (glyph_index == 0) if (glyph_index == 0)
error = FT_Err_Invalid_Character_Code; error = FT_Err_Invalid_Character_Code;
else else

View File

@ -107,17 +107,17 @@
{ {
FT_Error error; FT_Error error;
FT_Glyph_Format* format; FT_Glyph_Format* format;
error = FT_Err_Invalid_Glyph_Format; error = FT_Err_Invalid_Glyph_Format;
format = FT_Get_Glyph_Format( library, ft_glyph_format_outline ); format = FT_Get_Glyph_Format( library, ft_glyph_format_outline );
if (!format) goto Exit; if (!format) goto Exit;
error = FT_Err_Invalid_Glyph_Format; error = FT_Err_Invalid_Glyph_Format;
if (!format->raster) goto Exit; if (!format->raster) goto Exit;
error = format->raster_interface->render( format->raster, outline, map ); error = format->raster_interface->render( format->raster, outline, map );
Exit: Exit:
return error; return error;
} }

View File

@ -683,7 +683,7 @@
x = ras.cursor[-1]; x = ras.cursor[-1];
switch ( ras.cur_prof->flow ) switch ( ras.cur_prof->flow )
{ {
case FT_Flow_Up: case FT_Flow_Up:
o = Vio_ScanLineWidth * o = Vio_ScanLineWidth *
@ -1202,7 +1202,7 @@
Ix --; Ix --;
Rx += Dy; Rx += Dy;
} }
Ax = -Dy; Ax = -Dy;
Rx <<= 1; Rx <<= 1;
Dy <<= 1; Dy <<= 1;
@ -1332,7 +1332,7 @@
e = CEILING( y1 ); /* integer start y == current scanline */ e = CEILING( y1 ); /* integer start y == current scanline */
f1 = FRAC( y1 ); /* fractional shift of start y */ f1 = FRAC( y1 ); /* fractional shift of start y */
e0 = e; /* first integer scanline to be pushed */ e0 = e; /* first integer scanline to be pushed */
if ( f1 == 0 ) /* do we start on an integer scanline? */ if ( f1 == 0 ) /* do we start on an integer scanline? */
{ {
if ( ras.joint ) if ( ras.joint )
@ -1381,7 +1381,7 @@
if ( y2 > e ) /* the arc intercepts the current scanline */ if ( y2 > e ) /* the arc intercepts the current scanline */
{ {
y1 = arc[degree].y; /* start y of top-most arc */ y1 = arc[degree].y; /* start y of top-most arc */
if ( y2 - y1 >= ras.precision_step ) if ( y2 - y1 >= ras.precision_step )
{ {
/* if the arc's height is too great, split it */ /* if the arc's height is too great, split it */
@ -1726,7 +1726,7 @@
{ {
TPos scaled_x, scaled_y; TPos scaled_x, scaled_y;
/* if there was already a contour being built, perform some checks */ /* if there was already a contour being built, perform some checks */
if ( ras.start_prof ) if ( ras.start_prof )
if ( Check_Contour( RAS_VAR ) ) if ( Check_Contour( RAS_VAR ) )
@ -1735,7 +1735,7 @@
/* set the `current last point' */ /* set the `current last point' */
scaled_x = SCALED( to->x ); scaled_x = SCALED( to->x );
scaled_y = SCALED( to->y ); scaled_y = SCALED( to->y );
if ( ras.flipped ) if ( ras.flipped )
{ {
ras.last.x = scaled_y; ras.last.x = scaled_y;
@ -1803,7 +1803,7 @@
if ( ras.state != new_state ) if ( ras.state != new_state )
{ {
if ( ras.state != Unknown && if ( ras.state != Unknown &&
End_Profile( RAS_VAR ) ) End_Profile( RAS_VAR ) )
goto Fail; goto Fail;
@ -1811,7 +1811,7 @@
if ( New_Profile( RAS_VAR_ new_state ) ) if ( New_Profile( RAS_VAR_ new_state ) )
goto Fail; goto Fail;
} }
} }
/* Then compute the lines */ /* Then compute the lines */
switch ( ras.state ) switch ( ras.state )
@ -1896,7 +1896,7 @@
ymin = y3; ymin = y3;
ymax = y1; ymax = y1;
} }
if ( y2 < ymin || y2 > ymax ) if ( y2 < ymin || y2 > ymax )
{ {
/* this arc has no given direction, split it !! */ /* this arc has no given direction, split it !! */
@ -1919,12 +1919,12 @@
if ( ras.state != Unknown && if ( ras.state != Unknown &&
End_Profile( RAS_VAR ) ) End_Profile( RAS_VAR ) )
goto Fail; goto Fail;
/* create a new profile */ /* create a new profile */
if ( New_Profile( RAS_VAR_ state_bez ) ) if ( New_Profile( RAS_VAR_ state_bez ) )
goto Fail; goto Fail;
} }
/* now call the appropriate routine */ /* now call the appropriate routine */
if ( state_bez == Ascending ) if ( state_bez == Ascending )
{ {
@ -1934,7 +1934,7 @@
else else
if ( Bezier_Down( RAS_VAR_ 2, Split_Conic, ras.minY, ras.maxY ) ) if ( Bezier_Down( RAS_VAR_ 2, Split_Conic, ras.minY, ras.maxY ) )
goto Fail; goto Fail;
} }
} while ( ras.arc >= ras.arcs ); } while ( ras.arc >= ras.arcs );
@ -2023,7 +2023,7 @@
ymin1 = y4; ymin1 = y4;
ymax1 = y1; ymax1 = y1;
} }
if ( y2 <= y3 ) if ( y2 <= y3 )
{ {
ymin2 = y2; ymin2 = y2;
@ -2034,7 +2034,7 @@
ymin2 = y3; ymin2 = y3;
ymax2 = y2; ymax2 = y2;
} }
if ( ymin2 < ymin1 || ymax2 > ymax1 ) if ( ymin2 < ymin1 || ymax2 > ymax1 )
{ {
/* this arc has no given direction, split it! */ /* this arc has no given direction, split it! */
@ -2045,11 +2045,11 @@
{ {
/* this arc is flat, ignore it and pop it from the bezier stack */ /* this arc is flat, ignore it and pop it from the bezier stack */
ras.arc -= 3; ras.arc -= 3;
} }
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 )
{ {
@ -2616,11 +2616,11 @@
void Vertical_Sweep_Init( RAS_ARG_ int* min, int* max ) void Vertical_Sweep_Init( RAS_ARG_ int* min, int* max )
{ {
long pitch; long pitch;
UNUSED( max ); UNUSED( max );
pitch = ras.target.pitch; pitch = ras.target.pitch;
/* start from the bottom line, going up !! */ /* start from the bottom line, going up !! */
ras.trace_bit = - *min * pitch; ras.trace_bit = - *min * pitch;
ras.trace_incr = -pitch; ras.trace_incr = -pitch;
@ -2874,10 +2874,10 @@
{ {
long pitch = ras.target.pitch; long pitch = ras.target.pitch;
long offset = - pitch * e1; long offset = - pitch * e1;
if (pitch > 0) if (pitch > 0)
offset += (ras.target.rows-1)*pitch; offset += (ras.target.rows-1)*pitch;
bits[offset] |= f1; bits[offset] |= f1;
} }
} }
@ -2906,10 +2906,10 @@
int f1 = (Byte)(0x80 >> (y & 7)); int f1 = (Byte)(0x80 >> (y & 7));
long pitch = ras.target.pitch; long pitch = ras.target.pitch;
long offset = - pitch * x; long offset = - pitch * x;
if (pitch > 0) if (pitch > 0)
offset += (ras.target.rows-1)*pitch; offset += (ras.target.rows-1)*pitch;
return ( x >= 0 && x < ras.target.rows && (bits[0] & f1) ); return ( x >= 0 && x < ras.target.rows && (bits[0] & f1) );
} }
@ -2943,9 +2943,9 @@
{ {
long pitch = ras.target.pitch; long pitch = ras.target.pitch;
long offset = - x*pitch; long offset = - x*pitch;
if (pitch > 0) if (pitch > 0)
offset += (ras.target.rows-1)*pitch; offset += (ras.target.rows-1)*pitch;
bits[offset] |= f1; bits[offset] |= f1;
} }
@ -3009,15 +3009,15 @@
void Vertical_Gray_Sweep_Init( RAS_ARG_ int* min, int* max ) void Vertical_Gray_Sweep_Init( RAS_ARG_ int* min, int* max )
{ {
long pitch; long pitch;
UNUSED( max ); UNUSED( max );
pitch = ras.target.pitch; pitch = ras.target.pitch;
/* start from the bottom line, going up */ /* start from the bottom line, going up */
ras.trace_incr = -pitch; ras.trace_incr = -pitch;
ras.trace_bit = - *min * pitch; ras.trace_bit = - *min * pitch;
if (pitch > 0) if (pitch > 0)
ras.trace_bit += (ras.target.rows-1)*pitch; ras.trace_bit += (ras.target.rows-1)*pitch;
} }
@ -3050,15 +3050,15 @@
x1 += ras.precision_half; x1 += ras.precision_half;
x2 += ras.precision_half; x2 += ras.precision_half;
#ifdef FT_RASTER_OPTION_CONTRAST #ifdef FT_RASTER_OPTION_CONTRAST
if ( x2-x1 < ras.precision ) if ( x2-x1 < ras.precision )
{ {
x1 = ((x1+x2) >> 1) - ras.precision_half; x1 = ((x1+x2) >> 1) - ras.precision_half;
x2 = x1 + ras.precision; x2 = x1 + ras.precision;
} }
#endif #endif
e1 = TRUNC( x1 ); e1 = TRUNC( x1 );
e2 = TRUNC( x2 ); e2 = TRUNC( x2 );
@ -3081,7 +3081,7 @@
target = ras.bit_buffer + ras.trace_bit + e1; target = ras.bit_buffer + ras.trace_bit + e1;
e2 -= e1; e2 -= e1;
if ( e2 > 0 ) if ( e2 > 0 )
{ {
if (x1 > 0) target[0] += (Byte)(64-x1) << 1; if (x1 > 0) target[0] += (Byte)(64-x1) << 1;
@ -3124,7 +3124,7 @@
#if 0 #if 0
/* as a rule of thumb, do not add a drop-out if the current */ /* as a rule of thumb, do not add a drop-out if the current */
/* gray level is over 0.5 */ /* gray level is over 0.5 */
return ( x >= 0 && x < ras.bit_width && return ( x >= 0 && x < ras.bit_width &&
ras.bit_buffer[ras.trace_bit + x] >= 64 ); ras.bit_buffer[ras.trace_bit + x] >= 64 );
#else #else
@ -3158,9 +3158,9 @@
if ( x >= 0 && x < ras.bit_width ) if ( x >= 0 && x < ras.bit_width )
{ {
unsigned char* pixel; unsigned char* pixel;
pixel = ras.bit_buffer + ras.trace_bit + x; pixel = ras.bit_buffer + ras.trace_bit + x;
/* do not add too much to the pixel gray level */ /* do not add too much to the pixel gray level */
color += *pixel; color += *pixel;
if (color < 64) if (color < 64)
@ -3267,14 +3267,14 @@
x1 += ras.precision_half; x1 += ras.precision_half;
x2 += ras.precision_half; x2 += ras.precision_half;
#ifdef FT_RASTER_OPTION_CONTRAST #ifdef FT_RASTER_OPTION_CONTRAST
if (x2-x1 < ras.precision) if (x2-x1 < ras.precision)
{ {
x1 = ((x1+x2) >> 1) - ras.precision_half; x1 = ((x1+x2) >> 1) - ras.precision_half;
x2 = x1 + ras.precision; x2 = x1 + ras.precision;
} }
#endif #endif
e1 = TRUNC( x1 ); e1 = TRUNC( x1 );
e2 = TRUNC( x2 ); e2 = TRUNC( x2 );
@ -3299,16 +3299,16 @@
bits = ras.bit_buffer + y; bits = ras.bit_buffer + y;
bits += incr * e1; bits += incr * e1;
if (incr < 0) if (incr < 0)
bits -= incr*(ras.target.rows-1); bits -= incr*(ras.target.rows-1);
e2 -= e1; e2 -= e1;
if ( e2 > 0 ) if ( e2 > 0 )
{ {
b = bits[0]; b = bits[0];
if (b < 127) b++; if (b < 127) b++;
bits[0] = (64-x1) + (b >> 1); bits[0] = (64-x1) + (b >> 1);
if ( ras.precision > 64 ) if ( ras.precision > 64 )
{ {
e2--; e2--;
@ -3316,16 +3316,16 @@
{ {
bits += incr; bits += incr;
b = bits[0]; b = bits[0];
if (b < 127) if (b < 127)
bits[0] = (Byte)(63+((b+1) >> 1)); bits[0] = (Byte)(63+((b+1) >> 1));
e2--; e2--;
} }
} }
else else
bits += incr*(e2-1); bits += incr*(e2-1);
if (x2) if (x2)
{ {
bits += incr; bits += incr;
@ -3403,10 +3403,10 @@
if ( x >= 0 && x < ras.target.rows ) if ( x >= 0 && x < ras.target.rows )
{ {
long pitch = ras.target.pitch; long pitch = ras.target.pitch;
pixel -= pitch*x; pixel -= pitch*x;
if (pitch > 0) if (pitch > 0)
pixel += pitch*(ras.target.rows-1); pixel += pitch*(ras.target.rows-1);
color += *pixel; color += *pixel;
if (color < 64) if (color < 64)
@ -4273,7 +4273,7 @@ Scan_DropOuts :
/* clear anti-alias intermediate lines */ /* clear anti-alias intermediate lines */
{ {
char* p = raster->gray_lines; char* p = raster->gray_lines;
char* limit = p + ANTI_ALIAS_BUFFER_SIZE; char* limit = p + ANTI_ALIAS_BUFFER_SIZE;
do *p++ = 0; while ( p < limit ); do *p++ = 0; while ( p < limit );
} }
@ -4383,10 +4383,10 @@ Scan_DropOuts :
{ {
sizeof( struct FT_RasterRec_ ), sizeof( struct FT_RasterRec_ ),
ft_glyph_format_outline, ft_glyph_format_outline,
(FT_Raster_Init_Proc) FT_Raster_Init, (FT_Raster_Init_Proc) FT_Raster_Init,
(FT_Raster_Set_Mode_Proc) 0, (FT_Raster_Set_Mode_Proc) 0,
(FT_Raster_Render_Proc) FT_Raster_Render (FT_Raster_Render_Proc) FT_Raster_Render
}; };

View File

@ -26,9 +26,9 @@
FT_ULong pos ) FT_ULong pos )
{ {
FT_Error error; FT_Error error;
stream->pos = pos; stream->pos = pos;
if (stream->read) if (stream->read)
{ {
if (stream->read( stream, pos, 0, 0 )) if (stream->read( stream, pos, 0, 0 ))
@ -51,30 +51,30 @@
FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n", FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n",
pos, stream->size )); pos, stream->size ));
} }
else else
error = FT_Err_Ok; error = FT_Err_Ok;
return error; return error;
} }
BASE_FUNC BASE_FUNC
FT_Error FT_Skip_Stream( FT_Stream stream, FT_Error FT_Skip_Stream( FT_Stream stream,
FT_Long distance ) FT_Long distance )
{ {
return FT_Seek_Stream( stream, (FT_ULong)(stream->pos + distance) ); return FT_Seek_Stream( stream, (FT_ULong)(stream->pos + distance) );
} }
BASE_FUNC BASE_FUNC
FT_Long FT_Stream_Pos( FT_Stream stream ) FT_Long FT_Stream_Pos( FT_Stream stream )
{ {
return stream->pos; return stream->pos;
} }
BASE_FUNC BASE_FUNC
FT_Error FT_Read_Stream( FT_Stream stream, FT_Error FT_Read_Stream( FT_Stream stream,
void* buffer, void* buffer,
@ -82,8 +82,8 @@
{ {
return FT_Read_Stream_At( stream, stream->pos, buffer, count ); return FT_Read_Stream_At( stream, stream->pos, buffer, count );
} }
BASE_FUNC BASE_FUNC
FT_Error FT_Read_Stream_At( FT_Stream stream, FT_Error FT_Read_Stream_At( FT_Stream stream,
FT_ULong pos, FT_ULong pos,
@ -92,16 +92,16 @@
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_ULong read_bytes; FT_ULong read_bytes;
if (pos >= stream->size) if (pos >= stream->size)
{ {
FT_ERROR(( "FT_Read_Stream_At:" )); FT_ERROR(( "FT_Read_Stream_At:" ));
FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n", FT_ERROR(( " invalid i/o, pos = 0x%lx, size = 0x%lx\n",
pos, stream->size )); pos, stream->size ));
return FT_Err_Invalid_Stream_Operation; return FT_Err_Invalid_Stream_Operation;
} }
if (stream->read) if (stream->read)
read_bytes = stream->read( stream, pos, buffer, count ); read_bytes = stream->read( stream, pos, buffer, count );
else else
@ -109,10 +109,10 @@
read_bytes = stream->size - pos; read_bytes = stream->size - pos;
if (read_bytes > count) if (read_bytes > count)
read_bytes = count; read_bytes = count;
MEM_Copy( buffer, stream->base + pos, read_bytes ); MEM_Copy( buffer, stream->base + pos, read_bytes );
} }
stream->pos = pos + read_bytes; stream->pos = pos + read_bytes;
if (read_bytes < count) if (read_bytes < count)
@ -125,9 +125,9 @@
return error; return error;
} }
BASE_FUNC BASE_FUNC
FT_Error FT_Access_Frame( FT_Stream stream, FT_Error FT_Access_Frame( FT_Stream stream,
FT_ULong count ) FT_ULong count )
@ -136,25 +136,25 @@
FT_ULong read_bytes; FT_ULong read_bytes;
/* check for nested frame access */ /* check for nested frame access */
FT_Assert( stream && stream->cursor == 0 ); FT_Assert( stream && stream->cursor == 0 );
if (stream->read) if (stream->read)
{ {
/* allocate the frame in memory */ /* allocate the frame in memory */
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
if ( ALLOC( stream->base, count ) ) if ( ALLOC( stream->base, count ) )
goto Exit; goto Exit;
/* read it */ /* read it */
read_bytes = stream->read( stream, stream->pos, read_bytes = stream->read( stream, stream->pos,
stream->base, count ); stream->base, count );
if (read_bytes < count) if (read_bytes < count)
{ {
FT_ERROR(( "FT_Access_Frame:" )); FT_ERROR(( "FT_Access_Frame:" ));
FT_ERROR(( " invalid read, expected %lu bytes, got %lu", FT_ERROR(( " invalid read, expected %lu bytes, got %lu",
count, read_bytes )); count, read_bytes ));
FREE( stream->base ); FREE( stream->base );
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
} }
@ -170,30 +170,30 @@
FT_ERROR(( "FT_Access_Frame:" )); 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",
stream->pos, count, stream->size )); stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation; error = FT_Err_Invalid_Stream_Operation;
goto Exit; goto Exit;
} }
/* set cursor */ /* set cursor */
stream->cursor = stream->base + stream->pos; stream->cursor = stream->base + stream->pos;
stream->limit = stream->cursor + count; stream->limit = stream->cursor + count;
stream->pos += count; stream->pos += count;
} }
Exit: Exit:
return error; return error;
} }
BASE_FUNC BASE_FUNC
void FT_Forget_Frame( FT_Stream stream ) void FT_Forget_Frame( FT_Stream stream )
{ {
FT_Assert( stream && stream->cursor != 0 ); FT_Assert( stream && stream->cursor != 0 );
if (stream->read) if (stream->read)
{ {
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
FREE( stream->base ); FREE( stream->base );
} }
stream->cursor = 0; stream->cursor = 0;
@ -205,25 +205,25 @@
FT_Char FT_Get_Char( FT_Stream stream ) FT_Char FT_Get_Char( FT_Stream stream )
{ {
FT_Char result; FT_Char result;
FT_Assert( stream && stream->cursor && stream->cursor ); FT_Assert( stream && stream->cursor && stream->cursor );
result = 0; result = 0;
if (stream->cursor < stream->limit) if (stream->cursor < stream->limit)
result = *stream->cursor++; result = *stream->cursor++;
return result; return result;
} }
BASE_FUNC BASE_FUNC
FT_Short FT_Get_Short( FT_Stream stream ) FT_Short FT_Get_Short( FT_Stream stream )
{ {
char* p; char* p;
FT_Short result; FT_Short result;
FT_Assert( stream && stream->cursor ); FT_Assert( stream && stream->cursor );
result = 0; result = 0;
p = stream->cursor; p = stream->cursor;
if (p+1 < stream->limit) if (p+1 < stream->limit)
@ -231,16 +231,16 @@
stream->cursor = p; stream->cursor = p;
return result; return result;
} }
BASE_FUNC BASE_FUNC
FT_Long FT_Get_Offset( FT_Stream stream ) FT_Long FT_Get_Offset( FT_Stream stream )
{ {
char* p; char* p;
FT_Long result; FT_Long result;
FT_Assert( stream && stream->cursor ); FT_Assert( stream && stream->cursor );
result = 0; result = 0;
p = stream->cursor; p = stream->cursor;
if (p+2 < stream->limit) if (p+2 < stream->limit)
@ -248,35 +248,35 @@
stream->cursor = p; stream->cursor = p;
return result; return result;
} }
BASE_FUNC BASE_FUNC
FT_Long FT_Get_Long( FT_Stream stream ) FT_Long FT_Get_Long( FT_Stream stream )
{ {
char* p; char* p;
FT_Long result; FT_Long result;
FT_Assert( stream && stream->cursor ); FT_Assert( stream && stream->cursor );
result = 0; result = 0;
p = stream->cursor; p = stream->cursor;
if (p+3 < stream->limit) if (p+3 < stream->limit)
result = NEXT_Long(p); result = NEXT_Long(p);
stream->cursor = p; stream->cursor = p;
return result; return result;
} }
BASE_FUNC BASE_FUNC
FT_Char FT_Read_Char( FT_Stream stream, FT_Char FT_Read_Char( FT_Stream stream,
FT_Error* error ) FT_Error* error )
{ {
char result = 0; char result = 0;
FT_Assert( stream ); FT_Assert( stream );
*error = FT_Err_Ok; *error = FT_Err_Ok;
if (stream->read) if (stream->read)
{ {
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L ) if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
@ -290,7 +290,7 @@
goto Fail; goto Fail;
} }
return result; return result;
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Char:" )); FT_ERROR(( "FT_Read_Char:" ));
@ -298,7 +298,7 @@
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
} }
BASE_FUNC BASE_FUNC
FT_Short FT_Read_Short( FT_Stream stream, FT_Short FT_Read_Short( FT_Stream stream,
@ -307,25 +307,25 @@
char reads[2]; char reads[2];
char* p = 0; char* p = 0;
FT_Short result = 0; FT_Short result = 0;
FT_Assert( stream ); FT_Assert( stream );
*error = FT_Err_Ok; *error = FT_Err_Ok;
if (stream->pos+1 < stream->size) if (stream->pos+1 < stream->size)
{ {
if (stream->read) if (stream->read)
{ {
if (stream->read( stream, stream->pos, reads, 2L ) != 2L ) if (stream->read( stream, stream->pos, reads, 2L ) != 2L )
goto Fail; goto Fail;
p = reads; p = reads;
} }
else else
{ {
p = stream->base + stream->pos; p = stream->base + stream->pos;
} }
if (p) if (p)
{ {
result = NEXT_Short(p); result = NEXT_Short(p);
@ -335,7 +335,7 @@
else goto Fail; else goto Fail;
return result; return result;
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Short:" )); FT_ERROR(( "FT_Read_Short:" ));
@ -343,7 +343,7 @@
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
} }
BASE_FUNC BASE_FUNC
FT_Long FT_Read_Offset( FT_Stream stream, FT_Long FT_Read_Offset( FT_Stream stream,
@ -352,25 +352,25 @@
char reads[3]; char reads[3];
char* p = 0; char* p = 0;
FT_Long result = 0; FT_Long result = 0;
FT_Assert( stream ); FT_Assert( stream );
*error = FT_Err_Ok; *error = FT_Err_Ok;
if (stream->pos+2 < stream->size) if (stream->pos+2 < stream->size)
{ {
if (stream->read) if (stream->read)
{ {
if (stream->read( stream, stream->pos, reads, 3L ) != 3L ) if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
goto Fail; goto Fail;
p = reads; p = reads;
} }
else else
{ {
p = stream->base + stream->pos; p = stream->base + stream->pos;
} }
if (p) if (p)
{ {
result = NEXT_Offset(p); result = NEXT_Offset(p);
@ -378,9 +378,9 @@
} }
} }
else goto Fail; else goto Fail;
return result; return result;
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Offset:" )); FT_ERROR(( "FT_Read_Offset:" ));
@ -388,7 +388,7 @@
stream->pos, stream->size )); stream->pos, stream->size ));
return 0; return 0;
} }
BASE_FUNC BASE_FUNC
FT_Long FT_Read_Long( FT_Stream stream, FT_Long FT_Read_Long( FT_Stream stream,
@ -397,25 +397,25 @@
char reads[4]; char reads[4];
char* p = 0; char* p = 0;
FT_Long result = 0; FT_Long result = 0;
FT_Assert( stream ); FT_Assert( stream );
*error = FT_Err_Ok; *error = FT_Err_Ok;
if (stream->pos+3 < stream->size) if (stream->pos+3 < stream->size)
{ {
if (stream->read) if (stream->read)
{ {
if (stream->read( stream, stream->pos, reads, 4L ) != 4L ) if (stream->read( stream, stream->pos, reads, 4L ) != 4L )
goto Fail; goto Fail;
p = reads; p = reads;
} }
else else
{ {
p = stream->base + stream->pos; p = stream->base + stream->pos;
} }
if (p) if (p)
{ {
result = NEXT_Long(p); result = NEXT_Long(p);
@ -425,7 +425,7 @@
else goto Fail; else goto Fail;
return result; return result;
Fail: Fail:
*error = FT_Err_Invalid_Stream_Operation; *error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Read_Long:" )); FT_ERROR(( "FT_Read_Long:" ));