1 /***************************************************************************/
5 /* FreeType modules public interface (specification). */
7 /* Copyright 1996-2003, 2006, 2008-2010, 2012 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 /***************************************************************************/
19 #ifndef __FTMODAPI_H__
20 #define __FTMODAPI_H__
24 #include FT_FREETYPE_H
27 #error "freetype.h of FreeType 1 has been loaded!"
28 #error "Please fix the directory search order for header files"
29 #error "so that freetype.h of FreeType 2 is found first."
36 /*************************************************************************/
39 /* module_management */
42 /* Module Management */
45 /* How to add, upgrade, remove, and control modules from FreeType. */
48 /* The definitions below are used to manage modules within FreeType. */
49 /* Modules can be added, upgraded, and removed at runtime. */
50 /* Additionally, some module properties can be controlled also. */
52 /* Here is a list of possible values of the `module_name' field in */
53 /* the @FT_Module_Class structure. */
66 /* raster1, raster5 */
68 /* smooth, smooth-lcd, smooth-lcdv */
76 /* Note that the FreeType Cache sub-system is not a FreeType module. */
78 /*************************************************************************/
81 /* module bit flags */
82 #define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
83 #define FT_MODULE_RENDERER 2 /* this module is a renderer */
84 #define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
85 #define FT_MODULE_STYLER 8 /* this module is a styler */
87 #define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
89 #define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
90 /* support vector outlines */
91 #define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
95 /* deprecated values */
96 #define ft_module_font_driver FT_MODULE_FONT_DRIVER
97 #define ft_module_renderer FT_MODULE_RENDERER
98 #define ft_module_hinter FT_MODULE_HINTER
99 #define ft_module_styler FT_MODULE_STYLER
101 #define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
102 #define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
103 #define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
106 typedef FT_Pointer FT_Module_Interface;
109 /*************************************************************************/
112 /* FT_Module_Constructor */
115 /* A function used to initialize (not create) a new module object. */
118 /* module :: The module to initialize. */
121 (*FT_Module_Constructor)( FT_Module module );
124 /*************************************************************************/
127 /* FT_Module_Destructor */
130 /* A function used to finalize (not destroy) a given module object. */
133 /* module :: The module to finalize. */
136 (*FT_Module_Destructor)( FT_Module module );
139 /*************************************************************************/
142 /* FT_Module_Requester */
145 /* A function used to query a given module for a specific interface. */
148 /* module :: The module to be searched. */
150 /* name :: The name of the interface in the module. */
152 typedef FT_Module_Interface
153 (*FT_Module_Requester)( FT_Module module,
157 /*************************************************************************/
160 /* FT_Module_Class */
163 /* The module class descriptor. */
166 /* module_flags :: Bit flags describing the module. */
168 /* module_size :: The size of one module object/instance in */
171 /* module_name :: The name of the module. */
173 /* module_version :: The version, as a 16.16 fixed number */
176 /* module_requires :: The version of FreeType this module requires, */
177 /* as a 16.16 fixed number (major.minor). Starts */
178 /* at version 2.0, i.e., 0x20000. */
180 /* module_init :: The initializing function. */
182 /* module_done :: The finalizing function. */
184 /* get_interface :: The interface requesting function. */
186 typedef struct FT_Module_Class_
188 FT_ULong module_flags;
190 const FT_String* module_name;
191 FT_Fixed module_version;
192 FT_Fixed module_requires;
194 const void* module_interface;
196 FT_Module_Constructor module_init;
197 FT_Module_Destructor module_done;
198 FT_Module_Requester get_interface;
203 /*************************************************************************/
209 /* Add a new module to a given library instance. */
212 /* library :: A handle to the library object. */
215 /* clazz :: A pointer to class descriptor for the module. */
218 /* FreeType error code. 0~means success. */
221 /* An error will be returned if a module already exists by that name, */
222 /* or if the module requires a version of FreeType that is too great. */
224 FT_EXPORT( FT_Error )
225 FT_Add_Module( FT_Library library,
226 const FT_Module_Class* clazz );
229 /*************************************************************************/
235 /* Find a module by its name. */
238 /* library :: A handle to the library object. */
240 /* module_name :: The module's name (as an ASCII string). */
243 /* A module handle. 0~if none was found. */
246 /* FreeType's internal modules aren't documented very well, and you */
247 /* should look up the source code for details. */
249 FT_EXPORT( FT_Module )
250 FT_Get_Module( FT_Library library,
251 const char* module_name );
254 /*************************************************************************/
257 /* FT_Remove_Module */
260 /* Remove a given module from a library instance. */
263 /* library :: A handle to a library object. */
266 /* module :: A handle to a module object. */
269 /* FreeType error code. 0~means success. */
272 /* The module object is destroyed by the function in case of success. */
274 FT_EXPORT( FT_Error )
275 FT_Remove_Module( FT_Library library,
279 /**********************************************************************
285 * Set a property for a given module.
289 * A handle to the library the module is part of.
295 * The property name. Properties are described in the `Synopsis'
296 * subsection of the module's documentation.
298 * Note that only a few modules have properties.
301 * A generic pointer to a variable or structure which gives the new
302 * value of the property. The exact definition of `value' is
303 * dependent on the property; see the `Synopsis' subsection of the
304 * module's documentation.
307 * FreeType error code. 0~means success.
310 * If `module_name' isn't a valid module name, or `property_name'
311 * doesn't specify a valid property, or if `value' doesn't represent a
312 * valid value for the given property, an error is returned.
314 * The following example sets property `bar' (a simple integer) in
315 * module `foo' to value~1.
322 * FT_Property_Set( library, "foo", "bar", &bar );
325 * It is not possible to set properties of the FreeType Cache
326 * sub-system with FT_Property_Set; use @FTC_Property_Set instead.
333 FT_Property_Set( FT_Library library,
334 const FT_String* module_name,
335 const FT_String* property_name,
339 /**********************************************************************
345 * Get a module's property value.
349 * A handle to the library the module is part of.
355 * The property name. Properties are described in the `Synopsis'
356 * subsection of the module's documentation.
360 * A generic pointer to a variable or structure which gives the
361 * value of the property. The exact definition of `value' is
362 * dependent on the property; see the `Synopsis' subsection of the
363 * module's documentation.
366 * FreeType error code. 0~means success.
369 * If `module_name' isn't a valid module name, or `property_name'
370 * doesn't specify a valid property, or if `value' doesn't represent a
371 * valid value for the given property, an error is returned.
373 * The following example gets property `baz' (a range) in module `foo'.
386 * FT_Property_Get( library, "foo", "baz", &baz );
389 * It is not possible to retrieve properties of the FreeType Cache
390 * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
397 FT_Property_Get( FT_Library library,
398 const FT_String* module_name,
399 const FT_String* property_name,
403 /*************************************************************************/
406 /* FT_Reference_Library */
409 /* A counter gets initialized to~1 at the time an @FT_Library */
410 /* structure is created. This function increments the counter. */
411 /* @FT_Done_Library then only destroys a library if the counter is~1, */
412 /* otherwise it simply decrements the counter. */
414 /* This function helps in managing life-cycles of structures which */
415 /* reference @FT_Library objects. */
418 /* library :: A handle to a target library object. */
421 /* FreeType error code. 0~means success. */
426 FT_EXPORT( FT_Error )
427 FT_Reference_Library( FT_Library library );
430 /*************************************************************************/
436 /* This function is used to create a new FreeType library instance */
437 /* from a given memory object. It is thus possible to use libraries */
438 /* with distinct memory allocators within the same program. */
440 /* Normally, you would call this function (followed by a call to */
441 /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
442 /* instead of @FT_Init_FreeType to initialize the FreeType library. */
444 /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
445 /* library instance. */
448 /* memory :: A handle to the original memory object. */
451 /* alibrary :: A pointer to handle of a new library object. */
454 /* FreeType error code. 0~means success. */
457 /* See the discussion of reference counters in the description of */
458 /* @FT_Reference_Library. */
460 FT_EXPORT( FT_Error )
461 FT_New_Library( FT_Memory memory,
462 FT_Library *alibrary );
465 /*************************************************************************/
468 /* FT_Done_Library */
471 /* Discard a given library object. This closes all drivers and */
472 /* discards all resource objects. */
475 /* library :: A handle to the target library. */
478 /* FreeType error code. 0~means success. */
481 /* See the discussion of reference counters in the description of */
482 /* @FT_Reference_Library. */
484 FT_EXPORT( FT_Error )
485 FT_Done_Library( FT_Library library );
490 (*FT_DebugHook_Func)( void* arg );
493 /*************************************************************************/
496 /* FT_Set_Debug_Hook */
499 /* Set a debug hook function for debugging the interpreter of a font */
503 /* library :: A handle to the library object. */
506 /* hook_index :: The index of the debug hook. You should use the */
507 /* values defined in `ftobjs.h', e.g., */
508 /* `FT_DEBUG_HOOK_TRUETYPE'. */
510 /* debug_hook :: The function used to debug the interpreter. */
513 /* Currently, four debug hook slots are available, but only two (for */
514 /* the TrueType and the Type~1 interpreter) are defined. */
516 /* Since the internal headers of FreeType are no longer installed, */
517 /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
518 /* This is a bug and will be fixed in a forthcoming release. */
521 FT_Set_Debug_Hook( FT_Library library,
523 FT_DebugHook_Func debug_hook );
526 /*************************************************************************/
529 /* FT_Add_Default_Modules */
532 /* Add the set of default drivers to a given library object. */
533 /* This is only useful when you create a library object with */
534 /* @FT_New_Library (usually to plug a custom memory manager). */
537 /* library :: A handle to a new library object. */
540 FT_Add_Default_Modules( FT_Library library );
544 /**************************************************************************
550 * The TrueType Engine
553 * TrueType bytecode support.
556 * This section contains a function used to query the level of TrueType
557 * bytecode support compiled in this version of the library.
562 /**************************************************************************
565 * FT_TrueTypeEngineType
568 * A list of values describing which kind of TrueType bytecode
569 * engine is implemented in a given FT_Library instance. It is used
570 * by the @FT_Get_TrueType_Engine_Type function.
573 * FT_TRUETYPE_ENGINE_TYPE_NONE ::
574 * The library doesn't implement any kind of bytecode interpreter.
576 * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
577 * The library implements a bytecode interpreter that doesn't
578 * support the patented operations of the TrueType virtual machine.
580 * Its main use is to load certain Asian fonts which position and
581 * scale glyph components with bytecode instructions. It produces
582 * bad output for most other fonts.
584 * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
585 * The library implements a bytecode interpreter that covers
586 * the full instruction set of the TrueType virtual machine (this
587 * was governed by patents until May 2010, hence the name).
593 typedef enum FT_TrueTypeEngineType_
595 FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
596 FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
597 FT_TRUETYPE_ENGINE_TYPE_PATENTED
599 } FT_TrueTypeEngineType;
602 /**************************************************************************
605 * FT_Get_TrueType_Engine_Type
608 * Return an @FT_TrueTypeEngineType value to indicate which level of
609 * the TrueType virtual machine a given library instance supports.
613 * A library instance.
616 * A value indicating which level is supported.
622 FT_EXPORT( FT_TrueTypeEngineType )
623 FT_Get_TrueType_Engine_Type( FT_Library library );
631 #endif /* __FTMODAPI_H__ */