1 /****************************************************************************
5 * FreeType modules public interface (specification).
7 * Copyright (C) 1996-2020 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.
23 #include <freetype/freetype.h>
26 #error "freetype.h of FreeType 1 has been loaded!"
27 #error "Please fix the directory search order for header files"
28 #error "so that freetype.h of FreeType 2 is found first."
35 /**************************************************************************
44 * How to add, upgrade, remove, and control modules from FreeType.
47 * The definitions below are used to manage modules within FreeType.
48 * Modules can be added, upgraded, and removed at runtime. Additionally,
49 * some module properties can be controlled also.
51 * Here is a list of possible values of the `module_name` field in the
52 * @FT_Module_Class structure.
75 * Note that the FreeType Cache sub-system is not a FreeType module.
79 * FT_Module_Constructor
80 * FT_Module_Destructor
87 * FT_Add_Default_Modules
91 * FT_Set_Default_Properties
95 * FT_Reference_Library
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 */
120 #define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
121 /* produces LIGHT hints */
124 /* deprecated values */
125 #define ft_module_font_driver FT_MODULE_FONT_DRIVER
126 #define ft_module_renderer FT_MODULE_RENDERER
127 #define ft_module_hinter FT_MODULE_HINTER
128 #define ft_module_styler FT_MODULE_STYLER
130 #define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
131 #define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
132 #define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
133 #define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY
136 typedef FT_Pointer FT_Module_Interface;
139 /**************************************************************************
142 * FT_Module_Constructor
145 * A function used to initialize (not create) a new module object.
149 * The module to initialize.
152 (*FT_Module_Constructor)( FT_Module module );
155 /**************************************************************************
158 * FT_Module_Destructor
161 * A function used to finalize (not destroy) a given module object.
165 * The module to finalize.
168 (*FT_Module_Destructor)( FT_Module module );
171 /**************************************************************************
174 * FT_Module_Requester
177 * A function used to query a given module for a specific interface.
181 * The module to be searched.
184 * The name of the interface in the module.
186 typedef FT_Module_Interface
187 (*FT_Module_Requester)( FT_Module module,
191 /**************************************************************************
197 * The module class descriptor. While being a public structure necessary
198 * for FreeType's module bookkeeping, most of the fields are essentially
199 * internal, not to be used directly by an application.
203 * Bit flags describing the module.
206 * The size of one module object/instance in bytes.
209 * The name of the module.
212 * The version, as a 16.16 fixed number (major.minor).
215 * The version of FreeType this module requires, as a 16.16 fixed
216 * number (major.minor). Starts at version 2.0, i.e., 0x20000.
218 * module_interface ::
219 * A typeless pointer to a structure (which varies between different
220 * modules) that holds the module's interface functions. This is
221 * essentially what `get_interface` returns.
224 * The initializing function.
227 * The finalizing function.
230 * The interface requesting function.
232 typedef struct FT_Module_Class_
234 FT_ULong module_flags;
236 const FT_String* module_name;
237 FT_Fixed module_version;
238 FT_Fixed module_requires;
240 const void* module_interface;
242 FT_Module_Constructor module_init;
243 FT_Module_Destructor module_done;
244 FT_Module_Requester get_interface;
249 /**************************************************************************
255 * Add a new module to a given library instance.
259 * A handle to the library object.
263 * A pointer to class descriptor for the module.
266 * FreeType error code. 0~means success.
269 * An error will be returned if a module already exists by that name, or
270 * if the module requires a version of FreeType that is too great.
272 FT_EXPORT( FT_Error )
273 FT_Add_Module( FT_Library library,
274 const FT_Module_Class* clazz );
277 /**************************************************************************
283 * Find a module by its name.
287 * A handle to the library object.
290 * The module's name (as an ASCII string).
293 * A module handle. 0~if none was found.
296 * FreeType's internal modules aren't documented very well, and you
297 * should look up the source code for details.
299 FT_EXPORT( FT_Module )
300 FT_Get_Module( FT_Library library,
301 const char* module_name );
304 /**************************************************************************
310 * Remove a given module from a library instance.
314 * A handle to a library object.
318 * A handle to a module object.
321 * FreeType error code. 0~means success.
324 * The module object is destroyed by the function in case of success.
326 FT_EXPORT( FT_Error )
327 FT_Remove_Module( FT_Library library,
331 /**************************************************************************
337 * Set a property for a given module.
341 * A handle to the library the module is part of.
347 * The property name. Properties are described in section
350 * Note that only a few modules have properties.
353 * A generic pointer to a variable or structure that gives the new
354 * value of the property. The exact definition of `value` is
355 * dependent on the property; see section @properties.
358 * FreeType error code. 0~means success.
361 * If `module_name` isn't a valid module name, or `property_name`
362 * doesn't specify a valid property, or if `value` doesn't represent a
363 * valid value for the given property, an error is returned.
365 * The following example sets property 'bar' (a simple integer) in
366 * module 'foo' to value~1.
373 * FT_Property_Set( library, "foo", "bar", &bar );
376 * Note that the FreeType Cache sub-system doesn't recognize module
377 * property changes. To avoid glyph lookup confusion within the cache
378 * you should call @FTC_Manager_Reset to completely flush the cache if a
379 * module property gets changed after @FTC_Manager_New has been called.
381 * It is not possible to set properties of the FreeType Cache sub-system
382 * itself with FT_Property_Set; use @FTC_Property_Set instead.
388 FT_EXPORT( FT_Error )
389 FT_Property_Set( FT_Library library,
390 const FT_String* module_name,
391 const FT_String* property_name,
395 /**************************************************************************
401 * Get a module's property value.
405 * A handle to the library the module is part of.
411 * The property name. Properties are described in section
416 * A generic pointer to a variable or structure that gives the value
417 * of the property. The exact definition of `value` is dependent on
418 * the property; see section @properties.
421 * FreeType error code. 0~means success.
424 * If `module_name` isn't a valid module name, or `property_name`
425 * doesn't specify a valid property, or if `value` doesn't represent a
426 * valid value for the given property, an error is returned.
428 * The following example gets property 'baz' (a range) in module 'foo'.
441 * FT_Property_Get( library, "foo", "baz", &baz );
444 * It is not possible to retrieve properties of the FreeType Cache
445 * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
451 FT_EXPORT( FT_Error )
452 FT_Property_Get( FT_Library library,
453 const FT_String* module_name,
454 const FT_String* property_name,
458 /**************************************************************************
461 * FT_Set_Default_Properties
464 * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
465 * set, this function reads the `FREETYPE_PROPERTIES` environment
466 * variable to control driver properties. See section @properties for
469 * If the compilation option is not set, this function does nothing.
471 * `FREETYPE_PROPERTIES` has the following syntax form (broken here into
472 * multiple lines for better readability).
475 * <optional whitespace>
477 * <property-name1> '=' <property-value1>
480 * <property-name2> '=' <property-value2>
487 * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
488 * cff:no-stem-darkening=0 \
489 * autofitter:warping=1
494 * A handle to a new library object.
500 FT_Set_Default_Properties( FT_Library library );
503 /**************************************************************************
506 * FT_Reference_Library
509 * A counter gets initialized to~1 at the time an @FT_Library structure
510 * is created. This function increments the counter. @FT_Done_Library
511 * then only destroys a library if the counter is~1, otherwise it simply
512 * decrements the counter.
514 * This function helps in managing life-cycles of structures that
515 * reference @FT_Library objects.
519 * A handle to a target library object.
522 * FreeType error code. 0~means success.
527 FT_EXPORT( FT_Error )
528 FT_Reference_Library( FT_Library library );
531 /**************************************************************************
537 * This function is used to create a new FreeType library instance from a
538 * given memory object. It is thus possible to use libraries with
539 * distinct memory allocators within the same program. Note, however,
540 * that the used @FT_Memory structure is expected to remain valid for the
541 * life of the @FT_Library object.
543 * Normally, you would call this function (followed by a call to
544 * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a
545 * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to
546 * initialize the FreeType library.
548 * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library
553 * A handle to the original memory object.
557 * A pointer to handle of a new library object.
560 * FreeType error code. 0~means success.
563 * See the discussion of reference counters in the description of
564 * @FT_Reference_Library.
566 FT_EXPORT( FT_Error )
567 FT_New_Library( FT_Memory memory,
568 FT_Library *alibrary );
571 /**************************************************************************
577 * Discard a given library object. This closes all drivers and discards
578 * all resource objects.
582 * A handle to the target library.
585 * FreeType error code. 0~means success.
588 * See the discussion of reference counters in the description of
589 * @FT_Reference_Library.
591 FT_EXPORT( FT_Error )
592 FT_Done_Library( FT_Library library );
595 /**************************************************************************
601 * A drop-in replacement (or rather a wrapper) for the bytecode or
602 * charstring interpreter's main loop function.
604 * Its job is essentially
606 * - to activate debug mode to enforce single-stepping,
608 * - to call the main loop function to interpret the next opcode, and
610 * - to show the changed context to the user.
612 * An example for such a main loop function is `TT_RunIns` (declared in
613 * FreeType's internal header file `src/truetype/ttinterp.h`).
615 * Have a look at the source code of the `ttdebug` FreeType demo program
616 * for an example of a drop-in replacement.
620 * A typeless pointer, to be cast to the main loop function's data
621 * structure (which depends on the font module). For TrueType fonts
622 * it is bytecode interpreter's execution context, `TT_ExecContext`,
623 * which is declared in FreeType's internal header file `tttypes.h`.
626 (*FT_DebugHook_Func)( void* arg );
629 /**************************************************************************
635 * A list of named debug hook indices.
638 * FT_DEBUG_HOOK_TRUETYPE::
639 * This hook index identifies the TrueType bytecode debugger.
641 #define FT_DEBUG_HOOK_TRUETYPE 0
644 /**************************************************************************
650 * Set a debug hook function for debugging the interpreter of a font
653 * While this is a public API function, an application needs access to
654 * FreeType's internal header files to do something useful.
656 * Have a look at the source code of the `ttdebug` FreeType demo program
657 * for an example of its usage.
661 * A handle to the library object.
665 * The index of the debug hook. You should use defined enumeration
666 * macros like @FT_DEBUG_HOOK_TRUETYPE.
669 * The function used to debug the interpreter.
672 * Currently, four debug hook slots are available, but only one (for the
673 * TrueType interpreter) is defined.
676 FT_Set_Debug_Hook( FT_Library library,
678 FT_DebugHook_Func debug_hook );
681 /**************************************************************************
684 * FT_Add_Default_Modules
687 * Add the set of default drivers to a given library object. This is
688 * only useful when you create a library object with @FT_New_Library
689 * (usually to plug a custom memory manager).
693 * A handle to a new library object.
696 FT_Add_Default_Modules( FT_Library library );
700 /**************************************************************************
706 * The TrueType Engine
709 * TrueType bytecode support.
712 * This section contains a function used to query the level of TrueType
713 * bytecode support compiled in this version of the library.
718 /**************************************************************************
721 * FT_TrueTypeEngineType
724 * A list of values describing which kind of TrueType bytecode engine is
725 * implemented in a given FT_Library instance. It is used by the
726 * @FT_Get_TrueType_Engine_Type function.
729 * FT_TRUETYPE_ENGINE_TYPE_NONE ::
730 * The library doesn't implement any kind of bytecode interpreter.
732 * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
733 * Deprecated and removed.
735 * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
736 * The library implements a bytecode interpreter that covers the full
737 * instruction set of the TrueType virtual machine (this was governed
738 * by patents until May 2010, hence the name).
744 typedef enum FT_TrueTypeEngineType_
746 FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
747 FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
748 FT_TRUETYPE_ENGINE_TYPE_PATENTED
750 } FT_TrueTypeEngineType;
753 /**************************************************************************
756 * FT_Get_TrueType_Engine_Type
759 * Return an @FT_TrueTypeEngineType value to indicate which level of the
760 * TrueType virtual machine a given library instance supports.
764 * A library instance.
767 * A value indicating which level is supported.
773 FT_EXPORT( FT_TrueTypeEngineType )
774 FT_Get_TrueType_Engine_Type( FT_Library library );
781 #endif /* FTMODAPI_H_ */