the debug sub-system initialization. trace levels can now be specified within the "FT2_DEBUG" environment variable. See the comments within "ftdebug.c" for more details * include/freetype/internal/fttrace.h: new file to define the trace levels used for debugging. it is used both to define enums and toggle names for FT2_DEBUG * src/base/ftobjs.c, src/base/ftstream.c: FT_Assert renamed to FT_ASSERT * include/freetype/internal/ftextend.h, src/base/ftextend.c, src/base/Jamfile, src/base/rules.mk: removing "ftextend" from the library, since it is now completely obsolete..BRANCH-2-1-5
parent
af14179c9e
commit
677dc0f752
16 changed files with 494 additions and 700 deletions
@ -1,211 +0,0 @@ |
||||
/***************************************************************************/ |
||||
/* */ |
||||
/* ftextend.h */ |
||||
/* */ |
||||
/* FreeType extensions implementation (specification). */ |
||||
/* */ |
||||
/* Copyright 1996-2001 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. */ |
||||
/* */ |
||||
/***************************************************************************/ |
||||
|
||||
|
||||
#ifndef __FTEXTEND_H__ |
||||
#define __FTEXTEND_H__ |
||||
|
||||
|
||||
#include <ft2build.h> |
||||
#include FT_INTERNAL_OBJECTS_H |
||||
|
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* The extensions don't need to be integrated at compile time into the */ |
||||
/* engine, only at link time. */ |
||||
/* */ |
||||
/*************************************************************************/ |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <FuncType> */ |
||||
/* FT_Extension_Initializer */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Each new face object can have several extensions associated with */ |
||||
/* it at creation time. This function is used to initialize given */ |
||||
/* extension data for a given face. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* ext :: A typeless pointer to the extension data. */ |
||||
/* */ |
||||
/* face :: A handle to the source face object the extension is */ |
||||
/* associated with. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
/* <Note> */ |
||||
/* In case of error, the initializer should not destroy the extension */ |
||||
/* data, as the finalizer will get called later by the function's */ |
||||
/* caller. */ |
||||
/* */ |
||||
typedef FT_Error |
||||
(*FT_Extension_Initializer)( void* ext, |
||||
FT_Face face ); |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <FuncType> */ |
||||
/* FT_Extension_Finalizer */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Each new face object can have several extensions associated with */ |
||||
/* it at creation time. This function is used to finalize given */ |
||||
/* extension data for a given face; it occurs before the face object */ |
||||
/* itself is finalized. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* ext :: A typeless pointer to the extension data. */ |
||||
/* */ |
||||
/* face :: A handle to the source face object the extension is */ |
||||
/* associated with. */ |
||||
/* */ |
||||
typedef void |
||||
(*FT_Extension_Finalizer)( void* ext, |
||||
FT_Face face ); |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Struct> */ |
||||
/* FT_Extension_Class */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* A simple structure used to describe a given extension to the */ |
||||
/* FreeType base layer. An FT_Extension_Class is used as a parameter */ |
||||
/* for FT_Register_Extension(). */ |
||||
/* */ |
||||
/* <Fields> */ |
||||
/* id :: The extension's ID. This is a normal C string that */ |
||||
/* is used to uniquely reference the extension's */ |
||||
/* interface. */ |
||||
/* */ |
||||
/* size :: The size in bytes of the extension data that must be */ |
||||
/* associated with each face object. */ |
||||
/* */ |
||||
/* init :: A pointer to the extension data's initializer. */ |
||||
/* */ |
||||
/* finalize :: A pointer to the extension data's finalizer. */ |
||||
/* */ |
||||
/* interface :: This pointer can be anything, but should usually */ |
||||
/* point to a table of function pointers which implement */ |
||||
/* the extension's interface. */ |
||||
/* */ |
||||
/* offset :: This field is set and used within the base layer and */ |
||||
/* should be set to 0 when registering an extension */ |
||||
/* through FT_Register_Extension(). It contains an */ |
||||
/* offset within the face's extension block for the */ |
||||
/* current extension's data. */ |
||||
/* */ |
||||
typedef struct FT_Extension_Class_ |
||||
{ |
||||
const char* id; |
||||
FT_ULong size; |
||||
FT_Extension_Initializer init; |
||||
FT_Extension_Finalizer finalize; |
||||
void* interface; |
||||
|
||||
FT_ULong offset; |
||||
|
||||
} FT_Extension_Class; |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Register_Extension */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Registers a new extension. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* driver :: A handle to the driver object. */ |
||||
/* */ |
||||
/* class :: A pointer to a class describing the extension. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
FT_EXPORT( FT_Error ) |
||||
FT_Register_Extension( FT_Driver driver, |
||||
FT_Extension_Class* clazz ); |
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_EXTEND_ENGINE |
||||
|
||||
|
||||
/* Initialize the extension component */ |
||||
FT_LOCAL FT_Error |
||||
FT_Init_Extensions( FT_Library library ); |
||||
|
||||
/* Finalize the extension component */ |
||||
FT_LOCAL FT_Error |
||||
FT_Done_Extensions( FT_Library library ); |
||||
|
||||
/* Create an extension within a face object. Called by the */ |
||||
/* face object constructor. */ |
||||
FT_LOCAL FT_Error |
||||
FT_Create_Extensions( FT_Face face ); |
||||
|
||||
/* Destroy all extensions within a face object. Called by the */ |
||||
/* face object destructor. */ |
||||
FT_LOCAL FT_Error |
||||
FT_Destroy_Extensions( FT_Face face ); |
||||
|
||||
|
||||
#endif |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Get_Extension */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Queries an extension block by an extension ID string. */ |
||||
/* */ |
||||
/* <Input> */ |
||||
/* face :: A handle to the face object. */ |
||||
/* extension_id :: An ID string identifying the extension. */ |
||||
/* */ |
||||
/* <Output> */ |
||||
/* extension_interface :: A generic pointer, usually pointing to a */ |
||||
/* table of functions implementing the */ |
||||
/* extension interface. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* A generic pointer to the extension block. */ |
||||
/* */ |
||||
FT_EXPORT( void* ) |
||||
FT_Get_Extension( FT_Face face, |
||||
const char* extension_id, |
||||
void** extension_interface ); |
||||
|
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FTEXTEND_H__ */ |
||||
|
||||
|
||||
/* END */ |
@ -0,0 +1,75 @@ |
||||
/* definitions of trace levels for FreeType 2 */ |
||||
|
||||
/* the first level must always be `trace_any' */ |
||||
FT_TRACE_DEF( any ) |
||||
|
||||
/* base components */ |
||||
FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ |
||||
FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ |
||||
FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ |
||||
FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ |
||||
FT_TRACE_DEF( list ) /* list management (ftlist.c) */ |
||||
FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ |
||||
FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ |
||||
FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ |
||||
FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ |
||||
|
||||
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ |
||||
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ |
||||
FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ |
||||
|
||||
/* Cache sub-system */ |
||||
FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc..) */ |
||||
|
||||
/* SFNT driver components */ |
||||
FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ |
||||
FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ |
||||
FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ |
||||
FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ |
||||
FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ |
||||
|
||||
/* TrueType driver components */ |
||||
FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ |
||||
FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ |
||||
FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ |
||||
FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ |
||||
FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ |
||||
|
||||
/* Type 1 driver components */ |
||||
FT_TRACE_DEF( t1driver ) |
||||
FT_TRACE_DEF( t1gload ) |
||||
FT_TRACE_DEF( t1hint ) |
||||
FT_TRACE_DEF( t1load ) |
||||
FT_TRACE_DEF( t1objs ) |
||||
FT_TRACE_DEF( t1parse ) |
||||
|
||||
/* PostScript helper module `psaux' */ |
||||
FT_TRACE_DEF( t1decode ) |
||||
FT_TRACE_DEF( psobjs ) |
||||
|
||||
/* PostScript hinting module `pshinter' */ |
||||
FT_TRACE_DEF( pshrec ) |
||||
FT_TRACE_DEF( pshalgo1 ) |
||||
FT_TRACE_DEF( pshalgo2 ) |
||||
|
||||
/* Type 2 driver components */ |
||||
FT_TRACE_DEF( cffdriver ) |
||||
FT_TRACE_DEF( cffgload ) |
||||
FT_TRACE_DEF( cffload ) |
||||
FT_TRACE_DEF( cffobjs ) |
||||
FT_TRACE_DEF( cffparse ) |
||||
|
||||
/* CID driver components */ |
||||
FT_TRACE_DEF( cidafm ) |
||||
FT_TRACE_DEF( ciddriver ) |
||||
FT_TRACE_DEF( cidgload ) |
||||
FT_TRACE_DEF( cidload ) |
||||
FT_TRACE_DEF( cidobjs ) |
||||
FT_TRACE_DEF( cidparse ) |
||||
|
||||
/* Windows fonts component */ |
||||
FT_TRACE_DEF( winfnt ) |
||||
|
||||
/* PCF fonts component */ |
||||
FT_TRACE_DEF( pcfdriver ) |
||||
FT_TRACE_DEF( pcfread ) |
@ -1,302 +0,0 @@ |
||||
/***************************************************************************/ |
||||
/* */ |
||||
/* ftextend.c */ |
||||
/* */ |
||||
/* FreeType extensions implementation (body). */ |
||||
/* */ |
||||
/* Copyright 1996-2001 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. */ |
||||
/* */ |
||||
/***************************************************************************/ |
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* This is an updated version of the extension component, now located */ |
||||
/* in the main library's source directory. It allows the dynamic */ |
||||
/* registration/use of various face object extensions through a simple */ |
||||
/* API. */ |
||||
/* */ |
||||
/*************************************************************************/ |
||||
|
||||
|
||||
#include <ft2build.h> |
||||
#include FT_INTERNAL_EXTEND_H |
||||
#include FT_INTERNAL_DEBUG_H |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
||||
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
||||
/* messages during execution. */ |
||||
/* */ |
||||
#undef FT_COMPONENT |
||||
#define FT_COMPONENT trace_extend |
||||
|
||||
|
||||
typedef struct FT_Extension_Registry_ |
||||
{ |
||||
FT_Int num_extensions; |
||||
FT_Long cur_offset; |
||||
FT_Extension_Class classes[FT_MAX_EXTENSIONS]; |
||||
|
||||
} FT_Extension_Registry; |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Init_Extensions */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Initializes the extension component. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* driver :: A handle to the driver object. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
FT_LOCAL_DEF FT_Error |
||||
FT_Init_Extensions( FT_Driver driver ) |
||||
{ |
||||
FT_Error error; |
||||
FT_Memory memory; |
||||
FT_Extension_Registry* registry; |
||||
|
||||
|
||||
memory = driver->root.library->memory; |
||||
if ( ALLOC( registry, sizeof ( *registry ) ) ) |
||||
return error; |
||||
|
||||
registry->num_extensions = 0; |
||||
registry->cur_offset = 0; |
||||
driver->extensions = registry; |
||||
|
||||
FT_TRACE2(( "FT_Init_Extensions: success\n" )); |
||||
|
||||
return FT_Err_Ok; |
||||
} |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Done_Extensions */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Finalizes the extension component. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* driver :: A handle to the driver object. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
FT_LOCAL_DEF FT_Error |
||||
FT_Done_Extensions( FT_Driver driver ) |
||||
{ |
||||
FT_Memory memory = driver->root.memory; |
||||
|
||||
|
||||
FREE( driver->extensions ); |
||||
return FT_Err_Ok; |
||||
} |
||||
|
||||
|
||||
/* documentation is in ftextend.h */ |
||||
|
||||
FT_EXPORT_DEF( FT_Error ) |
||||
FT_Register_Extension( FT_Driver driver, |
||||
FT_Extension_Class* clazz ) |
||||
{ |
||||
FT_Extension_Registry* registry; |
||||
|
||||
|
||||
if ( !driver ) |
||||
return FT_Err_Invalid_Driver_Handle; |
||||
|
||||
if ( !clazz ) |
||||
return FT_Err_Invalid_Argument; |
||||
|
||||
registry = (FT_Extension_Registry*)driver->extensions; |
||||
if ( registry ) |
||||
{ |
||||
FT_Int n = registry->num_extensions; |
||||
FT_Extension_Class* cur = registry->classes + n; |
||||
|
||||
|
||||
if ( n >= FT_MAX_EXTENSIONS ) |
||||
return FT_Err_Too_Many_Extensions; |
||||
|
||||
*cur = *clazz; |
||||
|
||||
cur->offset = registry->cur_offset; |
||||
|
||||
registry->num_extensions++; |
||||
registry->cur_offset += |
||||
( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT; |
||||
|
||||
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n", |
||||
cur->id )); |
||||
} |
||||
|
||||
return FT_Err_Ok; |
||||
} |
||||
|
||||
|
||||
/* documentation is in ftextend.h */ |
||||
|
||||
FT_EXPORT_DEF( void* ) |
||||
FT_Get_Extension( FT_Face face, |
||||
const char* extension_id, |
||||
void** extension_interface ) |
||||
{ |
||||
FT_Extension_Registry* registry; |
||||
|
||||
|
||||
if ( !face || !extension_id || !extension_interface ) |
||||
return 0; |
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions; |
||||
if ( registry && face->extensions ) |
||||
{ |
||||
FT_Extension_Class* cur = registry->classes; |
||||
FT_Extension_Class* limit = cur + registry->num_extensions; |
||||
|
||||
|
||||
for ( ; cur < limit; cur++ ) |
||||
if ( strcmp( cur->id, extension_id ) == 0 ) |
||||
{ |
||||
*extension_interface = cur->interface; |
||||
|
||||
FT_TRACE1(( "FT_Get_Extension: got `%s'\n", extension_id )); |
||||
|
||||
return (void*)((char*)face->extensions + cur->offset); |
||||
} |
||||
} |
||||
|
||||
/* could not find the extension id */ |
||||
|
||||
FT_ERROR(( "FT_Get_Extension: couldn't find `%s'\n", extension_id )); |
||||
|
||||
*extension_interface = 0; |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Destroy_Extensions */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Destroys all extensions within a face object. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* face :: A handle to the face object. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
/* <Note> */ |
||||
/* Called by the face object destructor. */ |
||||
/* */ |
||||
FT_LOCAL_DEF FT_Error |
||||
FT_Destroy_Extensions( FT_Face face ) |
||||
{ |
||||
FT_Extension_Registry* registry; |
||||
FT_Memory memory; |
||||
|
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions; |
||||
if ( registry && face->extensions ) |
||||
{ |
||||
FT_Extension_Class* cur = registry->classes; |
||||
FT_Extension_Class* limit = cur + registry->num_extensions; |
||||
|
||||
|
||||
for ( ; cur < limit; cur++ ) |
||||
{ |
||||
char* ext = (char*)face->extensions + cur->offset; |
||||
|
||||
if ( cur->finalize ) |
||||
cur->finalize( ext, face ); |
||||
} |
||||
|
||||
memory = face->driver->root.memory; |
||||
FREE( face->extensions ); |
||||
} |
||||
|
||||
return FT_Err_Ok; |
||||
} |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Create_Extensions */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Creates an extension object within a face object for all */ |
||||
/* registered extensions. */ |
||||
/* */ |
||||
/* <InOut> */ |
||||
/* face :: A handle to the face object. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* FreeType error code. 0 means success. */ |
||||
/* */ |
||||
/* <Note> */ |
||||
/* Called by the face object constructor. */ |
||||
/* */ |
||||
FT_LOCAL_DEF FT_Error |
||||
FT_Create_Extensions( FT_Face face ) |
||||
{ |
||||
FT_Extension_Registry* registry; |
||||
FT_Memory memory; |
||||
FT_Error error; |
||||
|
||||
|
||||
face->extensions = 0; |
||||
|
||||
/* load extensions registry; exit successfully if none is there */ |
||||
|
||||
registry = (FT_Extension_Registry*)face->driver->extensions; |
||||
if ( !registry ) |
||||
return FT_Err_Ok; |
||||
|
||||
memory = face->driver->root.memory; |
||||
if ( ALLOC( face->extensions, registry->cur_offset ) ) |
||||
return error; |
||||
|
||||
{ |
||||
FT_Extension_Class* cur = registry->classes; |
||||
FT_Extension_Class* limit = cur + registry->num_extensions; |
||||
|
||||
|
||||
for ( ; cur < limit; cur++ ) |
||||
{ |
||||
char* ext = (char*)face->extensions + cur->offset; |
||||
|
||||
if ( cur->init ) |
||||
{ |
||||
error = cur->init( ext, face ); |
||||
if ( error ) |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return error; |
||||
} |
||||
|
||||
|
||||
/* END */ |
Loading…
Reference in new issue