1 /***************************************************************************/
5 /* FreeType modules public interface (specification). */
7 /* Copyright 1996-2015 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. */
68 /* smooth, smooth-lcd, smooth-lcdv */
76 /* Note that the FreeType Cache sub-system is not a FreeType module. */
80 /* FT_Module_Constructor */
81 /* FT_Module_Destructor */
82 /* FT_Module_Requester */
87 /* FT_Remove_Module */
88 /* FT_Add_Default_Modules */
95 /* FT_Reference_Library */
98 /* FT_Renderer_Class */
100 /* FT_Get_Renderer */
101 /* FT_Set_Renderer */
103 /* FT_Set_Debug_Hook */
105 /*************************************************************************/
108 /* module bit flags */
109 #define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
110 #define FT_MODULE_RENDERER 2 /* this module is a renderer */
111 #define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
112 #define FT_MODULE_STYLER 8 /* this module is a styler */
114 #define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
116 #define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
117 /* support vector outlines */
118 #define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
122 /* deprecated values */
123 #define ft_module_font_driver FT_MODULE_FONT_DRIVER
124 #define ft_module_renderer FT_MODULE_RENDERER
125 #define ft_module_hinter FT_MODULE_HINTER
126 #define ft_module_styler FT_MODULE_STYLER
128 #define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
129 #define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
130 #define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
133 typedef FT_Pointer FT_Module_Interface
;
136 /*************************************************************************/
139 /* FT_Module_Constructor */
142 /* A function used to initialize (not create) a new module object. */
145 /* module :: The module to initialize. */
148 (*FT_Module_Constructor
)( FT_Module module
);
151 /*************************************************************************/
154 /* FT_Module_Destructor */
157 /* A function used to finalize (not destroy) a given module object. */
160 /* module :: The module to finalize. */
163 (*FT_Module_Destructor
)( FT_Module module
);
166 /*************************************************************************/
169 /* FT_Module_Requester */
172 /* A function used to query a given module for a specific interface. */
175 /* module :: The module to be searched. */
177 /* name :: The name of the interface in the module. */
179 typedef FT_Module_Interface
180 (*FT_Module_Requester
)( FT_Module module
,
184 /*************************************************************************/
187 /* FT_Module_Class */
190 /* The module class descriptor. */
193 /* module_flags :: Bit flags describing the module. */
195 /* module_size :: The size of one module object/instance in */
198 /* module_name :: The name of the module. */
200 /* module_version :: The version, as a 16.16 fixed number */
203 /* module_requires :: The version of FreeType this module requires, */
204 /* as a 16.16 fixed number (major.minor). Starts */
205 /* at version 2.0, i.e., 0x20000. */
207 /* module_init :: The initializing function. */
209 /* module_done :: The finalizing function. */
211 /* get_interface :: The interface requesting function. */
213 typedef struct FT_Module_Class_
215 FT_ULong module_flags
;
217 const FT_String
* module_name
;
218 FT_Fixed module_version
;
219 FT_Fixed module_requires
;
221 const void* module_interface
;
223 FT_Module_Constructor module_init
;
224 FT_Module_Destructor module_done
;
225 FT_Module_Requester get_interface
;
230 /*************************************************************************/
236 /* Add a new module to a given library instance. */
239 /* library :: A handle to the library object. */
242 /* clazz :: A pointer to class descriptor for the module. */
245 /* FreeType error code. 0~means success. */
248 /* An error will be returned if a module already exists by that name, */
249 /* or if the module requires a version of FreeType that is too great. */
251 FT_EXPORT( FT_Error
)
252 FT_Add_Module( FT_Library library
,
253 const FT_Module_Class
* clazz
);
256 /*************************************************************************/
262 /* Find a module by its name. */
265 /* library :: A handle to the library object. */
267 /* module_name :: The module's name (as an ASCII string). */
270 /* A module handle. 0~if none was found. */
273 /* FreeType's internal modules aren't documented very well, and you */
274 /* should look up the source code for details. */
276 FT_EXPORT( FT_Module
)
277 FT_Get_Module( FT_Library library
,
278 const char* module_name
);
281 /*************************************************************************/
284 /* FT_Remove_Module */
287 /* Remove a given module from a library instance. */
290 /* library :: A handle to a library object. */
293 /* module :: A handle to a module object. */
296 /* FreeType error code. 0~means success. */
299 /* The module object is destroyed by the function in case of success. */
301 FT_EXPORT( FT_Error
)
302 FT_Remove_Module( FT_Library library
,
306 /**********************************************************************
312 * Set a property for a given module.
316 * A handle to the library the module is part of.
322 * The property name. Properties are described in the `Synopsis'
323 * subsection of the module's documentation.
325 * Note that only a few modules have properties.
328 * A generic pointer to a variable or structure that gives the new
329 * value of the property. The exact definition of `value' is
330 * dependent on the property; see the `Synopsis' subsection of the
331 * module's documentation.
334 * FreeType error code. 0~means success.
337 * If `module_name' isn't a valid module name, or `property_name'
338 * doesn't specify a valid property, or if `value' doesn't represent a
339 * valid value for the given property, an error is returned.
341 * The following example sets property `bar' (a simple integer) in
342 * module `foo' to value~1.
349 * FT_Property_Set( library, "foo", "bar", &bar );
352 * Note that the FreeType Cache sub-system doesn't recognize module
353 * property changes. To avoid glyph lookup confusion within the cache
354 * you should call @FTC_Manager_Reset to completely flush the cache if
355 * a module property gets changed after @FTC_Manager_New has been
358 * It is not possible to set properties of the FreeType Cache
359 * sub-system itself with FT_Property_Set; use @FTC_Property_Set
366 FT_EXPORT( FT_Error
)
367 FT_Property_Set( FT_Library library
,
368 const FT_String
* module_name
,
369 const FT_String
* property_name
,
373 /**********************************************************************
379 * Get a module's property value.
383 * A handle to the library the module is part of.
389 * The property name. Properties are described in the `Synopsis'
390 * subsection of the module's documentation.
394 * A generic pointer to a variable or structure that gives the
395 * value of the property. The exact definition of `value' is
396 * dependent on the property; see the `Synopsis' subsection of the
397 * module's documentation.
400 * FreeType error code. 0~means success.
403 * If `module_name' isn't a valid module name, or `property_name'
404 * doesn't specify a valid property, or if `value' doesn't represent a
405 * valid value for the given property, an error is returned.
407 * The following example gets property `baz' (a range) in module `foo'.
420 * FT_Property_Get( library, "foo", "baz", &baz );
423 * It is not possible to retrieve properties of the FreeType Cache
424 * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
430 FT_EXPORT( FT_Error
)
431 FT_Property_Get( FT_Library library
,
432 const FT_String
* module_name
,
433 const FT_String
* property_name
,
437 /*************************************************************************/
440 /* FT_Reference_Library */
443 /* A counter gets initialized to~1 at the time an @FT_Library */
444 /* structure is created. This function increments the counter. */
445 /* @FT_Done_Library then only destroys a library if the counter is~1, */
446 /* otherwise it simply decrements the counter. */
448 /* This function helps in managing life-cycles of structures that */
449 /* reference @FT_Library objects. */
452 /* library :: A handle to a target library object. */
455 /* FreeType error code. 0~means success. */
460 FT_EXPORT( FT_Error
)
461 FT_Reference_Library( FT_Library library
);
464 /*************************************************************************/
470 /* This function is used to create a new FreeType library instance */
471 /* from a given memory object. It is thus possible to use libraries */
472 /* with distinct memory allocators within the same program. Note, */
473 /* however, that the used @FT_Memory structure is expected to remain */
474 /* valid for the life of the @FT_Library object. */
476 /* Normally, you would call this function (followed by a call to */
477 /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
478 /* instead of @FT_Init_FreeType to initialize the FreeType library. */
480 /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
481 /* library instance. */
484 /* memory :: A handle to the original memory object. */
487 /* alibrary :: A pointer to handle of a new library object. */
490 /* FreeType error code. 0~means success. */
493 /* See the discussion of reference counters in the description of */
494 /* @FT_Reference_Library. */
496 FT_EXPORT( FT_Error
)
497 FT_New_Library( FT_Memory memory
,
498 FT_Library
*alibrary
);
501 /*************************************************************************/
504 /* FT_Done_Library */
507 /* Discard a given library object. This closes all drivers and */
508 /* discards all resource objects. */
511 /* library :: A handle to the target library. */
514 /* FreeType error code. 0~means success. */
517 /* See the discussion of reference counters in the description of */
518 /* @FT_Reference_Library. */
520 FT_EXPORT( FT_Error
)
521 FT_Done_Library( FT_Library library
);
526 (*FT_DebugHook_Func
)( void* arg
);
529 /*************************************************************************/
532 /* FT_Set_Debug_Hook */
535 /* Set a debug hook function for debugging the interpreter of a font */
539 /* library :: A handle to the library object. */
542 /* hook_index :: The index of the debug hook. You should use the */
543 /* values defined in `ftobjs.h', e.g., */
544 /* `FT_DEBUG_HOOK_TRUETYPE'. */
546 /* debug_hook :: The function used to debug the interpreter. */
549 /* Currently, four debug hook slots are available, but only two (for */
550 /* the TrueType and the Type~1 interpreter) are defined. */
552 /* Since the internal headers of FreeType are no longer installed, */
553 /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
554 /* This is a bug and will be fixed in a forthcoming release. */
557 FT_Set_Debug_Hook( FT_Library library
,
559 FT_DebugHook_Func debug_hook
);
562 /*************************************************************************/
565 /* FT_Add_Default_Modules */
568 /* Add the set of default drivers to a given library object. */
569 /* This is only useful when you create a library object with */
570 /* @FT_New_Library (usually to plug a custom memory manager). */
573 /* library :: A handle to a new library object. */
576 FT_Add_Default_Modules( FT_Library library
);
580 /**************************************************************************
586 * The TrueType Engine
589 * TrueType bytecode support.
592 * This section contains a function used to query the level of TrueType
593 * bytecode support compiled in this version of the library.
598 /**************************************************************************
601 * FT_TrueTypeEngineType
604 * A list of values describing which kind of TrueType bytecode
605 * engine is implemented in a given FT_Library instance. It is used
606 * by the @FT_Get_TrueType_Engine_Type function.
609 * FT_TRUETYPE_ENGINE_TYPE_NONE ::
610 * The library doesn't implement any kind of bytecode interpreter.
612 * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
613 * The library implements a bytecode interpreter that doesn't
614 * support the patented operations of the TrueType virtual machine.
616 * Its main use is to load certain Asian fonts that position and
617 * scale glyph components with bytecode instructions. It produces
618 * bad output for most other fonts.
620 * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
621 * The library implements a bytecode interpreter that covers
622 * the full instruction set of the TrueType virtual machine (this
623 * was governed by patents until May 2010, hence the name).
629 typedef enum FT_TrueTypeEngineType_
631 FT_TRUETYPE_ENGINE_TYPE_NONE
= 0,
632 FT_TRUETYPE_ENGINE_TYPE_UNPATENTED
,
633 FT_TRUETYPE_ENGINE_TYPE_PATENTED
635 } FT_TrueTypeEngineType
;
638 /**************************************************************************
641 * FT_Get_TrueType_Engine_Type
644 * Return an @FT_TrueTypeEngineType value to indicate which level of
645 * the TrueType virtual machine a given library instance supports.
649 * A library instance.
652 * A value indicating which level is supported.
658 FT_EXPORT( FT_TrueTypeEngineType
)
659 FT_Get_TrueType_Engine_Type( FT_Library library
);
666 #endif /* __FTMODAPI_H__ */