sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftmodapi.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftmodapi.h
4 *
5 * FreeType modules public interface (specification).
6 *
7 * Copyright (C) 1996-2025 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
23#ifndef FTMODAPI_H_
24#define FTMODAPI_H_
25
26
27#include <freetype/freetype.h>
28
29#ifdef FREETYPE_H
30#error "freetype.h of FreeType 1 has been loaded!"
31#error "Please fix the directory search order for header files"
32#error "so that freetype.h of FreeType 2 is found first."
33#endif
34
35
36FT_BEGIN_HEADER
37
38
39 /**************************************************************************
40 *
41 * @section:
42 * module_management
43 *
44 * @title:
45 * Module Management
46 *
47 * @abstract:
48 * How to add, upgrade, remove, and control modules from FreeType.
49 *
50 * @description:
51 * The definitions below are used to manage modules within FreeType.
52 * Internal and external modules can be added, upgraded, and removed at
53 * runtime. For example, an alternative renderer or proprietary font
54 * driver can be registered and prioritized. Additionally, some module
55 * properties can also be controlled.
56 *
57 * Here is a list of existing values of the `module_name` field in the
58 * @FT_Module_Class structure.
59 *
60 * ```
61 * autofitter
62 * bdf
63 * cff
64 * gxvalid
65 * otvalid
66 * pcf
67 * pfr
68 * psaux
69 * pshinter
70 * psnames
71 * raster1
72 * sfnt
73 * smooth
74 * truetype
75 * type1
76 * type42
77 * t1cid
78 * winfonts
79 * ```
80 *
81 * Note that the FreeType Cache sub-system is not a FreeType module.
82 *
83 * @order:
84 * FT_Module
85 * FT_Module_Constructor
86 * FT_Module_Destructor
87 * FT_Module_Requester
88 * FT_Module_Class
89 *
90 * FT_Add_Module
91 * FT_Get_Module
92 * FT_Remove_Module
93 * FT_Add_Default_Modules
94 *
95 * FT_FACE_DRIVER_NAME
96 * FT_Property_Set
97 * FT_Property_Get
98 * FT_Set_Default_Properties
99 *
100 * FT_New_Library
101 * FT_Done_Library
102 * FT_Reference_Library
103 *
104 * FT_Renderer
105 * FT_Renderer_Class
106 *
107 * FT_Get_Renderer
108 * FT_Set_Renderer
109 *
110 * FT_Set_Debug_Hook
111 *
112 */
113
114
115 /* module bit flags */
116#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
117#define FT_MODULE_RENDERER 2 /* this module is a renderer */
118#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
119#define FT_MODULE_STYLER 8 /* this module is a styler */
120
121#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
122 /* scalable fonts */
123#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
124 /* support vector outlines */
125#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
126 /* own hinter */
127#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
128 /* produces LIGHT hints */
129
130
131 /* deprecated values */
132#define ft_module_font_driver FT_MODULE_FONT_DRIVER
133#define ft_module_renderer FT_MODULE_RENDERER
134#define ft_module_hinter FT_MODULE_HINTER
135#define ft_module_styler FT_MODULE_STYLER
136
137#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
138#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
139#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
140#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY
141
142
143 typedef FT_Pointer FT_Module_Interface;
144
145
146 /**************************************************************************
147 *
148 * @functype:
149 * FT_Module_Constructor
150 *
151 * @description:
152 * A function used to initialize (not create) a new module object.
153 *
154 * @input:
155 * module ::
156 * The module to initialize.
157 */
158 typedef FT_Error
159 (*FT_Module_Constructor)( FT_Module module );
160
161
162 /**************************************************************************
163 *
164 * @functype:
165 * FT_Module_Destructor
166 *
167 * @description:
168 * A function used to finalize (not destroy) a given module object.
169 *
170 * @input:
171 * module ::
172 * The module to finalize.
173 */
174 typedef void
175 (*FT_Module_Destructor)( FT_Module module );
176
177
178 /**************************************************************************
179 *
180 * @functype:
181 * FT_Module_Requester
182 *
183 * @description:
184 * A function used to query a given module for a specific interface.
185 *
186 * @input:
187 * module ::
188 * The module to be searched.
189 *
190 * name ::
191 * The name of the interface in the module.
192 */
193 typedef FT_Module_Interface
194 (*FT_Module_Requester)( FT_Module module,
195 const char* name );
196
197
198 /**************************************************************************
199 *
200 * @struct:
201 * FT_Module_Class
202 *
203 * @description:
204 * The module class descriptor. While being a public structure necessary
205 * for FreeType's module bookkeeping, most of the fields are essentially
206 * internal, not to be used directly by an application.
207 *
208 * @fields:
209 * module_flags ::
210 * Bit flags describing the module.
211 *
212 * module_size ::
213 * The size of one module object/instance in bytes.
214 *
215 * module_name ::
216 * The name of the module.
217 *
218 * module_version ::
219 * The version, as a 16.16 fixed number (major.minor).
220 *
221 * module_requires ::
222 * The version of FreeType this module requires, as a 16.16 fixed
223 * number (major.minor). Starts at version 2.0, i.e., 0x20000.
224 *
225 * module_interface ::
226 * A typeless pointer to a structure (which varies between different
227 * modules) that holds the module's interface functions. This is
228 * essentially what `get_interface` returns.
229 *
230 * module_init ::
231 * The initializing function.
232 *
233 * module_done ::
234 * The finalizing function.
235 *
236 * get_interface ::
237 * The interface requesting function.
238 */
239 typedef struct FT_Module_Class_
240 {
241 FT_ULong module_flags;
242 FT_Long module_size;
243 const FT_String* module_name;
244 FT_Fixed module_version;
245 FT_Fixed module_requires;
246
247 const void* module_interface;
248
249 FT_Module_Constructor module_init;
250 FT_Module_Destructor module_done;
251 FT_Module_Requester get_interface;
252
253 } FT_Module_Class;
254
255
256 /**************************************************************************
257 *
258 * @function:
259 * FT_Add_Module
260 *
261 * @description:
262 * Add a new module to a given library instance.
263 *
264 * @inout:
265 * library ::
266 * A handle to the library object.
267 *
268 * @input:
269 * clazz ::
270 * A pointer to class descriptor for the module.
271 *
272 * @return:
273 * FreeType error code. 0~means success.
274 *
275 * @note:
276 * An error will be returned if a module already exists by that name, or
277 * if the module requires a version of FreeType that is too great.
278 */
279 FT_EXPORT( FT_Error )
280 FT_Add_Module( FT_Library library,
281 const FT_Module_Class* clazz );
282
283
284 /**************************************************************************
285 *
286 * @function:
287 * FT_Get_Module
288 *
289 * @description:
290 * Find a module by its name.
291 *
292 * @input:
293 * library ::
294 * A handle to the library object.
295 *
296 * module_name ::
297 * The module's name (as an ASCII string).
298 *
299 * @return:
300 * A module handle. 0~if none was found.
301 *
302 * @note:
303 * FreeType's internal modules aren't documented very well, and you
304 * should look up the source code for details.
305 */
306 FT_EXPORT( FT_Module )
307 FT_Get_Module( FT_Library library,
308 const char* module_name );
309
310
311 /**************************************************************************
312 *
313 * @function:
314 * FT_Remove_Module
315 *
316 * @description:
317 * Remove a given module from a library instance.
318 *
319 * @inout:
320 * library ::
321 * A handle to a library object.
322 *
323 * @input:
324 * module ::
325 * A handle to a module object.
326 *
327 * @return:
328 * FreeType error code. 0~means success.
329 *
330 * @note:
331 * The module object is destroyed by the function in case of success.
332 */
333 FT_EXPORT( FT_Error )
334 FT_Remove_Module( FT_Library library,
335 FT_Module module );
336
337
338 /**************************************************************************
339 *
340 * @macro:
341 * FT_FACE_DRIVER_NAME
342 *
343 * @description:
344 * A macro that retrieves the name of a font driver from a face object.
345 *
346 * @note:
347 * The font driver name is a valid `module_name` for @FT_Property_Set
348 * and @FT_Property_Get. This is not the same as @FT_Get_Font_Format.
349 *
350 * @since:
351 * 2.11
352 *
353 */
354#define FT_FACE_DRIVER_NAME( face ) \
355 ( ( *FT_REINTERPRET_CAST( FT_Module_Class**, \
356 ( face )->driver ) )->module_name )
357
358
359 /**************************************************************************
360 *
361 * @function:
362 * FT_Property_Set
363 *
364 * @description:
365 * Set a property for a given module.
366 *
367 * @input:
368 * library ::
369 * A handle to the library the module is part of.
370 *
371 * module_name ::
372 * The module name.
373 *
374 * property_name ::
375 * The property name. Properties are described in section
376 * @properties.
377 *
378 * Note that only a few modules have properties.
379 *
380 * value ::
381 * A generic pointer to a variable or structure that gives the new
382 * value of the property. The exact definition of `value` is
383 * dependent on the property; see section @properties.
384 *
385 * @return:
386 * FreeType error code. 0~means success.
387 *
388 * @note:
389 * If `module_name` isn't a valid module name, or `property_name`
390 * doesn't specify a valid property, or if `value` doesn't represent a
391 * valid value for the given property, an error is returned.
392 *
393 * The following example sets property 'bar' (a simple integer) in
394 * module 'foo' to value~1.
395 *
396 * ```
397 * FT_UInt bar;
398 *
399 *
400 * bar = 1;
401 * FT_Property_Set( library, "foo", "bar", &bar );
402 * ```
403 *
404 * Note that the FreeType Cache sub-system doesn't recognize module
405 * property changes. To avoid glyph lookup confusion within the cache
406 * you should call @FTC_Manager_Reset to completely flush the cache if a
407 * module property gets changed after @FTC_Manager_New has been called.
408 *
409 * It is not possible to set properties of the FreeType Cache sub-system
410 * itself with FT_Property_Set; use @FTC_Property_Set instead.
411 *
412 * @since:
413 * 2.4.11
414 *
415 */
416 FT_EXPORT( FT_Error )
417 FT_Property_Set( FT_Library library,
418 const FT_String* module_name,
419 const FT_String* property_name,
420 const void* value );
421
422
423 /**************************************************************************
424 *
425 * @function:
426 * FT_Property_Get
427 *
428 * @description:
429 * Get a module's property value.
430 *
431 * @input:
432 * library ::
433 * A handle to the library the module is part of.
434 *
435 * module_name ::
436 * The module name.
437 *
438 * property_name ::
439 * The property name. Properties are described in section
440 * @properties.
441 *
442 * @inout:
443 * value ::
444 * A generic pointer to a variable or structure that gives the value
445 * of the property. The exact definition of `value` is dependent on
446 * the property; see section @properties.
447 *
448 * @return:
449 * FreeType error code. 0~means success.
450 *
451 * @note:
452 * If `module_name` isn't a valid module name, or `property_name`
453 * doesn't specify a valid property, or if `value` doesn't represent a
454 * valid value for the given property, an error is returned.
455 *
456 * The following example gets property 'baz' (a range) in module 'foo'.
457 *
458 * ```
459 * typedef range_
460 * {
461 * FT_Int32 min;
462 * FT_Int32 max;
463 *
464 * } range;
465 *
466 * range baz;
467 *
468 *
469 * FT_Property_Get( library, "foo", "baz", &baz );
470 * ```
471 *
472 * It is not possible to retrieve properties of the FreeType Cache
473 * sub-system with FT_Property_Get; use @FTC_Property_Get instead.
474 *
475 * @since:
476 * 2.4.11
477 *
478 */
479 FT_EXPORT( FT_Error )
480 FT_Property_Get( FT_Library library,
481 const FT_String* module_name,
482 const FT_String* property_name,
483 void* value );
484
485
486 /**************************************************************************
487 *
488 * @function:
489 * FT_Set_Default_Properties
490 *
491 * @description:
492 * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
493 * set, this function reads the `FREETYPE_PROPERTIES` environment
494 * variable to control driver properties. See section @properties for
495 * more.
496 *
497 * If the compilation option is not set, this function does nothing.
498 *
499 * `FREETYPE_PROPERTIES` has the following syntax form (broken here into
500 * multiple lines for better readability).
501 *
502 * ```
503 * <optional whitespace>
504 * <module-name1> ':'
505 * <property-name1> '=' <property-value1>
506 * <whitespace>
507 * <module-name2> ':'
508 * <property-name2> '=' <property-value2>
509 * ...
510 * ```
511 *
512 * Example:
513 *
514 * ```
515 * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
516 * cff:no-stem-darkening=0
517 * ```
518 *
519 * @inout:
520 * library ::
521 * A handle to a new library object.
522 *
523 * @since:
524 * 2.8
525 */
526 FT_EXPORT( void )
527 FT_Set_Default_Properties( FT_Library library );
528
529
530 /**************************************************************************
531 *
532 * @function:
533 * FT_Reference_Library
534 *
535 * @description:
536 * A counter gets initialized to~1 at the time an @FT_Library structure
537 * is created. This function increments the counter. @FT_Done_Library
538 * then only destroys a library if the counter is~1, otherwise it simply
539 * decrements the counter.
540 *
541 * This function helps in managing life-cycles of structures that
542 * reference @FT_Library objects.
543 *
544 * @input:
545 * library ::
546 * A handle to a target library object.
547 *
548 * @return:
549 * FreeType error code. 0~means success.
550 *
551 * @since:
552 * 2.4.2
553 */
554 FT_EXPORT( FT_Error )
555 FT_Reference_Library( FT_Library library );
556
557
558 /**************************************************************************
559 *
560 * @function:
561 * FT_New_Library
562 *
563 * @description:
564 * This function is used to create a new FreeType library instance from a
565 * given memory object. It is thus possible to use libraries with
566 * distinct memory allocators within the same program. Note, however,
567 * that the used @FT_Memory structure is expected to remain valid for the
568 * life of the @FT_Library object.
569 *
570 * Normally, you would call this function (followed by a call to
571 * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a
572 * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to
573 * initialize the FreeType library.
574 *
575 * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library
576 * instance.
577 *
578 * @input:
579 * memory ::
580 * A handle to the original memory object.
581 *
582 * @output:
583 * alibrary ::
584 * A pointer to handle of a new library object.
585 *
586 * @return:
587 * FreeType error code. 0~means success.
588 *
589 * @note:
590 * See the discussion of reference counters in the description of
591 * @FT_Reference_Library.
592 */
593 FT_EXPORT( FT_Error )
594 FT_New_Library( FT_Memory memory,
595 FT_Library *alibrary );
596
597
598 /**************************************************************************
599 *
600 * @function:
601 * FT_Done_Library
602 *
603 * @description:
604 * Discard a given library object. This closes all drivers and discards
605 * all resource objects.
606 *
607 * @input:
608 * library ::
609 * A handle to the target library.
610 *
611 * @return:
612 * FreeType error code. 0~means success.
613 *
614 * @note:
615 * See the discussion of reference counters in the description of
616 * @FT_Reference_Library.
617 */
618 FT_EXPORT( FT_Error )
619 FT_Done_Library( FT_Library library );
620
621
622 /**************************************************************************
623 *
624 * @functype:
625 * FT_DebugHook_Func
626 *
627 * @description:
628 * A drop-in replacement (or rather a wrapper) for the bytecode or
629 * charstring interpreter's main loop function.
630 *
631 * Its job is essentially
632 *
633 * - to activate debug mode to enforce single-stepping,
634 *
635 * - to call the main loop function to interpret the next opcode, and
636 *
637 * - to show the changed context to the user.
638 *
639 * An example for such a main loop function is `TT_RunIns` (declared in
640 * FreeType's internal header file `src/truetype/ttinterp.h`).
641 *
642 * Have a look at the source code of the `ttdebug` FreeType demo program
643 * for an example of a drop-in replacement.
644 *
645 * @inout:
646 * arg ::
647 * A typeless pointer, to be cast to the main loop function's data
648 * structure (which depends on the font module). For TrueType fonts
649 * it is bytecode interpreter's execution context, `TT_ExecContext`,
650 * which is declared in FreeType's internal header file `tttypes.h`.
651 */
652 typedef FT_Error
653 (*FT_DebugHook_Func)( void* arg );
654
655
656 /**************************************************************************
657 *
658 * @enum:
659 * FT_DEBUG_HOOK_XXX
660 *
661 * @description:
662 * A list of named debug hook indices.
663 *
664 * @values:
665 * FT_DEBUG_HOOK_TRUETYPE::
666 * This hook index identifies the TrueType bytecode debugger.
667 */
668#define FT_DEBUG_HOOK_TRUETYPE 0
669
670
671 /**************************************************************************
672 *
673 * @function:
674 * FT_Set_Debug_Hook
675 *
676 * @description:
677 * Set a debug hook function for debugging the interpreter of a font
678 * format.
679 *
680 * While this is a public API function, an application needs access to
681 * FreeType's internal header files to do something useful.
682 *
683 * Have a look at the source code of the `ttdebug` FreeType demo program
684 * for an example of its usage.
685 *
686 * @inout:
687 * library ::
688 * A handle to the library object.
689 *
690 * @input:
691 * hook_index ::
692 * The index of the debug hook. You should use defined enumeration
693 * macros like @FT_DEBUG_HOOK_TRUETYPE.
694 *
695 * debug_hook ::
696 * The function used to debug the interpreter.
697 *
698 * @note:
699 * Currently, four debug hook slots are available, but only one (for the
700 * TrueType interpreter) is defined.
701 */
702 FT_EXPORT( void )
703 FT_Set_Debug_Hook( FT_Library library,
704 FT_UInt hook_index,
705 FT_DebugHook_Func debug_hook );
706
707
708 /**************************************************************************
709 *
710 * @function:
711 * FT_Add_Default_Modules
712 *
713 * @description:
714 * Add the set of default drivers to a given library object. This is
715 * only useful when you create a library object with @FT_New_Library
716 * (usually to plug a custom memory manager).
717 *
718 * @inout:
719 * library ::
720 * A handle to a new library object.
721 */
722 FT_EXPORT( void )
723 FT_Add_Default_Modules( FT_Library library );
724
725
726
727 /**************************************************************************
728 *
729 * @section:
730 * truetype_engine
731 *
732 * @title:
733 * The TrueType Engine
734 *
735 * @abstract:
736 * TrueType bytecode support.
737 *
738 * @description:
739 * This section contains a function used to query the level of TrueType
740 * bytecode support compiled in this version of the library.
741 *
742 */
743
744
745 /**************************************************************************
746 *
747 * @enum:
748 * FT_TrueTypeEngineType
749 *
750 * @description:
751 * A list of values describing which kind of TrueType bytecode engine is
752 * implemented in a given FT_Library instance. It is used by the
753 * @FT_Get_TrueType_Engine_Type function.
754 *
755 * @values:
756 * FT_TRUETYPE_ENGINE_TYPE_NONE ::
757 * The library doesn't implement any kind of bytecode interpreter.
758 *
759 * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
760 * Deprecated and removed.
761 *
762 * FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
763 * The library implements a bytecode interpreter that covers the full
764 * instruction set of the TrueType virtual machine (this was governed
765 * by patents until May 2010, hence the name).
766 *
767 * @since:
768 * 2.2
769 *
770 */
771 typedef enum FT_TrueTypeEngineType_
772 {
773 FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
774 FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
775 FT_TRUETYPE_ENGINE_TYPE_PATENTED
776
777 } FT_TrueTypeEngineType;
778
779
780 /**************************************************************************
781 *
782 * @function:
783 * FT_Get_TrueType_Engine_Type
784 *
785 * @description:
786 * Return an @FT_TrueTypeEngineType value to indicate which level of the
787 * TrueType virtual machine a given library instance supports.
788 *
789 * @input:
790 * library ::
791 * A library instance.
792 *
793 * @return:
794 * A value indicating which level is supported.
795 *
796 * @since:
797 * 2.2
798 *
799 */
800 FT_EXPORT( FT_TrueTypeEngineType )
801 FT_Get_TrueType_Engine_Type( FT_Library library );
802
803 /* */
804
805
806FT_END_HEADER
807
808#endif /* FTMODAPI_H_ */
809
810
811/* END */