1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftmodule.h                                                             */
4 /*                                                                         */
5 /*    FreeType modules public interface (specification).                   */
6 /*                                                                         */
7 /*  Copyright 1996-2001, 2002, 2003 by                                     */
8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9 /*                                                                         */
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.                                        */
15 /*                                                                         */
16 /***************************************************************************/
17 
18 
19 #ifndef __FTMODULE_H__
20 #define __FTMODULE_H__
21 
22 
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 
26 
27 FT_BEGIN_HEADER
28 
29 
30   /*************************************************************************/
31   /*                                                                       */
32   /* <Section>                                                             */
33   /*    module_management                                                  */
34   /*                                                                       */
35   /* <Title>                                                               */
36   /*    Module Management                                                  */
37   /*                                                                       */
38   /* <Abstract>                                                            */
39   /*    How to add, upgrade, and remove modules from FreeType.             */
40   /*                                                                       */
41   /* <Description>                                                         */
42   /*    The definitions below are used to manage modules within FreeType.  */
43   /*    Modules can be added, upgraded, and removed at runtime.            */
44   /*                                                                       */
45   /*************************************************************************/
46 
47 
48   /* module bit flags */
49 #define FT_MODULE_FONT_DRIVER         1  /* this module is a font driver  */
50 #define FT_MODULE_RENDERER            2  /* this module is a renderer     */
51 #define FT_MODULE_HINTER              4  /* this module is a glyph hinter */
52 #define FT_MODULE_STYLER              8  /* this module is a styler       */
53 
54 #define FT_MODULE_DRIVER_SCALABLE     0x100   /* the driver supports      */
55                                               /* scalable fonts           */
56 #define FT_MODULE_DRIVER_NO_OUTLINES  0x200   /* the driver does not      */
57                                               /* support vector outlines  */
58 #define FT_MODULE_DRIVER_HAS_HINTER   0x400   /* the driver provides its  */
59                                               /* own hinter               */
60 
61 
62   /* deprecated values */
63 #define ft_module_font_driver         FT_MODULE_FONT_DRIVER
64 #define ft_module_renderer            FT_MODULE_RENDERER
65 #define ft_module_hinter              FT_MODULE_HINTER
66 #define ft_module_styler              FT_MODULE_STYLER
67 
68 #define ft_module_driver_scalable     FT_MODULE_DRIVER_SCALABLE
69 #define ft_module_driver_no_outlines  FT_MODULE_DRIVER_NO_OUTLINES
70 #define ft_module_driver_has_hinter   FT_MODULE_DRIVER_HAS_HINTER
71 
72 
73   typedef void
74   (*FT_Module_Interface)( void );
75 
76   typedef FT_Error
77   (*FT_Module_Constructor)( FT_Module  module );
78 
79   typedef void
80   (*FT_Module_Destructor)( FT_Module  module );
81 
82   typedef FT_Module_Interface
83   (*FT_Module_Requester)( FT_Module    module,
84                           const char*  name );
85 
86 
87   /*************************************************************************/
88   /*                                                                       */
89   /* <Struct>                                                              */
90   /*    FT_Module_Class                                                    */
91   /*                                                                       */
92   /* <Description>                                                         */
93   /*    The module class descriptor.                                       */
94   /*                                                                       */
95   /* <Fields>                                                              */
96   /*    module_flags      :: Bit flags describing the module.              */
97   /*                                                                       */
98   /*    module_size       :: The size of one module object/instance in     */
99   /*                         bytes.                                        */
100   /*                                                                       */
101   /*    module_name       :: The name of the module.                       */
102   /*                                                                       */
103   /*    module_version    :: The version, as a 16.16 fixed number          */
104   /*                         (major.minor).                                */
105   /*                                                                       */
106   /*    module_requires   :: The version of FreeType this module requires  */
107   /*                         (starts at version 2.0, i.e 0x20000)          */
108   /*                                                                       */
109   /*    module_init       :: A function used to initialize (not create) a  */
110   /*                         new module object.                            */
111   /*                                                                       */
112   /*    module_done       :: A function used to finalize (not destroy) a   */
113   /*                         given module object                           */
114   /*                                                                       */
115   /*    get_interface     :: Queries a given module for a specific         */
116   /*                         interface by name.                            */
117   /*                                                                       */
118   typedef struct  FT_Module_Class_
119   {
120     FT_ULong               module_flags;
121     FT_Long                module_size;
122     const FT_String*       module_name;
123     FT_Fixed               module_version;
124     FT_Fixed               module_requires;
125 
126     const void*            module_interface;
127 
128     FT_Module_Constructor  module_init;
129     FT_Module_Destructor   module_done;
130     FT_Module_Requester    get_interface;
131 
132   } FT_Module_Class;
133 
134 
135   /*************************************************************************/
136   /*                                                                       */
137   /* <Function>                                                            */
138   /*    FT_Add_Module                                                      */
139   /*                                                                       */
140   /* <Description>                                                         */
141   /*    Adds a new module to a given library instance.                     */
142   /*                                                                       */
143   /* <InOut>                                                               */
144   /*    library :: A handle to the library object.                         */
145   /*                                                                       */
146   /* <Input>                                                               */
147   /*    clazz   :: A pointer to class descriptor for the module.           */
148   /*                                                                       */
149   /* <Return>                                                              */
150   /*    FreeType error code.  0 means success.                             */
151   /*                                                                       */
152   /* <Note>                                                                */
153   /*    An error will be returned if a module already exists by that name, */
154   /*    or if the module requires a version of FreeType that is too great. */
155   /*                                                                       */
156   FT_EXPORT( FT_Error )
157   FT_Add_Module( FT_Library              library,
158                  const FT_Module_Class*  clazz );
159 
160 
161   /*************************************************************************/
162   /*                                                                       */
163   /* <Function>                                                            */
164   /*    FT_Get_Module                                                      */
165   /*                                                                       */
166   /* <Description>                                                         */
167   /*    Finds a module by its name.                                        */
168   /*                                                                       */
169   /* <Input>                                                               */
170   /*    library     :: A handle to the library object.                     */
171   /*                                                                       */
172   /*    module_name :: The module's name (as an ASCII string).             */
173   /*                                                                       */
174   /* <Return>                                                              */
175   /*    A module handle.  0 if none was found.                             */
176   /*                                                                       */
177   /* <Note>                                                                */
178   /*    You should better be familiar with FreeType internals to know      */
179   /*    which module to look for :-)                                       */
180   /*                                                                       */
181   FT_EXPORT( FT_Module )
182   FT_Get_Module( FT_Library   library,
183                  const char*  module_name );
184 
185 
186   /*************************************************************************/
187   /*                                                                       */
188   /* <Function>                                                            */
189   /*    FT_Remove_Module                                                   */
190   /*                                                                       */
191   /* <Description>                                                         */
192   /*    Removes a given module from a library instance.                    */
193   /*                                                                       */
194   /* <InOut>                                                               */
195   /*    library :: A handle to a library object.                           */
196   /*                                                                       */
197   /* <Input>                                                               */
198   /*    module  :: A handle to a module object.                            */
199   /*                                                                       */
200   /* <Return>                                                              */
201   /*    FreeType error code.  0 means success.                             */
202   /*                                                                       */
203   /* <Note>                                                                */
204   /*    The module object is destroyed by the function in case of success. */
205   /*                                                                       */
206   FT_EXPORT( FT_Error )
207   FT_Remove_Module( FT_Library  library,
208                     FT_Module   module );
209 
210 
211   /*************************************************************************/
212   /*                                                                       */
213   /* <Function>                                                            */
214   /*    FT_New_Library                                                     */
215   /*                                                                       */
216   /* <Description>                                                         */
217   /*    This function is used to create a new FreeType library instance    */
218   /*    from a given memory object.  It is thus possible to use libraries  */
219   /*    with distinct memory allocators within the same program.           */
220   /*                                                                       */
221   /* <Input>                                                               */
222   /*    memory   :: A handle to the original memory object.                */
223   /*                                                                       */
224   /* <Output>                                                              */
225   /*    alibrary :: A pointer to handle of a new library object.           */
226   /*                                                                       */
227   /* <Return>                                                              */
228   /*    FreeType error code.  0 means success.                             */
229   /*                                                                       */
230   FT_EXPORT( FT_Error )
231   FT_New_Library( FT_Memory    memory,
232                   FT_Library  *alibrary );
233 
234 
235   /*************************************************************************/
236   /*                                                                       */
237   /* <Function>                                                            */
238   /*    FT_Done_Library                                                    */
239   /*                                                                       */
240   /* <Description>                                                         */
241   /*    Discards a given library object.  This closes all drivers and      */
242   /*    discards all resource objects.                                     */
243   /*                                                                       */
244   /* <Input>                                                               */
245   /*    library :: A handle to the target library.                         */
246   /*                                                                       */
247   /* <Return>                                                              */
248   /*    FreeType error code.  0 means success.                             */
249   /*                                                                       */
250   FT_EXPORT( FT_Error )
251   FT_Done_Library( FT_Library  library );
252 
253 
254 
255   typedef void
256   (*FT_DebugHook_Func)( void*  arg );
257 
258 
259   /*************************************************************************/
260   /*                                                                       */
261   /* <Function>                                                            */
262   /*    FT_Set_Debug_Hook                                                  */
263   /*                                                                       */
264   /* <Description>                                                         */
265   /*    Sets a debug hook function for debugging the interpreter of a font */
266   /*    format.                                                            */
267   /*                                                                       */
268   /* <InOut>                                                               */
269   /*    library    :: A handle to the library object.                      */
270   /*                                                                       */
271   /* <Input>                                                               */
272   /*    hook_index :: The index of the debug hook.  You should use the     */
273   /*                  values defined in ftobjs.h, e.g.                     */
274   /*                  FT_DEBUG_HOOK_TRUETYPE.                              */
275   /*                                                                       */
276   /*    debug_hook :: The function used to debug the interpreter.          */
277   /*                                                                       */
278   /* <Note>                                                                */
279   /*    Currently, four debug hook slots are available, but only two (for  */
280   /*    the TrueType and the Type 1 interpreter) are defined.              */
281   /*                                                                       */
282   FT_EXPORT( void )
283   FT_Set_Debug_Hook( FT_Library         library,
284                      FT_UInt            hook_index,
285                      FT_DebugHook_Func  debug_hook );
286 
287 
288 
289   /*************************************************************************/
290   /*                                                                       */
291   /* <Function>                                                            */
292   /*    FT_Add_Default_Modules                                             */
293   /*                                                                       */
294   /* <Description>                                                         */
295   /*    Adds the set of default drivers to a given library object.         */
296   /*    This is only useful when you create a library object with          */
297   /*    FT_New_Library() (usually to plug a custom memory manager).        */
298   /*                                                                       */
299   /* <InOut>                                                               */
300   /*    library :: A handle to a new library object.                       */
301   /*                                                                       */
302   FT_EXPORT( void )
303   FT_Add_Default_Modules( FT_Library  library );
304 
305 
306   /* */
307 
308 
309 FT_END_HEADER
310 
311 #endif /* __FTMODULE_H__ */
312 
313 
314 /* END */
315