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

@ -4,7 +4,7 @@
/* */
/* FreeType initialisation layer (body). */
/* */
/* Copyright 1996-1999 by */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* 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
* functions:
*
* FT_Default_Drivers:
* This function is used to add the set of default drivers
* to a fresh new library object. The set is computed at compile
* time from the Makefiles inclusions in Makefile.lib. See the
* document "FreeType Internals" for more info.
*
*
* FT_Init_FreeType:
* This function creates a system object for the current platform,
* builds a library out of it, then calls FT_Default_Drivers
*
*
* FT_Done_FreeType:
* 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"
*
*
*
*
*
************************************************************************/
/*************************************************************************/
/* */
/* The purpose of this file is to implement the three following */
/* functions: */
/* */
/* FT_Default_Drivers: */
/* This function is used to add the set of default drivers to a */
/* fresh new library object. The set is computed at compile time */
/* from the Makefiles inclusions in Makefile.lib. See the document */
/* `FreeType Internals' for more info. */
/* */
/* FT_Init_FreeType: */
/* This function creates a system object for the current platform, */
/* builds a library out of it, then calls FT_Default_Drivers(). */
/* */
/* FT_Done_FreeType: */
/* This function simply finalizes 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'. */
/* */
/*************************************************************************/
#include <ftobjs.h>
#include <ftconfig.h>
@ -57,17 +51,20 @@
#undef FT_DRIVER
#define FT_DRIVER( x ) extern FT_DriverInterface x;
#include <ftmodule.h>
#undef FT_DRIVER
#define FT_DRIVER( x ) &x,
static
const FT_DriverInterface* ft_default_drivers[] = {
const FT_DriverInterface* ft_default_drivers[] =
{
#include <ftmodule.h>
0
};
/*************************************************************************/
/* */
/* <Function> */
@ -76,7 +73,7 @@ const FT_DriverInterface* ft_default_drivers[] = {
/* <Description> */
/* Adds the set of default drivers to a given library object. */
/* */
/* <Input> */
/* <InOut> */
/* library :: A handle to a new library object. */
/* */
EXPORT_FUNC
@ -85,16 +82,15 @@ const FT_DriverInterface* ft_default_drivers[] = {
FT_Error error;
const FT_DriverInterface* *cur;
cur = ft_default_drivers;
while ( *cur )
{
error = FT_Add_Driver( library, *cur );
/* notify errors, but don't stop */
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++;
}
}
@ -113,7 +109,7 @@ const FT_DriverInterface* ft_default_drivers[] = {
/* library :: A handle to a new library object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeTyoe error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_Init_FreeType( FT_Library* library )
@ -121,8 +117,10 @@ const FT_DriverInterface* ft_default_drivers[] = {
FT_Error error;
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();
if ( !memory )
{
@ -132,7 +130,8 @@ const FT_DriverInterface* ft_default_drivers[] = {
}
/* builds a library out of it, then fill it with the set of */
/* default drivers.. */
/* default drivers. */
error = FT_New_Library( memory, library );
if ( !error )
FT_Default_Drivers( *library );

View File

@ -4,7 +4,7 @@
/* */
/* Generic list support for FreeType (body). */
/* */
/* Copyright 1996-1999 by */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* 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 */
/* data structures are defined in freetype.h. */
/* data structures are defined in `freetype.h'. */
/* */
/*************************************************************************/
@ -70,7 +69,7 @@
/* FT_List_Add */
/* */
/* <Description> */
/* Appends an element at the end of a list. */
/* Appends an element to the end of a list. */
/* */
/* <InOut> */
/* list :: A pointer to the parent list. */
@ -222,7 +221,7 @@
/* argument to the iterator. */
/* */
/* <Return> */
/* The result of the last iterator call. */
/* The result (an error code) of the last iterator call. */
/* */
BASE_FUNC
FT_Error FT_List_Iterate( FT_List list,

View File

@ -4,7 +4,7 @@
/* */
/* Generic list support for FreeType (specification). */
/* */
/* Copyright 1996-1999 by */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* 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 */
/* data structures are defined in freetype.h. */
/* data structures are defined in `freetype.h'. */
/* */
/*************************************************************************/
@ -34,93 +33,22 @@
#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
FT_ListNode FT_List_Find( FT_List list,
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
void FT_List_Add( FT_List list,
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
void FT_List_Insert( FT_List list,
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
void FT_List_Remove( FT_List list,
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
void FT_List_Up( FT_List list,
FT_ListNode node );
@ -144,26 +72,6 @@
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
FT_Error FT_List_Iterate( FT_List list,
FT_List_Iterator iterator,
@ -177,40 +85,20 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
/* system :: The current system object. */
/* data :: The current object to destroy. */
/* 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,
void* data,
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
void FT_List_Finalize( FT_List list,
FT_List_Destructor destroy,

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (base). */
/* */
/* Copyright 1996-1999 by */
/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -20,6 +20,8 @@
#include <ftdebug.h>
#include <ftstream.h>
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -35,7 +37,7 @@
/*************************************************************************/
/* */
/* 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. */
/* */
#undef FT_COMPONENT
@ -77,7 +79,7 @@
if ( !*P )
{
FT_ERROR(( "FT.Alloc:" ));
FT_ERROR(( " out of memory ? (%ld requested)\n",
FT_ERROR(( " Out of memory? (%ld requested)\n",
size ));
return FT_Err_Out_Of_Memory;
@ -122,10 +124,10 @@
/* All callers of FT_Realloc _must_ provide the current block size */
/* as well as the new one. */
/* */
/* When the memory object's flag FT_SYSTEM_FLAG_NO_REALLOC is */
/* set, this function will try to emulate a realloc through uses */
/* of FT_Alloc and FT_Free. Otherwise, it will call the system- */
/* specific "realloc" implementation. */
/* If the memory object's flag FT_SYSTEM_FLAG_NO_REALLOC is set, this */
/* function will try to emulate a reallocation using FT_Alloc() and */
/* FT_Free(). Otherwise, it will call the system-specific `realloc' */
/* implementation. */
/* */
/* (Some embedded systems do not have a working realloc). */
/* */
@ -137,6 +139,7 @@
{
void* Q;
FT_Assert( P != 0 );
/* if the original pointer is NULL, call FT_Alloc() */
@ -151,14 +154,15 @@
}
Q = memory->realloc( memory, current, size, *P );
if ( !Q ) goto Fail;
if ( !Q )
goto Fail;
*P = Q;
return FT_Err_Ok;
Fail:
FT_ERROR(( "FT.Realloc:" ));
FT_ERROR(( " failed (current %ld, requested %ld)\n",
FT_ERROR(( " Failed (current %ld, requested %ld)\n",
current, size ));
return FT_Err_Out_Of_Memory;
}
@ -204,6 +208,8 @@
}
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -267,12 +273,9 @@
/* Destroys a given driver object. This also destroys all child */
/* faces. */
/* */
/* <Input> */
/* <InOut> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
/* <Note> */
/* The driver _must_ be LOCKED! */
/* */
@ -281,6 +284,7 @@
{
FT_Memory memory = driver->memory;
/* now, finalize all faces in the driver list */
FT_List_Finalize( &driver->faces_list,
(FT_List_Destructor)destroy_face,
@ -300,9 +304,21 @@
}
/*************************************************************************/
/* */
/* <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
FT_Glyph_Format* FT_Get_Glyph_Format( FT_Library library,
FT_Glyph_Tag format_tag )
@ -310,6 +326,7 @@
FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur ++ )
{
if ( cur->format_tag == format_tag )
@ -326,18 +343,19 @@
/* FT_Set_Raster */
/* */
/* <Description> */
/* This function is used to change the raster module used to convert */
/* from a given memory object. It is thus possible to use libraries */
/* with distinct memory allocators within the same program. */
/* This function changes the raster module used to convert from a */
/* given memory object. It is thus possible to use libraries with */
/* distinct memory allocators within the same program. */
/* */
/* <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> */
/* library :: A handle to a new library object. */
/* raster :: A handle to the raster object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_Set_Raster( FT_Library library,
@ -348,6 +366,7 @@
FT_Error error = FT_Err_Ok;
FT_Glyph_Format* format;
/* allocate the render pool if necessary */
if ( !library->raster_pool &&
ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
@ -396,19 +415,54 @@
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
void FT_Set_Debug_Hook( FT_Library library,
FT_UInt hook_index,
FT_DebugHook_Func debug_hook )
{
if ( hook_index < ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
{
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
FT_Error FT_Add_Glyph_Format( FT_Library library,
FT_Glyph_Format* format )
@ -419,6 +473,7 @@
FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur++ )
{
/* return an error if the format is already registered */
@ -443,7 +498,23 @@
}
/*************************************************************************/
/* */
/* <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
FT_Error FT_Remove_Glyph_Format( FT_Library library,
FT_Glyph_Tag format_tag )
@ -452,6 +523,7 @@
FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
memory = library->memory;
for ( ; cur < limit; cur++ )
@ -486,10 +558,10 @@
/* memory :: A handle to the original memory object. */
/* */
/* <Output> */
/* library :: A handle to a new library object. */
/* alibrary :: A pointer to handle of a new library object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_New_Library( FT_Memory memory,
@ -498,6 +570,7 @@
FT_Library library = 0;
FT_Error error;
/* First of all, allocate the library object */
if ( ALLOC( library, sizeof ( *library ) ) )
return error;
@ -514,6 +587,7 @@
0
};
error = FT_Add_Glyph_Format( library, &outline_format );
}
@ -537,7 +611,7 @@
/* library :: A handle to the target library */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_Done_Library( FT_Library library )
@ -560,6 +634,7 @@
{
FT_Driver driver = library->drivers[n];
if ( driver )
{
Destroy_Driver( driver );
@ -574,6 +649,7 @@
FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur++ )
{
if ( cur->raster_allocated )
@ -596,15 +672,18 @@
/* FT_Set_Raster_Mode */
/* */
/* <Description> */
/* Set a raster-specific mode. */
/* Sets a raster-specific mode. */
/* */
/* <InOut> */
/* library :: A handle to a target library object. */
/* */
/* <Input> */
/* library :: A handle to a target library object. */
/* format :: the glyph format used to select the raster */
/* mode :: the raster-specific mode descriptor */
/* args :: the mode arguments */
/* format :: The glyph format used to select the raster. */
/* mode :: The raster-specific mode descriptor. */
/* args :: The mode arguments. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_Set_Raster_Mode( FT_Library library,
@ -616,10 +695,12 @@
FT_Error error;
FT_Glyph_Format* format = 0;
{
FT_Glyph_Format* cur = library->glyph_formats;
FT_Glyph_Format* limit = cur + FT_MAX_GLYPH_FORMATS;
for ( ; cur < limit; cur++ )
{
if ( cur->format_tag == format_tag )
@ -637,7 +718,8 @@
error = FT_Err_Ok;
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;
}
@ -650,16 +732,17 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
/* <InOut> */
/* library :: A handle to the target library object. */
/* */
/* <Input> */
/* driver_interface :: A pointer to a driver interface table. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* This function doesn't check whether the driver is already */
@ -673,6 +756,7 @@
FT_Driver driver;
FT_Memory memory;
if ( !library || !driver_interface )
return FT_Err_Invalid_Library_Handle;
@ -693,7 +777,8 @@
if ( driver_interface->init_driver )
{
error = driver_interface->init_driver( driver );
if ( error ) goto Fail;
if ( error )
goto Fail;
}
library->drivers[library->num_drivers++] = driver;
@ -714,7 +799,7 @@
/* FT_Remove_Driver */
/* */
/* <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. */
/* */
/* This function also DESTROYS the driver object. */
@ -723,7 +808,7 @@
/* driver :: A handle to target driver object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
EXPORT_FUNC
FT_Error FT_Remove_Driver( FT_Driver driver )
@ -778,15 +863,15 @@
/* FT_Get_Driver */
/* */
/* <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'. */
/* */
/* <Input> */
/* library :: handle to library object. */
/* driver_name :: name of driver to look-up. */
/* library :: A handle to the library object. */
/* driver_name :: The name of the driver to look up. */
/* */
/* <Return> */
/* handle to driver object. 0 otherwise */
/* A handle to the driver object, 0 otherwise. */
/* */
EXPORT_FUNC
FT_Driver FT_Get_Driver( FT_Library library,
@ -794,6 +879,7 @@
{
FT_Driver *cur, *limit;
if ( !library || !driver_name )
return 0;
@ -808,7 +894,6 @@
}
static
FT_Error open_face( FT_Driver driver,
FT_Stream stream,
@ -868,7 +953,7 @@
/* face :: A handle to a new face object. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Unlike FreeType 1.1, this function automatically creates a glyph */
@ -895,6 +980,7 @@
FT_Memory memory;
FT_Error error;
memory = library->memory;
if ( ALLOC( stream, sizeof ( *stream ) ) )
goto Fail;
@ -917,6 +1003,7 @@
return error;
}
EXPORT_FUNC
FT_Error FT_New_Memory_Face( FT_Library library,
void* file_base,