1 /***************************************************************************/
5 /* FreeType modules public interface (specification). */
7 /* Copyright 1996-2003, 2006, 2008-2010, 2012, 2013 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 that 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 * Note that the FreeType Cache sub-system doesn't recognize module
326 * property changes. To avoid glyph lookup confusion within the cache
327 * you should call @FTC_Manager_Reset to completely flush the cache if
328 * a module property gets changed after @FTC_Manager_New has been
331 * It is not possible to set properties of the FreeType Cache
332 * sub-system itself with FT_Property_Set; use @FTC_Property_Set
339 FT_EXPORT( FT_Error
)
340 FT_Property_Set( FT_Library library
,
341 const FT_String
* module_name
,
342 const FT_String
* property_name
,
346 /**********************************************************************
352 * Get a module's property value.
356 * A handle to the library the module is part of.
362 * The property name. Properties are described in the `Synopsis'
363 * subsection of the module's documentation.
367 * A generic pointer to a variable or structure that gives the
368 * value of the property. The exact definition of `value' is
369 * dependent on the property; see the `Synopsis' subsection of the
370 * module's documentation.
373 * FreeType error code. 0~means success.
376 * If `module_name' isn't a valid module name, or `property_name'
377 * doesn't specify a valid property, or if `value' doesn't represent a
378 * valid value for the given property, an error is returned.
380 * The following example gets property `baz' (a range) in module `foo'.
393 * FT_Property_Get( library, "foo", "baz", &baz );
396 * It is not possible to retrieve properties of the FreeType Cache
397 * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
403 FT_EXPORT( FT_Error
)
404 FT_Property_Get( FT_Library library
,
405 const FT_String
* module_name
,
406 const FT_String
* property_name
,
410 /*************************************************************************/
413 /* FT_Reference_Library */
416 /* A counter gets initialized to~1 at the time an @FT_Library */
417 /* structure is created. This function increments the counter. */
418 /* @FT_Done_Library then only destroys a library if the counter is~1, */
419 /* otherwise it simply decrements the counter. */
421 /* This function helps in managing life-cycles of structures that */
422 /* reference @FT_Library objects. */
425 /* library :: A handle to a target library object. */
428 /* FreeType error code. 0~means success. */
433 FT_EXPORT( FT_Error
)
434 FT_Reference_Library( FT_Library library
);
437 /*************************************************************************/
443 /* This function is used to create a new FreeType library instance */
444 /* from a given memory object. It is thus possible to use libraries */
445 /* with distinct memory allocators within the same program. */
447 /* Normally, you would call this function (followed by a call to */
448 /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
449 /* instead of @FT_Init_FreeType to initialize the FreeType library. */
451 /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
452 /* library instance. */
455 /* memory :: A handle to the original memory object. */
458 /* alibrary :: A pointer to handle of a new library object. */
461 /* FreeType error code. 0~means success. */
464 /* See the discussion of reference counters in the description of */
465 /* @FT_Reference_Library. */
467 FT_EXPORT( FT_Error
)
468 FT_New_Library( FT_Memory memory
,
469 FT_Library
*alibrary
);
472 /*************************************************************************/
475 /* FT_Done_Library */
478 /* Discard a given library object. This closes all drivers and */
479 /* discards all resource objects. */
482 /* library :: A handle to the target library. */
485 /* FreeType error code. 0~means success. */
488 /* See the discussion of reference counters in the description of */
489 /* @FT_Reference_Library. */
491 FT_EXPORT( FT_Error
)
492 FT_Done_Library( FT_Library library
);
497 (*FT_DebugHook_Func
)( void* arg
);
500 /*************************************************************************/
503 /* FT_Set_Debug_Hook */
506 /* Set a debug hook function for debugging the interpreter of a font */
510 /* library :: A handle to the library object. */
513 /* hook_index :: The index of the debug hook. You should use the */
514 /* values defined in `ftobjs.h', e.g., */
515 /* `FT_DEBUG_HOOK_TRUETYPE'. */
517 /* debug_hook :: The function used to debug the interpreter. */
520 /* Currently, four debug hook slots are available, but only two (for */
521 /* the TrueType and the Type~1 interpreter) are defined. */
523 /* Since the internal headers of FreeType are no longer installed, */
524 /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
525 /* This is a bug and will be fixed in a forthcoming release. */
528 FT_Set_Debug_Hook( FT_Library library
,
530 FT_DebugHook_Func debug_hook
);
533 /*************************************************************************/
536 /* FT_Add_Default_Modules */
539 /* Add the set of default drivers to a given library object. */
540 /* This is only useful when you create a library object with */
541 /* @FT_New_Library (usually to plug a custom memory manager). */
544 /* library :: A handle to a new library object. */
547 FT_Add_Default_Modules( FT_Library library
);
551 /**************************************************************************
557 * The TrueType Engine
560 * TrueType bytecode support.
563 * This section contains a function used to query the level of TrueType
564 * bytecode support compiled in this version of the library.
569 /**************************************************************************
572 * FT_TrueTypeEngineType
575 * A list of values describing which kind of TrueType bytecode
576 * engine is implemented in a given FT_Library instance. It is used
577 * by the @FT_Get_TrueType_Engine_Type function.
580 * FT_TRUETYPE_ENGINE_TYPE_NONE ::
581 * The library doesn't implement any kind of bytecode interpreter.
583 * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
584 * The library implements a bytecode interpreter that doesn't
585 * support the patented operations of the TrueType virtual machine.
587 * Its main use is to load certain Asian fonts that position and
588 * scale glyph components with bytecode instructions. It produces
589 * bad output for most other fonts.
591 * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
592 * The library implements a bytecode interpreter that covers
593 * the full instruction set of the TrueType virtual machine (this
594 * was governed by patents until May 2010, hence the name).
600 typedef enum FT_TrueTypeEngineType_
602 FT_TRUETYPE_ENGINE_TYPE_NONE
= 0,
603 FT_TRUETYPE_ENGINE_TYPE_UNPATENTED
,
604 FT_TRUETYPE_ENGINE_TYPE_PATENTED
606 } FT_TrueTypeEngineType
;
609 /**************************************************************************
612 * FT_Get_TrueType_Engine_Type
615 * Return an @FT_TrueTypeEngineType value to indicate which level of
616 * the TrueType virtual machine a given library instance supports.
620 * A library instance.
623 * A value indicating which level is supported.
629 FT_EXPORT( FT_TrueTypeEngineType
)
630 FT_Get_TrueType_Engine_Type( FT_Library library
);
638 #endif /* __FTMODAPI_H__ */