1
/*******************************************************************
5
* Extensions Interface.
7
* Copyright 1996-1999 by
8
* David Turner, Robert Wilhelm, and Werner Lemberg.
10
* This file is part of the FreeType project, and may only be used
11
* modified and distributed under the terms of the FreeType project
12
* license, LICENSE.TXT. By continuing to use, modify, or distribute
13
* this file you indicate that you have read the license and
14
* understand and accept it fully.
16
* This is an updated version of the extension component, now
17
* located in the main library's source directory. It allows
18
* the dynamic registration/use of various face object extensions
19
* through a simple API.
21
******************************************************************/
22
/* $XFree86: xc/extras/FreeType/lib/ttextend.h,v 1.2 2001/10/28 03:32:05 tsi Exp $ */
36
/* The extensions don't need to be integrated at compile time into */
37
/* the engine, only at link time. */
40
/* When a new face object is created, the face constructor calls */
41
/* the extension constructor with the following arguments: */
43
/* ext : typeless pointer to the face's extension block. */
44
/* Its size is the one given at registration time */
45
/* in the extension class's 'size' field. */
47
/* face : the parent face object. Note that the extension */
48
/* constructor is called when the face object is */
51
typedef TT_Error TExt_Constructor( void* ext, PFace face );
54
/* When a face object is destroyed, the face destructor calls */
55
/* the extension destructor with the following arguments. */
57
/* ext : typeless pointer to the face's extension block. */
58
/* Its size is the one given at registration time */
59
/* in the extension class's 'size' field. */
61
/* face : the parent face object. Note that the extension */
62
/* destructor is called before the actual face object */
65
typedef TT_Error TExt_Destructor ( void* ext, PFace face );
67
typedef TExt_Constructor* PExt_Constructor;
68
typedef TExt_Destructor* PExt_Destructor;
71
struct TExtension_Class_
73
Long id; /* extension id */
74
Long size; /* size in bytes of extension record */
75
PExt_Constructor build; /* the extension's class constructor */
76
PExt_Destructor destroy; /* the extension's class destructor */
78
Long offset; /* offset of ext. record in face obj */
79
/* (set by the engine) */
82
typedef struct TExtension_Class_ TExtension_Class;
83
typedef TExtension_Class* PExtension_Class;
86
#define Build_Extension_ID( a, b, c, d ) \
87
( ((ULong)(a) << 24) | \
88
((ULong)(b) << 16) | \
89
((ULong)(c) << 8 ) | \
92
/* A note regarding extensions and the single-object compilation */
95
/* When the engine is compiled as a single object file, extensions */
96
/* must remain linkable *after* compile time. In order to do this, */
97
/* we need to export the functions that an extension may need. */
98
/* Fortunately, we can limit ourselves to : */
100
/* o TT_Register_Extension (previously called Extension_Register) */
101
/* which is to be called by each extension on within */
102
/* it TT_Init_XXXX_Extension initializer. */
104
/* o File and frame access functions. Fortunately, these already */
105
/* have their names prefixed by "TT_", so no change was needed */
106
/* except replacing the LOCAL_DEF keyword with EXPORT_DEF */
108
/* o Memory access functions, i.e. TT_Alloc and TT_Free. Again, */
109
/* the change is minimal */
111
/* o the table-lookup function : TT_LookUp_Table, formerly known */
112
/* as Load_TrueType_Table in ttload.c. */
115
/* Other than that, an extension should be able to #include all */
116
/* relevant header files to get access to internal types, but */
117
/* should not call engine internal functions.. */
119
/* If there is a need for a specific internal function call, let */
120
/* me known to see if we need to export it by default.. */
124
/* Register a new extension. Called by extension */
125
/* service initializers. */
127
TT_Error TT_Register_Extension( PEngine_Instance engine,
130
PExt_Constructor create,
131
PExt_Destructor destroy );
134
#if defined(TT_CONFIG_OPTION_EXTEND_ENGINE) && !defined(FTXSBIT_H)
135
/* Initialize the extension component */
137
TT_Error TTExtend_Init( PEngine_Instance engine );
139
/* Finalize the extension component */
141
TT_Error TTExtend_Done( PEngine_Instance engine );
143
/* Create an extension within a face object. Called by the */
144
/* face object constructor. */
146
TT_Error Extension_Create( PFace face );
148
/* Destroy all extensions within a face object. Called by the */
149
/* face object destructor. */
151
TT_Error Extension_Destroy( PFace face );
154
/* Query an extension block by extension_ID. Called by extension */
155
/* service routines. */
157
TT_Error TT_Extension_Get( PFace face,
159
void** extension_block );
166
#endif /* TTEXTEND_H */