From a3b6c6c2906c04b73a80674b3f75c3e21e7f21c6 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 31 May 2000 06:55:12 +0000 Subject: [PATCH] Formatting, fixing and adding documentation. --- src/base/ftinit.c | 24 +- src/base/ftlist.c | 43 ++- src/base/ftmm.c | 71 +++-- src/base/ftobjs.c | 670 ++++++++++++++++++++++++++-------------------- 4 files changed, 467 insertions(+), 341 deletions(-) diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 1ec542099..65a363aed 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -17,23 +17,19 @@ /*************************************************************************/ /* */ - /* The purpose of this file is to implement the three following */ + /* The purpose of this file is to implement the following two */ /* functions: */ /* */ - /* FT_Default_Drivers: */ + /* 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. */ + /* fresh new library object. The set is taken from the header file */ + /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */ + /* Build System' for more information. */ /* */ - /* FT_Init_FreeType: */ + /* 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'. */ @@ -76,7 +72,7 @@ const FT_DriverInterface* ft_default_drivers[] = /* */ /* library :: A handle to a new library object. */ /* */ - FT_EXPORT_FUNC(void) FT_Default_Drivers( FT_Library library ) + FT_EXPORT_FUNC( void ) FT_Default_Drivers( FT_Library library ) { FT_Error error; const FT_DriverInterface* *cur; @@ -89,7 +85,7 @@ const FT_DriverInterface* ft_default_drivers[] = /* 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++; @@ -112,13 +108,13 @@ const FT_DriverInterface* ft_default_drivers[] = /* */ /* FreeTyoe error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Init_FreeType( FT_Library* library ) + FT_EXPORT_FUNC( FT_Error ) FT_Init_FreeType( FT_Library* library ) { FT_Error error; FT_Memory memory; - /* First of all, allocate a new system object - -this function is part */ + /* 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(); diff --git a/src/base/ftlist.c b/src/base/ftlist.c index c4d0eb33e..d6dd9c2ed 100644 --- a/src/base/ftlist.c +++ b/src/base/ftlist.c @@ -18,7 +18,7 @@ /*************************************************************************/ /* */ /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ + /* data structures are defined in `freetype/internal/ftlist.h'. */ /* */ /*************************************************************************/ @@ -43,8 +43,8 @@ /* */ /* List node. NULL if it wasn't found. */ /* */ - BASE_FUNC(FT_ListNode) FT_List_Find( FT_List list, - void* data ) + BASE_FUNC( FT_ListNode ) FT_List_Find( FT_List list, + void* data ) { FT_ListNode cur; @@ -74,8 +74,8 @@ /* list :: A pointer to the parent list. */ /* node :: The node to append. */ /* */ - BASE_FUNC(void) FT_List_Add( FT_List list, - FT_ListNode node ) + BASE_FUNC( void ) FT_List_Add( FT_List list, + FT_ListNode node ) { FT_ListNode before = list->tail; @@ -104,8 +104,8 @@ /* list :: A pointer to parent list. */ /* node :: The node to insert. */ /* */ - BASE_FUNC(void) FT_List_Insert( FT_List list, - FT_ListNode node ) + BASE_FUNC( void ) FT_List_Insert( FT_List list, + FT_ListNode node ) { FT_ListNode after = list->head; @@ -137,8 +137,8 @@ /* */ /* list :: A pointer to the parent list. */ /* */ - BASE_FUNC(void) FT_List_Remove( FT_List list, - FT_ListNode node ) + BASE_FUNC( void ) FT_List_Remove( FT_List list, + FT_ListNode node ) { FT_ListNode before, after; @@ -171,8 +171,8 @@ /* list :: A pointer to the parent list. */ /* node :: The node to move. */ /* */ - BASE_FUNC(void) FT_List_Up( FT_List list, - FT_ListNode node ) + BASE_FUNC( void ) FT_List_Up( FT_List list, + FT_ListNode node ) { FT_ListNode before, after; @@ -180,7 +180,7 @@ before = node->prev; after = node->next; - /* check wether we're already on top of the list */ + /* check whether we are already on top of the list */ if ( !before ) return; @@ -216,11 +216,11 @@ /* argument to the iterator. */ /* */ /* */ - /* The result (an error code) of the last iterator call. */ + /* The result (a FreeType error code) of the last iterator call. */ /* */ - BASE_FUNC(FT_Error) FT_List_Iterate( FT_List list, - FT_List_Iterator iterator, - void* user ) + BASE_FUNC( FT_Error ) FT_List_Iterate( FT_List list, + FT_List_Iterator iterator, + void* user ) { FT_ListNode cur = list->head; FT_Error error = FT_Err_Ok; @@ -256,16 +256,15 @@ /* destroy :: A list destructor that will be applied to each element */ /* of the list. */ /* */ - /* memory :: The current memory object where destructions take */ - /* place. */ + /* memory :: The current memory object which handles deallocation. */ /* */ /* user :: A user-supplied field which is passed as the last */ /* argument to the destructor. */ /* */ - BASE_FUNC(void) FT_List_Finalize( FT_List list, - FT_List_Destructor destroy, - FT_Memory memory, - void* user ) + BASE_FUNC( void ) FT_List_Finalize( FT_List list, + FT_List_Destructor destroy, + FT_Memory memory, + void* user ) { FT_ListNode cur; diff --git a/src/base/ftmm.c b/src/base/ftmm.c index f9943bff1..42b13d40f 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -1,66 +1,97 @@ +/***************************************************************************/ +/* */ +/* ftmm.c */ +/* */ +/* Multiple Master font support (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used */ +/* modified and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + #include #include - FT_EXPORT_FUNC(FT_Error) FT_Get_Multi_Master( FT_Face face, - FT_Multi_Master* master ) + FT_EXPORT_FUNC( FT_Error ) FT_Get_Multi_Master( FT_Face face, + FT_Multi_Master* master ) { FT_Error error; + error = FT_Err_Invalid_Argument; - if (face && FT_HAS_MULTIPLE_MASTERS(face)) + + if ( face && FT_HAS_MULTIPLE_MASTERS( face ) ) { FT_Driver driver = face->driver; FT_Get_MM_Func func; - func = (FT_Get_MM_Func)driver->interface.get_interface( - driver, "get_mm" ); - if (func) - error = func(face,master); + + func = (FT_Get_MM_Func)driver->interface.get_interface( + driver, "get_mm" ); + if ( func ) + error = func( face, master ); } return error; } - FT_EXPORT_FUNC(FT_Error) FT_Set_MM_Design_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ) + FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Design_Coordinates( + FT_Face face, + FT_UInt num_coords, + FT_Long* coords ) { FT_Error error; + error = FT_Err_Invalid_Argument; - if (face && FT_HAS_MULTIPLE_MASTERS(face)) + + if ( face && FT_HAS_MULTIPLE_MASTERS( face ) ) { FT_Driver driver = face->driver; FT_Set_MM_Design_Func func; + func = (FT_Set_MM_Design_Func)driver->interface.get_interface( driver, "set_mm_design" ); - if (func) - error = func(face,num_coords,coords); + if ( func ) + error = func( face, num_coords, coords ); } return error; } - FT_EXPORT_FUNC(FT_Error) FT_Set_MM_Blend_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ) + + FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Blend_Coordinates( + FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) { FT_Error error; + error = FT_Err_Invalid_Argument; - if (face && FT_HAS_MULTIPLE_MASTERS(face)) + + if ( face && FT_HAS_MULTIPLE_MASTERS( face ) ) { - FT_Driver driver = face->driver; + FT_Driver driver = face->driver; FT_Set_MM_Blend_Func func; func = (FT_Set_MM_Blend_Func)driver->interface.get_interface( driver, "set_mm_blend" ); - if (func) - error = func(face,num_coords,coords); + if ( func ) + error = func( face, num_coords, coords ); } return error; } + +/* END */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index e51556275..cca71b807 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2,7 +2,7 @@ /* */ /* ftobjs.c */ /* */ -/* The FreeType private base classes (base). */ +/* The FreeType private base classes (base). */ /* */ /* Copyright 1996-2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ @@ -15,6 +15,7 @@ /* */ /***************************************************************************/ + #include #include #include @@ -22,6 +23,7 @@ #include + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -54,8 +56,8 @@ /* zero-filled; this is a strong convention in many FreeType parts. */ /* */ /* */ - /* memory :: A handle to a given `memory object' where allocation */ - /* occurs. */ + /* memory :: A handle to a given `memory object' which handles */ + /* allocation. */ /* */ /* size :: The size in bytes of the block to allocate. */ /* */ @@ -66,9 +68,9 @@ /* */ /* FreeType error code. 0 means success. */ /* */ - BASE_FUNC(FT_Error) FT_Alloc( FT_Memory memory, - FT_Long size, - void** P ) + BASE_FUNC( FT_Error ) FT_Alloc( FT_Memory memory, + FT_Long size, + void** P ) { FT_Assert( P != 0 ); @@ -77,7 +79,7 @@ *P = memory->alloc( memory, size ); if ( !*P ) { - FT_ERROR(( "FT.Alloc:" )); + FT_ERROR(( "FT_Alloc:" )); FT_ERROR(( " Out of memory? (%ld requested)\n", size )); @@ -106,10 +108,11 @@ /* from the heap, possibly changing `*P'. */ /* */ /* */ - /* memory :: A handle to a given `memory object' where allocation */ - /* occurs. */ + /* memory :: A handle to a given `memory object' which handles */ + /* reallocation. */ /* */ /* current :: The current block size in bytes. */ + /* */ /* size :: The new block size in bytes. */ /* */ /* */ @@ -130,10 +133,10 @@ /* */ /* (Some embedded systems do not have a working realloc function). */ /* */ - BASE_FUNC(FT_Error) FT_Realloc( FT_Memory memory, - FT_Long current, - FT_Long size, - void** P ) + BASE_FUNC( FT_Error ) FT_Realloc( FT_Memory memory, + FT_Long current, + FT_Long size, + void** P ) { void* Q; @@ -159,7 +162,7 @@ return FT_Err_Ok; Fail: - FT_ERROR(( "FT.Realloc:" )); + FT_ERROR(( "FT_Realloc:" )); FT_ERROR(( " Failed (current %ld, requested %ld)\n", current, size )); return FT_Err_Out_Of_Memory; @@ -175,8 +178,8 @@ /* Releases a given block of memory allocated through FT_Alloc(). */ /* */ /* */ - /* memory :: A handle to a given `memory object' where allocation */ - /* occurred. */ + /* memory :: A handle to a given `memory object' which handles */ + /* memory deallocation */ /* */ /* P :: This is the _address_ of a _pointer_ which points to the */ /* allocated block. It is always set to NULL on exit. */ @@ -189,12 +192,12 @@ /* This is a strong convention within all of FreeType and its */ /* drivers. */ /* */ - BASE_FUNC(void) FT_Free( FT_Memory memory, - void** P ) + BASE_FUNC( void ) FT_Free( FT_Memory memory, + void** P ) { FT_TRACE2(( "FT_Free:" )); FT_TRACE2(( " Freeing block 0x%08p, ref 0x%08p\n", - P, (P ? *P : (void*)0) )); + P, P ? *P : (void*)0 )); FT_Assert( P != 0 ); @@ -217,12 +220,13 @@ static FT_Error ft_new_input_stream( FT_Library library, FT_Open_Args* args, - FT_Stream *astream ) + FT_Stream* astream ) { FT_Error error; FT_Memory memory; FT_Stream stream; + *astream = 0; memory = library->memory; if ( ALLOC( stream, sizeof ( *stream ) ) ) @@ -239,25 +243,24 @@ args->memory_size, stream ); } - else if (args->flags & ft_open_pathname) + else if ( args->flags & ft_open_pathname ) { error = FT_New_Stream( args->pathname, stream ); stream->pathname.pointer = args->pathname; } - else if (args->flags & ft_open_stream && args->stream) + else if ( args->flags & ft_open_stream && args->stream ) { *stream = *(args->stream); stream->memory = memory; } else - { error = FT_Err_Invalid_Argument; - } if ( error ) FREE( stream ); *astream = stream; + Exit: return error; } @@ -271,7 +274,10 @@ /* */ /* Closes and destroys a stream object. */ /* */ - FT_EXPORT_FUNC(void) FT_Done_Stream( FT_Stream stream ) + /* */ + /* stream :: The stream to be closed and destroyed. */ + /* */ + FT_EXPORT_FUNC( void ) FT_Done_Stream( FT_Stream stream ) { if ( stream->close ) stream->close( stream ); @@ -284,6 +290,7 @@ FT_Stream stream = *astream; FT_Memory memory = stream->memory; + if ( stream->close ) stream->close( stream ); @@ -291,6 +298,7 @@ *astream = 0; } + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -388,39 +396,43 @@ } - /************************************************************************* - * - * - * FT_Get_Raster - * - * - * Return a pointer to the raster corresponding to a given glyph - * format tag. - * - * - * library :: handle to source library object - * glyph_format :: glyph format tag - * - * - * raster_funcs :: if this field is not 0, returns the raster's interface - * - * - * a pointer to the corresponding raster object. - * - *************************************************************************/ - - FT_EXPORT_FUNC(FT_Raster) FT_Get_Raster( FT_Library library, - FT_Glyph_Format glyph_format, - FT_Raster_Funcs *raster_funcs ) + /*************************************************************************/ + /* */ + /* */ + /* FT_Get_Raster */ + /* */ + /* */ + /* Returns the raster interface corresponding to a given glyph format */ + /* tag. */ + /* */ + /* */ + /* library :: A handle to the source library object. */ + /* */ + /* glyph_format :: The glyph format tag. */ + /* */ + /* */ + /* raster_funcs :: If this field is not 0, the raster's interface */ + /* functions are returned. */ + /* */ + /* */ + /* A pointer to the corresponding raster object. */ + /* */ + FT_EXPORT_FUNC( FT_Raster ) FT_Get_Raster( + FT_Library library, + FT_Glyph_Format glyph_format, + FT_Raster_Funcs* raster_funcs ) { FT_Int n; + for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ ) { FT_Raster_Funcs* funcs = &library->raster_funcs[n]; - if (funcs->glyph_format == glyph_format) + + + if ( funcs->glyph_format == glyph_format ) { - if (raster_funcs) + if ( raster_funcs ) *raster_funcs = *funcs; return library->rasters[n]; } @@ -428,34 +440,36 @@ return 0; } + /*************************************************************************/ /* */ /* */ /* FT_Set_Raster */ /* */ /* */ - /* Register a given raster to the library. */ + /* Registers a given raster to the library. */ /* */ /* */ /* library :: A handle to a target library object. */ - /* raster_funcs :: pointer to the raster's interface */ + /* */ + /* raster_funcs :: A pointer to the raster's interface functions. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* This function will do the following: */ /* */ - /* - a new raster object is created through raster_func.raster_new */ - /* if this fails, then the function returns */ + /* - A new raster object is created through `raster_func.raster_new'. */ + /* If this fails, the function returns. */ /* */ - /* - if a raster is already registered for the glyph format */ - /* specified in raster_funcs, it will be destroyed */ + /* - If a raster is already registered for the glyph format */ + /* specified in raster_funcs, it will be destroyed. */ /* */ - /* - the new raster is registered for the glyph format */ + /* - The new raster is registered for the glyph format. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Set_Raster( FT_Library library, - FT_Raster_Funcs* raster_funcs ) + FT_EXPORT_FUNC( FT_Error ) FT_Set_Raster( FT_Library library, + FT_Raster_Funcs* raster_funcs ) { FT_Glyph_Format glyph_format = raster_funcs->glyph_format; FT_Raster_Funcs* funcs; @@ -463,38 +477,41 @@ FT_Error error; FT_Int n, index; - if ( glyph_format == ft_glyph_format_none) + + if ( glyph_format == ft_glyph_format_none ) return FT_Err_Invalid_Argument; /* create a new raster object */ error = raster_funcs->raster_new( library->memory, &raster ); - if (error) goto Exit; + if ( error ) + goto Exit; raster_funcs->raster_reset( raster, library->raster_pool, library->raster_pool_size ); index = -1; - for (n = 0; n < FT_MAX_GLYPH_FORMATS; n++) + for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ ) { FT_Raster_Funcs* funcs = library->raster_funcs + n; - /* record the first vacant entry in "index" */ - if (index < 0 && funcs->glyph_format == ft_glyph_format_none) + + /* record the first vacant entry in `index' */ + if ( index < 0 && funcs->glyph_format == ft_glyph_format_none ) index = n; /* compare this entry's glyph format with the one we need */ - if (funcs->glyph_format == glyph_format) + if ( funcs->glyph_format == glyph_format ) { - /* a raster already exists for this glyph format, we will */ - /* destroy it before updating its entry in the table */ + /* A raster already exists for this glyph format. We will */ + /* destroy it before updating its entry in the table. */ funcs->raster_done( library->rasters[n] ); index = n; break; } } - if (index < 0) + if ( index < 0 ) { /* the table is full and has no vacant entries */ error = FT_Err_Too_Many_Glyph_Formats; @@ -513,6 +530,7 @@ goto Exit; } + /*************************************************************************/ /* */ /* */ @@ -523,27 +541,32 @@ /* */ /* */ /* library :: A handle to a target library object. */ - /* raster_funcs :: pointer to the raster's interface */ + /* */ + /* raster_funcs :: A pointer to the raster's interface functions. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_DEF(FT_Error) FT_Unset_Raster( FT_Library library, - FT_Raster_Funcs* raster_funcs ) + FT_EXPORT_DEF( FT_Error ) FT_Unset_Raster( + FT_Library library, + FT_Raster_Funcs* raster_funcs ) { FT_Glyph_Format glyph_format = raster_funcs->glyph_format; FT_Error error; FT_Int n; + error = FT_Err_Invalid_Argument; - if ( glyph_format == ft_glyph_format_none) + + if ( glyph_format == ft_glyph_format_none ) goto Exit; - for (n = 0; n < FT_MAX_GLYPH_FORMATS; n++) + for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ ) { FT_Raster_Funcs* funcs = library->raster_funcs + n; - if (funcs->glyph_format == glyph_format) + + if ( funcs->glyph_format == glyph_format ) { funcs->raster_done( library->rasters[n] ); library->rasters[n] = 0; @@ -564,31 +587,38 @@ /* FT_Set_Raster_Mode */ /* */ /* */ - /* Set a raster-specific mode. */ + /* Sets a raster-specific mode. */ + /* */ + /* */ + /* library :: A handle to a target library object. */ /* */ /* */ - /* 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 */ - /* */ - /* Error code. 0 means success. */ + /* format :: The glyph format used to select the raster. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Set_Raster_Mode( FT_Library library, - FT_Glyph_Format format, - unsigned long mode, - void* args ) + /* mode :: The raster-specific mode descriptor. */ + /* */ + /* args :: The mode arguments. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_EXPORT_FUNC( FT_Error ) FT_Set_Raster_Mode( FT_Library library, + FT_Glyph_Format format, + unsigned long mode, + void* args ) { FT_Raster_Funcs funcs; FT_Raster raster; + raster = FT_Get_Raster( library, format, &funcs ); - if (raster && funcs.raster_set_mode ) + if ( raster && funcs.raster_set_mode ) return funcs.raster_set_mode( raster, mode, args ); else return FT_Err_Invalid_Argument; } + /*************************************************************************/ /* */ /* */ @@ -600,20 +630,23 @@ /* */ /* */ /* 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. */ /* */ /* */ /* Currently, four debug hook slots are available, but only two (for */ /* the TrueType and the Type 1 interpreter) are defined. */ /* */ - FT_EXPORT_FUNC(void) FT_Set_Debug_Hook( FT_Library library, - FT_UInt hook_index, - FT_DebugHook_Func debug_hook ) + FT_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* ) ) ) + if ( hook_index < + ( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) ) library->debug_hooks[hook_index] = debug_hook; } @@ -637,12 +670,13 @@ /* */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_New_Library( FT_Memory memory, - FT_Library* alibrary ) + FT_EXPORT_FUNC( FT_Error ) FT_New_Library( FT_Memory memory, + FT_Library* alibrary ) { FT_Library library = 0; FT_Error error; + /* first of all, allocate the library object */ if ( ALLOC( library, sizeof ( *library ) ) ) return error; @@ -654,15 +688,15 @@ if ( ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) ) goto Fail; - /* now register the default raster for the `outline' glyph image format */ - /* for now, ignore the error... */ + /* now register the default raster for the `outline' glyph image */ + /* format for now, ignore the error... */ error = FT_Set_Raster( library, &ft_default_raster ); - /* That's ok now */ *alibrary = library; return FT_Err_Ok; + Fail: FREE( library ); return error; @@ -679,12 +713,12 @@ /* discards all resource objects. */ /* */ /* */ - /* library :: A handle to the target library */ + /* library :: A handle to the target library. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Done_Library( FT_Library library ) + FT_EXPORT_FUNC( FT_Error ) FT_Done_Library( FT_Library library ) { FT_Memory memory; FT_Int n; @@ -717,8 +751,8 @@ library->raster_pool_size = 0; { - FT_Raster_Funcs* cur = library->raster_funcs; - FT_Raster_Funcs* limit = cur + FT_MAX_GLYPH_FORMATS; + FT_Raster_Funcs* cur = library->raster_funcs; + FT_Raster_Funcs* limit = cur + FT_MAX_GLYPH_FORMATS; FT_Raster* raster = library->rasters; for ( ; cur < limit; cur++, raster++ ) @@ -761,8 +795,9 @@ /* This function doesn't check whether the driver is already */ /* installed! */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Add_Driver( FT_Library library, - const FT_DriverInterface* driver_interface ) + FT_EXPORT_FUNC( FT_Error ) FT_Add_Driver( + FT_Library library, + const FT_DriverInterface* driver_interface ) { FT_Error error; FT_Driver driver; @@ -822,7 +857,7 @@ /* */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Remove_Driver( FT_Driver driver ) + FT_EXPORT_FUNC( FT_Error ) FT_Remove_Driver( FT_Driver driver ) { FT_Library library; FT_Memory memory; @@ -885,8 +920,8 @@ /* */ /* A handle to the driver object, 0 otherwise. */ /* */ - FT_EXPORT_FUNC(FT_Driver) FT_Get_Driver( FT_Library library, - char* driver_name ) + FT_EXPORT_FUNC( FT_Driver ) FT_Get_Driver( FT_Library library, + char* driver_name ) { FT_Driver *cur, *limit; @@ -938,7 +973,11 @@ face->memory = memory; face->stream = stream; - error = interface->init_face( stream, face, face_index, num_params, params ); + error = interface->init_face( stream, + face, + face_index, + num_params, + params ); if ( error ) goto Fail; @@ -956,7 +995,6 @@ } - /*************************************************************************/ /* */ /* */ @@ -971,10 +1009,11 @@ /* */ /* */ /* pathname :: A path to the font file. */ + /* */ /* face_index :: The index of the face within the resource. The */ /* first face has index 0. */ /* */ - /* face :: A handle to a new face object. */ + /* aface :: A handle to a new face object. */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -994,15 +1033,17 @@ /* `*face'. Its return value should be 0 if the resource is */ /* recognized, or non-zero if not. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_New_Face( FT_Library library, - const char* pathname, - FT_Long face_index, - FT_Face* aface ) + FT_EXPORT_FUNC( FT_Error ) FT_New_Face( FT_Library library, + const char* pathname, + FT_Long face_index, + FT_Face* aface ) { FT_Open_Args args; + args.flags = ft_open_pathname; args.pathname = (char*)pathname; + return FT_Open_Face( library, &args, face_index, aface ); } @@ -1021,7 +1062,9 @@ /* */ /* */ /* file_base :: A pointer to the beginning of the font data. */ + /* */ /* file_size :: The size of the memory chunk used by the font data. */ + /* */ /* face_index :: The index of the face within the resource. The */ /* first face has index 0. */ /* */ @@ -1045,17 +1088,19 @@ /* `*face'. Its return value should be 0 if the resource is */ /* recognized, or non-zero if not. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_New_Memory_Face( FT_Library library, - void* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face* face ) + FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library, + void* file_base, + FT_Long file_size, + FT_Long face_index, + FT_Face* face ) { FT_Open_Args args; + args.flags = ft_open_memory; args.memory_base = file_base; args.memory_size = file_size; + return FT_Open_Face( library, &args, face_index, face ); } @@ -1076,10 +1121,11 @@ /* */ /* args :: A pointer to an `FT_Open_Args' structure which must */ /* be filled by the caller. */ + /* */ /* face_index :: The index of the face within the resource. The */ /* first face has index 0. */ /* */ - /* face :: A handle to a new face object. */ + /* aface :: A handle to a new face object. */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -1099,10 +1145,10 @@ /* `*face'. Its return value should be 0 if the resource is */ /* recognized, or non-zero if not. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Open_Face( FT_Library library, - FT_Open_Args* args, - FT_Long face_index, - FT_Face* aface ) + FT_EXPORT_FUNC( FT_Error ) FT_Open_Face( FT_Library library, + FT_Open_Args* args, + FT_Long face_index, + FT_Face* aface ) { FT_Error error; FT_Driver driver; @@ -1119,11 +1165,12 @@ /* create input stream */ error = ft_new_input_stream( library, args, &stream ); - if ( error ) goto Exit; + if ( error ) + goto Exit; memory = library->memory; - /* if the font driver is specified in the `args' structure, use */ + /* If the font driver is specified in the `args' structure, use */ /* it. Otherwise, we'll scan the list of registered drivers. */ if ( args->flags & ft_open_driver && args->driver ) { @@ -1134,6 +1181,7 @@ FT_Int num_params = 0; FT_Parameter* params = 0; + if ( args->flags & ft_open_params ) { num_params = args->num_params; @@ -1165,6 +1213,7 @@ FT_Int num_params = 0; FT_Parameter* params = 0; + if ( args->flags & ft_open_params ) { num_params = args->num_params; @@ -1194,8 +1243,8 @@ goto Fail; node->data = face; - /* don't assume driver is the same as face->driver, so use - face->driver instead. (JvR 3/5/2000) */ + /* don't assume driver is the same as face->driver, so use */ + /* face->driver instead. */ FT_List_Add( &face->driver->faces_list, node ); /* now allocate a glyph slot object for the face */ @@ -1209,7 +1258,7 @@ goto Fail; } - /* finally allocate a size object for the face */ + /* finally, allocate a size object for the face */ { FT_Size size; @@ -1220,7 +1269,7 @@ goto Fail; } - /* initialize transform for convenience functions */ + /* initialize transformation for convenience functions */ face->transform_matrix.xx = 0x10000L; face->transform_matrix.xy = 0; face->transform_matrix.yx = 0; @@ -1270,16 +1319,18 @@ /* depends on the font format (and thus the font driver). */ /* */ /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ + /* when invoking this function. Most drivers simply do not implement */ /* file attachments. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Attach_File( FT_Face face, - const char* filepathname ) + FT_EXPORT_FUNC( FT_Error ) FT_Attach_File( FT_Face face, + const char* filepathname ) { FT_Open_Args open; + open.flags = ft_open_pathname; open.pathname = (char*)filepathname; + return FT_Attach_Stream( face, &open ); } @@ -1290,27 +1341,28 @@ /* FT_Attach_Stream */ /* */ /* */ - /* This function is similar to FT_Attach_File with the exception */ + /* This function is similar to FT_Attach_File() with the exception */ /* that it reads the attachment from an arbitrary stream. */ /* */ /* */ - /* face :: target face object */ + /* face :: The target face object. */ /* */ - /* args :: a pointer to an FT_Open_Args structure used to describe */ - /* the input stream to FreeType */ + /* parameters :: A pointer to an FT_Open_Args structure used to */ + /* describe the input stream to FreeType. */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - /* The meaning of the "attach" (i.e. what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ + /* */ + /* The meaning of the `attach' (i.e. what really happens when the */ + /* new file is read) is not fixed by FreeType itself. It really */ /* depends on the font format (and thus the font driver). */ /* */ - /* Client applications are expected to know what they're doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments.. */ + /* Client applications are expected to know what they are doing */ + /* when invoking this function. Most drivers simply do not implement */ + /* file attachments. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ) + FT_EXPORT_FUNC( FT_Error ) FT_Attach_Stream( FT_Face face, + FT_Open_Args* parameters ) { FT_Stream stream; FT_Error error; @@ -1318,24 +1370,28 @@ FTDriver_getInterface get_interface; + if ( !face || !face->driver ) return FT_Err_Invalid_Handle; driver = face->driver; - error = ft_new_input_stream( driver->library, parameters, &stream ); - if (error) goto Exit; + error = ft_new_input_stream( driver->library, parameters, &stream ); + if ( error ) + goto Exit; /* we implement FT_Attach_Stream in each driver through the */ - /* "attach_file" interface.. */ + /* `attach_file' interface */ + error = FT_Err_Unimplemented_Feature; get_interface = driver->interface.get_interface; - if (get_interface) + if ( get_interface ) { FT_Attach_Reader reader; + reader = (FT_Attach_Reader)(get_interface( driver, "attach_file" )); - if (reader) + if ( reader ) error = reader( face, stream ); } @@ -1347,7 +1403,6 @@ } - /*************************************************************************/ /* */ /* */ @@ -1361,9 +1416,9 @@ /* face :: A handle to a target face object. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Done_Face( FT_Face face ) + FT_EXPORT_FUNC( FT_Error ) FT_Done_Face( FT_Face face ) { FT_Error error; FT_Driver driver; @@ -1372,7 +1427,7 @@ FT_ListNode node; - if (!face || !face->driver ) + if ( !face || !face->driver ) return FT_Err_Invalid_Face_Handle; driver = face->driver; @@ -1410,13 +1465,13 @@ /* face :: A handle to a parent face object. */ /* */ /* */ - /* size :: A handle to a new size object. */ + /* asize :: A handle to a new size object. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_New_Size( FT_Face face, - FT_Size* asize ) + FT_EXPORT_FUNC( FT_Error ) FT_New_Size( FT_Face face, + FT_Size* asize ) { FT_Error error; FT_Memory memory; @@ -1475,12 +1530,12 @@ /* Discards a given size object. */ /* */ /* */ - /* size :: A handle to a target size object */ + /* size :: A handle to a target size object. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Done_Size( FT_Size size ) + FT_EXPORT_FUNC( FT_Error ) FT_Done_Size( FT_Size size ) { FT_Error error; FT_Driver driver; @@ -1506,10 +1561,10 @@ FT_List_Remove( &face->sizes_list, node ); FREE( node ); - if (face->size == size) + if ( face->size == size ) { face->size = 0; - if (face->sizes_list.head) + if ( face->sizes_list.head ) face->size = (FT_Size)(face->sizes_list.head->data); } @@ -1528,26 +1583,39 @@ /* FT_Set_Char_Size */ /* */ /* */ - /* Sets the character dimensions of a given size object. The */ - /* `char_size' value is used for the width and height, expressed in */ - /* 26.6 fractional points. 1 point = 1/72 inch. */ + /* Sets the character dimensions of a given face object. The */ + /* `char_width' and `char_height' values are used for the width and */ + /* height, respectively, expressed in 26.6 fractional points. */ + /* */ + /* If the horizontal or vertical resolution values are zero, a */ + /* default value of 72dpi is used. Similarly, if one of the */ + /* character dimensions is zero, its value is set equal to the other. */ + /* */ + /* */ + /* size :: A handle to a target size object. */ /* */ /* */ - /* size :: A handle to a target size object. */ - /* char_size :: The character size, in 26.6 fractional points. */ + /* char_width :: The character width, in 26.6 fractional points. */ + /* */ + /* char_height :: The character height, in 26.6 fractional */ + /* points. */ + /* */ + /* horz_resolution :: The horizontal resolution. */ + /* */ + /* vert_resolution :: The vertical resolution. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* When dealing with fixed-size faces (i.e., non-scalable formats), */ /* use the function FT_Set_Pixel_Sizes(). */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Set_Char_Size( FT_Face face, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) + FT_EXPORT_FUNC( FT_Error ) FT_Set_Char_Size( FT_Face face, + FT_F26Dot6 char_width, + FT_F26Dot6 char_height, + FT_UInt horz_resolution, + FT_UInt vert_resolution ) { FT_Error error; FT_Driver driver; @@ -1556,39 +1624,39 @@ FT_Size_Metrics* metrics = &face->size->metrics; FT_Long dim_x, dim_y; - if ( !face || !face->size || !face->driver) + + if ( !face || !face->size || !face->driver ) return FT_Err_Invalid_Face_Handle; - if (!char_width) + if ( !char_width ) char_width = char_height; - - else if (!char_height) + else if ( !char_height ) char_height = char_width; - if (!horz_resolution) + if ( !horz_resolution ) horz_resolution = 72; - - if (!vert_resolution) + if ( !vert_resolution ) vert_resolution = 72; driver = face->driver; interface = &driver->interface; memory = driver->memory; - /* default processing - this can be overriden by the driver */ - if ( char_width < 1*64 ) char_width = 1*64; - if ( char_height < 1*64 ) char_height = 1*64; + /* default processing -- this can be overridden by the driver */ + if ( char_width < 1 * 64 ) char_width = 1 * 64; + if ( char_height < 1 * 64 ) char_height = 1 * 64; /* Compute pixel sizes in 26.6 units */ - dim_x = (((char_width * horz_resolution) / 72) + 32) & -64; - dim_y = (((char_height * vert_resolution) / 72) + 32) & -64; + dim_x = ( ( ( char_width * horz_resolution ) / 72 ) + 32 ) & -64; + dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64; - metrics->x_ppem = (FT_UShort)(dim_x >> 6); - metrics->y_ppem = (FT_UShort)(dim_y >> 6); + metrics->x_ppem = (FT_UShort)(dim_x >> 6); + metrics->y_ppem = (FT_UShort)(dim_y >> 6); - metrics->x_scale = 0x10000; - metrics->y_scale = 0x10000; - if ( face->face_flags & FT_FACE_FLAG_SCALABLE) + metrics->x_scale = 0x10000L; + metrics->y_scale = 0x10000L; + + if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) { metrics->x_scale = FT_DivFix( dim_x, face->units_per_EM ); metrics->y_scale = FT_DivFix( dim_y, face->units_per_EM ); @@ -1609,20 +1677,26 @@ /* FT_Set_Pixel_Sizes */ /* */ /* */ - /* Sets the character dimensions of a given size object. The width */ + /* Sets the character dimensions of a given face object. The width */ /* and height are expressed in integer pixels. */ /* */ + /* If one of the character dimensions is zero, its value is set equal */ + /* to the other. */ + /* */ + /* */ + /* face :: A handle to the target face object. */ + /* */ /* */ - /* size :: A handle to a target size object. */ /* pixel_width :: The character width, in integer pixels. */ + /* */ /* pixel_height :: The character height, in integer pixels. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Set_Pixel_Sizes( FT_Face face, - FT_UInt pixel_width, - FT_UInt pixel_height ) + FT_EXPORT_FUNC( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, + FT_UInt pixel_width, + FT_UInt pixel_height ) { FT_Error error; FT_Driver driver; @@ -1630,6 +1704,7 @@ FT_DriverInterface* interface; FT_Size_Metrics* metrics = &face->size->metrics; + if ( !face || !face->size || !face->driver ) return FT_Err_Invalid_Face_Handle; @@ -1637,11 +1712,10 @@ interface = &driver->interface; memory = driver->memory; - /* default processing - this can be overriden by the driver */ - if (pixel_width == 0) + /* default processing -- this can be overridden by the driver */ + if ( pixel_width == 0 ) pixel_width = pixel_height; - - else if (pixel_height == 0) + else if ( pixel_height == 0 ) pixel_height = pixel_width; if ( pixel_width < 1 ) pixel_width = 1; @@ -1684,10 +1758,10 @@ /* aslot :: A handle to a new glyph slot object. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_New_GlyphSlot( FT_Face face, - FT_GlyphSlot* aslot ) + FT_EXPORT_FUNC( FT_Error ) FT_New_GlyphSlot( FT_Face face, + FT_GlyphSlot* aslot ) { FT_Error error; FT_Driver driver; @@ -1746,9 +1820,9 @@ /* */ /* slot :: A handle to a target glyph slot. */ /* */ - FT_EXPORT_FUNC(void) FT_Done_GlyphSlot( FT_GlyphSlot slot ) + FT_EXPORT_FUNC( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot ) { - if (slot) + if ( slot ) { FT_Driver driver = slot->face->driver; FT_Memory memory = driver->memory; @@ -1781,16 +1855,12 @@ /* FT_Load_Glyph */ /* */ /* */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ + /* A function used to load a single glyph within a given face. */ /* */ /* */ - /* slot :: A handle to a target slot object where the glyph */ + /* face :: A handle to a target face object where the glyph */ /* will be loaded. */ /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled/loaded. */ - /* */ /* glyph_index :: The index of the glyph in the font file. */ /* */ /* load_flags :: A flag indicating what to load for this glyph. The */ @@ -1798,24 +1868,18 @@ /* glyph loading process (e.g., whether the outline */ /* should be scaled, whether to load bitmaps or not, */ /* whether to hint the outline, etc). */ - /* */ - /* result :: A set of bit flags indicating the type of data that */ - /* was loaded in the glyph slot (outline or bitmap, */ - /* etc). */ - /* */ - /* You can set this field to 0 if you don't want this */ - /* information. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int load_flags ) + FT_EXPORT_FUNC( FT_Error ) FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int load_flags ) { FT_Error error; FT_Driver driver; + if ( !face || !face->size || !face->glyph ) return FT_Err_Invalid_Face_Handle; @@ -1825,7 +1889,7 @@ driver = face->driver; /* when the flag NO_RECURSE is set, we disable hinting and scaling */ - if (load_flags & FT_LOAD_NO_RECURSE) + if ( load_flags & FT_LOAD_NO_RECURSE ) load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; error = driver->interface.load_glyph( face->glyph, @@ -1837,21 +1901,47 @@ } - FT_EXPORT_FUNC(FT_Error) FT_Load_Char( FT_Face face, - FT_ULong char_code, - FT_Int load_flags ) + /*************************************************************************/ + /* */ + /* */ + /* FT_Load_Char */ + /* */ + /* */ + /* A function used to load a single character within a given face */ + /* and the selected charmap (to be done with the FT_Select_Charmap() */ + /* function). */ + /* */ + /* */ + /* face :: A handle to a target face object where the */ + /* character will be loaded. */ + /* */ + /* char_code :: The character code of the glyph in the font file. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* FT_LOAD_XXX constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_EXPORT_FUNC( FT_Error ) FT_Load_Char( FT_Face face, + FT_ULong char_code, + FT_Int load_flags ) { FT_Error error; FT_Driver driver; 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; driver = face->driver; glyph_index = FT_Get_Char_Index( face, char_code ); - if (glyph_index == 0) + if ( glyph_index == 0 ) error = FT_Err_Invalid_Character_Code; else error = driver->interface.load_glyph( face->glyph, @@ -1861,6 +1951,7 @@ return error; } + /*************************************************************************/ /* */ /* */ @@ -1890,10 +1981,10 @@ /* kernings, are out of the scope of this API function -- they can be */ /* implemented through format-specific interfaces. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Get_Kerning( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_Vector* kerning ) + FT_EXPORT_FUNC( FT_Error ) FT_Get_Kerning( FT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_Vector* kerning ) { FT_Error error; FT_Driver driver; @@ -1911,8 +2002,10 @@ if ( driver->interface.get_kerning ) { - error = driver->interface.get_kerning( face, left_glyph, - right_glyph, kerning ); + error = driver->interface.get_kerning( face, + left_glyph, + right_glyph, + kerning ); } else { @@ -1925,31 +2018,35 @@ return error; } + /*************************************************************************/ /* */ /* */ /* FT_Select_Charmap */ /* */ /* */ - /* Selects a given charmap by its encoding tag. */ + /* Selects a given charmap by its encoding tag (as listed in */ + /* `freetype.h'). */ /* */ /* */ /* face :: A handle to the source face object. */ - /* encoding :: handle to the selected charmap */ + /* */ + /* encoding :: A handle to the selected charmap. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* This function will return an error if no charmap in the face */ - /* corresponds to the encoding queried here */ + /* corresponds to the encoding queried here. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ) + FT_EXPORT_FUNC( FT_Error ) FT_Select_Charmap( FT_Face face, + FT_Encoding encoding ) { FT_CharMap* cur = face->charmaps; FT_CharMap* limit = cur + face->num_charmaps; + for ( ; cur < limit; cur++ ) { if ( cur[0]->encoding == encoding ) @@ -1973,22 +2070,23 @@ /* */ /* */ /* face :: A handle to the source face object. */ - /* charmap :: handle to the selected charmap */ + /* charmap :: A handle to the selected charmap. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ - /* this function will return an error when the charmap is not part */ - /* of the face (i.e. if it is not listed in the face->charmaps[] */ + /* This function will return an error when the charmap is not part */ + /* of the face (i.e., if it is not listed in the face->charmaps[] */ /* table). */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ) + FT_EXPORT_FUNC( FT_Error ) FT_Set_Charmap( FT_Face face, + FT_CharMap charmap ) { FT_CharMap* cur = face->charmaps; FT_CharMap* limit = cur + face->num_charmaps; + for ( ; cur < limit; cur++ ) { if ( cur[0] == charmap ) @@ -2000,6 +2098,7 @@ return FT_Err_Invalid_Argument; } + /*************************************************************************/ /* */ /* */ @@ -2010,18 +2109,19 @@ /* uses a charmap object to do the translation. */ /* */ /* */ - /* charmap :: A handle to a filter charmap object. */ + /* face :: A handle to the source face object. */ /* charcode :: The character code. */ /* */ /* */ /* The glyph index. 0 means `undefined character code'. */ /* */ - FT_EXPORT_FUNC(FT_UInt) FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ) + FT_EXPORT_FUNC( FT_UInt ) FT_Get_Char_Index( FT_Face face, + FT_ULong charcode ) { FT_UInt result; FT_Driver driver; + result = 0; if ( face && face->charmap ) { @@ -2032,55 +2132,54 @@ } - /*************************************************************************** - * - * - * FT_Get_Sfnt_Table - * - * - * Returns a pointer to a given SFNT table within a face. - * - * - * face :: handle to source - * tag :: index if SFNT table - * - * - * type-less pointer to the table. This will be 0 in case of error, or - * when the corresponding table was not found *OR* loaded from the file. - * - * - * The table is owned by the face object, and disappears with it. - * - * This function is only useful to access Sfnt tables that are loaded - * by the sfnt/truetype/opentype drivers. See FT_Sfnt_tag for a list. - * - * You can load any table with a different function.. XXX - * - ***************************************************************************/ - - - FT_EXPORT_FUNC(void*) FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ) + /*************************************************************************/ + /* */ + /* */ + /* FT_Get_Sfnt_Table */ + /* */ + /* */ + /* Returns a pointer to a given SFNT table within a face. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* tag :: An index of an SFNT table. */ + /* */ + /* */ + /* A type-less pointer to the table. This will be 0 in case of */ + /* error, or if the corresponding table was not found *OR* loaded */ + /* from the file. */ + /* */ + /* */ + /* The table is owned by the face object, and disappears with it. */ + /* */ + /* This function is only useful to access SFNT tables that are loaded */ + /* by the sfnt/truetype/opentype drivers. See the FT_Sfnt_Tag */ + /* enumeration in `tttables.h' for a list. */ + /* */ + /* You can load any table with a different function.. XXX */ + /* */ + FT_EXPORT_FUNC( void* ) FT_Get_Sfnt_Table( FT_Face face, + FT_Sfnt_Tag tag ) { void* table = 0; FT_Get_Sfnt_Table_Func func; FT_Driver driver; - if (!face || !FT_IS_SFNT(face)) + + if ( !face || !FT_IS_SFNT( face ) ) goto Exit; driver = face->driver; func = (FT_Get_Sfnt_Table_Func)driver->interface.get_interface( - driver, "get_sfnt" ); - if (func) - table = func(face,tag); + driver, "get_sfnt" ); + if ( func ) + table = func( face, tag ); Exit: return table; } - /*************************************************************************/ /* */ /* */ @@ -2094,9 +2193,9 @@ /* library :: A handle to the target library object. */ /* */ /* */ - /* Error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ - FT_EXPORT_FUNC(FT_Error) FT_Done_FreeType( FT_Library library ) + FT_EXPORT_FUNC( FT_Error ) FT_Done_FreeType( FT_Library library ) { /* Discard the library object */ FT_Done_Library( library ); @@ -2104,4 +2203,5 @@ return FT_Err_Ok; } + /* END */