sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftobjs.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftobjs.h
4 *
5 * The FreeType private base classes (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
19 /**************************************************************************
20 *
21 * This file contains the definition of all internal FreeType classes.
22 *
23 */
24
25
30#ifndef FTOBJS_H_
31#define FTOBJS_H_
32
33#include <freetype/ftrender.h>
34#include <freetype/ftsizes.h>
35#include <freetype/ftlcdfil.h>
42
43#ifdef FT_CONFIG_OPTION_INCREMENTAL
44#include <freetype/ftincrem.h>
45#endif
46
47#include "compiler-macros.h"
48
49FT_BEGIN_HEADER
50
51
52 /**************************************************************************
53 *
54 * Some generic definitions.
55 */
56#ifndef TRUE
57#define TRUE 1
58#endif
59
60#ifndef FALSE
61#define FALSE 0
62#endif
63
64#ifndef NULL
65#define NULL (void*)0
66#endif
67
68
69 /**************************************************************************
70 *
71 * The min and max functions missing in C. As usual, be careful not to
72 * write things like FT_MIN( a++, b++ ) to avoid side effects.
73 */
74#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
75#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
76
77#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
78
79 /*
80 * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm.
81 * We use alpha = 1, beta = 3/8, giving us results with a largest error
82 * less than 7% compared to the exact value.
83 */
84#define FT_HYPOT( x, y ) \
85 ( x = FT_ABS( x ), \
86 y = FT_ABS( y ), \
87 x > y ? x + ( 3 * y >> 3 ) \
88 : y + ( 3 * x >> 3 ) )
89
90 /* we use FT_TYPEOF to suppress signedness compilation warnings */
91#define FT_PAD_FLOOR( x, n ) ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
92#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + (n) / 2, n )
93#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + (n) - 1, n )
94
95#define FT_PIX_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 )
96#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
97#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
98
99 /* specialized versions (for signed values) */
100 /* that don't produce run-time errors due to integer overflow */
101#define FT_PAD_ROUND_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \
102 n )
103#define FT_PAD_CEIL_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \
104 n )
105#define FT_PIX_ROUND_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 32 ) )
106#define FT_PIX_CEIL_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 63 ) )
107
108#define FT_PAD_ROUND_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \
109 n )
110#define FT_PAD_CEIL_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \
111 n )
112#define FT_PIX_ROUND_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 32 ) )
113#define FT_PIX_CEIL_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 63 ) )
114
115
116 /*
117 * character classification functions -- since these are used to parse font
118 * files, we must not use those in <ctypes.h> which are locale-dependent
119 */
120#define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U )
121
122#define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \
123 ( (unsigned)(x) - 'a' ) < 6U || \
124 ( (unsigned)(x) - 'A' ) < 6U )
125
126 /* the next two macros assume ASCII representation */
127#define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U )
128#define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U )
129
130#define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) )
131#define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) )
132
133
134 /*************************************************************************/
135 /*************************************************************************/
136 /*************************************************************************/
137 /**** ****/
138 /**** ****/
139 /**** C H A R M A P S ****/
140 /**** ****/
141 /**** ****/
142 /*************************************************************************/
143 /*************************************************************************/
144 /*************************************************************************/
145
146 /* handle to internal charmap object */
147 typedef struct FT_CMapRec_* FT_CMap;
148
149 /* handle to charmap class structure */
150 typedef const struct FT_CMap_ClassRec_* FT_CMap_Class;
151
152 /* internal charmap object structure */
153 typedef struct FT_CMapRec_
154 {
155 FT_CharMapRec charmap;
156 FT_CMap_Class clazz;
157
158 } FT_CMapRec;
159
160 /* typecast any pointer to a charmap handle */
161#define FT_CMAP( x ) ( (FT_CMap)( x ) )
162
163 /* obvious macros */
164#define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id
165#define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id
166#define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding
167#define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face
168
169
170 /* class method definitions */
171 typedef FT_Error
172 (*FT_CMap_InitFunc)( FT_CMap cmap,
173 FT_Pointer init_data );
174
175 typedef void
176 (*FT_CMap_DoneFunc)( FT_CMap cmap );
177
178 typedef FT_UInt
179 (*FT_CMap_CharIndexFunc)( FT_CMap cmap,
180 FT_UInt32 char_code );
181
182 typedef FT_UInt
183 (*FT_CMap_CharNextFunc)( FT_CMap cmap,
184 FT_UInt32 *achar_code );
185
186 typedef FT_UInt
187 (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
188 FT_CMap unicode_cmap,
189 FT_UInt32 char_code,
190 FT_UInt32 variant_selector );
191
192 typedef FT_Int
193 (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
194 FT_UInt32 char_code,
195 FT_UInt32 variant_selector );
196
197 typedef FT_UInt32 *
198 (*FT_CMap_VariantListFunc)( FT_CMap cmap,
199 FT_Memory mem );
200
201 typedef FT_UInt32 *
202 (*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
203 FT_Memory mem,
204 FT_UInt32 char_code );
205
206 typedef FT_UInt32 *
207 (*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
208 FT_Memory mem,
209 FT_UInt32 variant_selector );
210
211
212 typedef struct FT_CMap_ClassRec_
213 {
214 FT_ULong size;
215
216 FT_CMap_InitFunc init;
217 FT_CMap_DoneFunc done;
218 FT_CMap_CharIndexFunc char_index;
219 FT_CMap_CharNextFunc char_next;
220
221 /* Subsequent entries are special ones for format 14 -- the variant */
222 /* selector subtable which behaves like no other */
223
224 FT_CMap_CharVarIndexFunc char_var_index;
225 FT_CMap_CharVarIsDefaultFunc char_var_default;
226 FT_CMap_VariantListFunc variant_list;
227 FT_CMap_CharVariantListFunc charvariant_list;
228 FT_CMap_VariantCharListFunc variantchar_list;
229
230 } FT_CMap_ClassRec;
231
232
233#define FT_DECLARE_CMAP_CLASS( class_ ) \
234 FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
235
236#define FT_DEFINE_CMAP_CLASS( \
237 class_, \
238 size_, \
239 init_, \
240 done_, \
241 char_index_, \
242 char_next_, \
243 char_var_index_, \
244 char_var_default_, \
245 variant_list_, \
246 charvariant_list_, \
247 variantchar_list_ ) \
248 FT_CALLBACK_TABLE_DEF \
249 const FT_CMap_ClassRec class_ = \
250 { \
251 size_, \
252 init_, \
253 done_, \
254 char_index_, \
255 char_next_, \
256 char_var_index_, \
257 char_var_default_, \
258 variant_list_, \
259 charvariant_list_, \
260 variantchar_list_ \
261 };
262
263
264 /* create a new charmap and add it to charmap->face */
265 FT_BASE( FT_Error )
266 FT_CMap_New( FT_CMap_Class clazz,
267 FT_Pointer init_data,
268 FT_CharMap charmap,
269 FT_CMap *acmap );
270
271 /* destroy a charmap and remove it from face's list */
272 FT_BASE( void )
273 FT_CMap_Done( FT_CMap cmap );
274
275
276 /* add LCD padding to CBox */
277 FT_BASE( void )
278 ft_lcd_padding( FT_BBox* cbox,
279 FT_GlyphSlot slot,
280 FT_Render_Mode mode );
281
282
283 /**************************************************************************
284 *
285 * @Function:
286 * find_unicode_charmap
287 *
288 * @Description:
289 * This function finds a Unicode charmap, if there is one. And if there
290 * is more than one, it tries to favour the more extensive one, i.e., one
291 * that supports UCS-4 against those which are limited to the BMP (UCS-2
292 * encoding.)
293 *
294 * If a unicode charmap is found, `face->charmap` is set to it.
295 *
296 * This function is called from `open_face`, from `FT_Select_Charmap(...,
297 * FT_ENCODING_UNICODE)`, and also from `afadjust.c` in the 'autofit'
298 * module.
299 */
300 FT_BASE( FT_Error )
301 find_unicode_charmap( FT_Face face );
302
303
304#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
305
306 typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
307 FT_Byte* weights );
308
309
310 /* This is the default LCD filter, an in-place, 5-tap FIR filter. */
311 FT_BASE( void )
312 ft_lcd_filter_fir( FT_Bitmap* bitmap,
313 FT_LcdFiveTapFilter weights );
314
315#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
316
317 /**************************************************************************
318 *
319 * @struct:
320 * FT_Face_InternalRec
321 *
322 * @description:
323 * This structure contains the internal fields of each FT_Face object.
324 * These fields may change between different releases of FreeType.
325 *
326 * @fields:
327 * max_points ::
328 * The maximum number of points used to store the vectorial outline of
329 * any glyph in this face. If this value cannot be known in advance,
330 * or if the face isn't scalable, this should be set to 0. Only
331 * relevant for scalable formats.
332 *
333 * max_contours ::
334 * The maximum number of contours used to store the vectorial outline
335 * of any glyph in this face. If this value cannot be known in
336 * advance, or if the face isn't scalable, this should be set to 0.
337 * Only relevant for scalable formats.
338 *
339 * transform_matrix ::
340 * A 2x2 matrix of 16.16 coefficients used to transform glyph outlines
341 * after they are loaded from the font. Only used by the convenience
342 * functions.
343 *
344 * transform_delta ::
345 * A translation vector used to transform glyph outlines after they are
346 * loaded from the font. Only used by the convenience functions.
347 *
348 * transform_flags ::
349 * Some flags used to classify the transform. Only used by the
350 * convenience functions.
351 *
352 * services ::
353 * A cache for frequently used services. It should be only accessed
354 * with the macro `FT_FACE_LOOKUP_SERVICE`.
355 *
356 * incremental_interface ::
357 * If non-null, the interface through which glyph data and metrics are
358 * loaded incrementally for faces that do not provide all of this data
359 * when first opened. This field exists only if
360 * @FT_CONFIG_OPTION_INCREMENTAL is defined.
361 *
362 * no_stem_darkening ::
363 * Overrides the module-level default, see @stem-darkening[cff], for
364 * example. FALSE and TRUE toggle stem darkening on and off,
365 * respectively, value~-1 means to use the module/driver default.
366 *
367 * random_seed ::
368 * If positive, override the seed value for the CFF 'random' operator.
369 * Value~0 means to use the font's value. Value~-1 means to use the
370 * CFF driver's default.
371 *
372 * lcd_weights ::
373 * lcd_filter_func ::
374 * These fields specify the LCD filtering weights and callback function
375 * for ClearType-style subpixel rendering.
376 *
377 * refcount ::
378 * A counter initialized to~1 at the time an @FT_Face structure is
379 * created. @FT_Reference_Face increments this counter, and
380 * @FT_Done_Face only destroys a face if the counter is~1, otherwise it
381 * simply decrements it.
382 */
383 typedef struct FT_Face_InternalRec_
384 {
385 FT_Matrix transform_matrix;
386 FT_Vector transform_delta;
387 FT_Int transform_flags;
388
389 FT_ServiceCacheRec services;
390
391#ifdef FT_CONFIG_OPTION_INCREMENTAL
392 FT_Incremental_InterfaceRec* incremental_interface;
393#endif
394
395 FT_Char no_stem_darkening;
396 FT_Int32 random_seed;
397
398#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
399 FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
400 FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
401#endif
402
403 FT_Int refcount;
404
405 } FT_Face_InternalRec;
406
407
408 /**************************************************************************
409 *
410 * @struct:
411 * FT_Slot_InternalRec
412 *
413 * @description:
414 * This structure contains the internal fields of each FT_GlyphSlot
415 * object. These fields may change between different releases of
416 * FreeType.
417 *
418 * @fields:
419 * loader ::
420 * The glyph loader object used to load outlines into the glyph slot.
421 *
422 * flags ::
423 * Possible values are zero or FT_GLYPH_OWN_BITMAP. The latter
424 * indicates that the FT_GlyphSlot structure owns the bitmap buffer.
425 *
426 * glyph_transformed ::
427 * Boolean. Set to TRUE when the loaded glyph must be transformed
428 * through a specific font transformation. This is _not_ the same as
429 * the face transform set through FT_Set_Transform().
430 *
431 * glyph_matrix ::
432 * The 2x2 matrix corresponding to the glyph transformation, if
433 * necessary.
434 *
435 * glyph_delta ::
436 * The 2d translation vector corresponding to the glyph transformation,
437 * if necessary.
438 *
439 * glyph_hints ::
440 * Format-specific glyph hints management.
441 *
442 * load_flags ::
443 * The load flags passed as an argument to @FT_Load_Glyph while
444 * initializing the glyph slot.
445 */
446
447#define FT_GLYPH_OWN_BITMAP 0x1U
448#define FT_GLYPH_OWN_GZIP_SVG 0x2U
449
450 typedef struct FT_Slot_InternalRec_
451 {
452 FT_GlyphLoader loader;
453 FT_UInt flags;
454 FT_Bool glyph_transformed;
455 FT_Matrix glyph_matrix;
456 FT_Vector glyph_delta;
457 void* glyph_hints;
458
459 FT_Int32 load_flags;
460
461 } FT_GlyphSlot_InternalRec;
462
463
464 /**************************************************************************
465 *
466 * @struct:
467 * FT_Size_InternalRec
468 *
469 * @description:
470 * This structure contains the internal fields of each FT_Size object.
471 *
472 * @fields:
473 * module_data ::
474 * Data specific to a driver module.
475 *
476 * autohint_mode ::
477 * The used auto-hinting mode.
478 *
479 * autohint_metrics ::
480 * Metrics used by the auto-hinter.
481 *
482 */
483
484 typedef struct FT_Size_InternalRec_
485 {
486 void* module_data;
487
488 FT_Render_Mode autohint_mode;
489 FT_Size_Metrics autohint_metrics;
490
491 } FT_Size_InternalRec;
492
493
494 /*************************************************************************/
495 /*************************************************************************/
496 /*************************************************************************/
497 /**** ****/
498 /**** ****/
499 /**** M O D U L E S ****/
500 /**** ****/
501 /**** ****/
502 /*************************************************************************/
503 /*************************************************************************/
504 /*************************************************************************/
505
506
507 /**************************************************************************
508 *
509 * @struct:
510 * FT_ModuleRec
511 *
512 * @description:
513 * A module object instance.
514 *
515 * @fields:
516 * clazz ::
517 * A pointer to the module's class.
518 *
519 * library ::
520 * A handle to the parent library object.
521 *
522 * memory ::
523 * A handle to the memory manager.
524 */
525 typedef struct FT_ModuleRec_
526 {
527 const FT_Module_Class* clazz;
528 FT_Library library;
529 FT_Memory memory;
530
531 } FT_ModuleRec;
532
533
534 /* typecast an object to an FT_Module */
535#define FT_MODULE( x ) ( (FT_Module)(x) )
536
537#define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
538#define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
539#define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
540
541
542#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
543 FT_MODULE_FONT_DRIVER )
544
545#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
546 FT_MODULE_RENDERER )
547
548#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
549 FT_MODULE_HINTER )
550
551#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
552 FT_MODULE_STYLER )
553
554#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
555 FT_MODULE_DRIVER_SCALABLE )
556
557#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
558 FT_MODULE_DRIVER_NO_OUTLINES )
559
560#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
561 FT_MODULE_DRIVER_HAS_HINTER )
562
563#define FT_DRIVER_HINTS_LIGHTLY( x ) ( FT_MODULE_CLASS( x )->module_flags & \
564 FT_MODULE_DRIVER_HINTS_LIGHTLY )
565
566
567 /**************************************************************************
568 *
569 * @function:
570 * FT_Get_Module_Interface
571 *
572 * @description:
573 * Finds a module and returns its specific interface as a typeless
574 * pointer.
575 *
576 * @input:
577 * library ::
578 * A handle to the library object.
579 *
580 * module_name ::
581 * The module's name (as an ASCII string).
582 *
583 * @return:
584 * A module-specific interface if available, 0 otherwise.
585 *
586 * @note:
587 * You should better be familiar with FreeType internals to know which
588 * module to look for, and what its interface is :-)
589 */
590 FT_BASE( const void* )
591 FT_Get_Module_Interface( FT_Library library,
592 const char* mod_name );
593
594 FT_BASE( FT_Pointer )
595 ft_module_get_service( FT_Module module,
596 const char* service_id,
597 FT_Bool global );
598
599#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
600 FT_BASE( FT_Error )
601 ft_property_string_set( FT_Library library,
602 const FT_String* module_name,
603 const FT_String* property_name,
604 FT_String* value );
605#endif
606
607 /* */
608
609
610 /*************************************************************************/
611 /*************************************************************************/
612 /*************************************************************************/
613 /**** ****/
614 /**** ****/
615 /**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/
616 /**** ****/
617 /**** ****/
618 /*************************************************************************/
619 /*************************************************************************/
620 /*************************************************************************/
621
622 /* a few macros used to perform easy typecasts with minimal brain damage */
623
624#define FT_FACE( x ) ( (FT_Face)(x) )
625#define FT_SIZE( x ) ( (FT_Size)(x) )
626#define FT_SLOT( x ) ( (FT_GlyphSlot)(x) )
627
628#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
629#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
630#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
631#define FT_FACE_STREAM( x ) FT_FACE( x )->stream
632
633
634 /**************************************************************************
635 *
636 * @function:
637 * FT_New_GlyphSlot
638 *
639 * @description:
640 * It is sometimes useful to have more than one glyph slot for a given
641 * face object. This function is used to create additional slots. All
642 * of them are automatically discarded when the face is destroyed.
643 *
644 * @input:
645 * face ::
646 * A handle to a parent face object.
647 *
648 * @output:
649 * aslot ::
650 * A handle to a new glyph slot object.
651 *
652 * @return:
653 * FreeType error code. 0 means success.
654 */
655 FT_BASE( FT_Error )
656 FT_New_GlyphSlot( FT_Face face,
657 FT_GlyphSlot *aslot );
658
659
660 /**************************************************************************
661 *
662 * @function:
663 * FT_Done_GlyphSlot
664 *
665 * @description:
666 * Destroys a given glyph slot. Remember however that all slots are
667 * automatically destroyed with its parent. Using this function is not
668 * always mandatory.
669 *
670 * @input:
671 * slot ::
672 * A handle to a target glyph slot.
673 */
674 FT_BASE( void )
675 FT_Done_GlyphSlot( FT_GlyphSlot slot );
676
677 /* */
678
679#define FT_REQUEST_WIDTH( req ) \
680 ( (req)->horiResolution \
681 ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
682 : (req)->width )
683
684#define FT_REQUEST_HEIGHT( req ) \
685 ( (req)->vertResolution \
686 ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
687 : (req)->height )
688
689
690 /* Set the metrics according to a bitmap strike. */
691 FT_BASE( void )
692 FT_Select_Metrics( FT_Face face,
693 FT_ULong strike_index );
694
695
696 /* Set the metrics according to a size request. */
697 FT_BASE( FT_Error )
698 FT_Request_Metrics( FT_Face face,
699 FT_Size_Request req );
700
701
702 /* Match a size request against `available_sizes'. */
703 FT_BASE( FT_Error )
704 FT_Match_Size( FT_Face face,
705 FT_Size_Request req,
706 FT_Bool ignore_width,
707 FT_ULong* size_index );
708
709
710 /* Use the horizontal metrics to synthesize the vertical metrics. */
711 /* If `advance' is zero, it is also synthesized. */
712 FT_BASE( void )
713 ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
714 FT_Pos advance );
715
716
717 /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
718 /* was allocated with ft_glyphslot_alloc_bitmap). */
719 FT_BASE( void )
720 ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
721
722
723 /* Preset bitmap metrics of an outline glyphslot prior to rendering */
724 /* and check whether the truncated bbox is too large for rendering. */
725 FT_BASE( FT_Bool )
726 ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
727 FT_Render_Mode mode,
728 const FT_Vector* origin );
729
730 /* Allocate a new bitmap buffer in a glyph slot. */
731 FT_BASE( FT_Error )
732 ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
733 FT_ULong size );
734
735
736 /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
737 /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
738 FT_BASE( void )
739 ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
740 FT_Byte* buffer );
741
742
743 /*************************************************************************/
744 /*************************************************************************/
745 /*************************************************************************/
746 /**** ****/
747 /**** ****/
748 /**** R E N D E R E R S ****/
749 /**** ****/
750 /**** ****/
751 /*************************************************************************/
752 /*************************************************************************/
753 /*************************************************************************/
754
755
756#define FT_RENDERER( x ) ( (FT_Renderer)(x) )
757#define FT_GLYPH( x ) ( (FT_Glyph)(x) )
758#define FT_BITMAP_GLYPH( x ) ( (FT_BitmapGlyph)(x) )
759#define FT_OUTLINE_GLYPH( x ) ( (FT_OutlineGlyph)(x) )
760
761
762 typedef struct FT_RendererRec_
763 {
764 FT_ModuleRec root;
765 FT_Renderer_Class* clazz;
766 FT_Glyph_Format glyph_format;
767 FT_Glyph_Class glyph_class;
768
769 FT_Raster raster;
770 FT_Raster_Render_Func raster_render;
771 FT_Renderer_RenderFunc render;
772
773 } FT_RendererRec;
774
775
776 /*************************************************************************/
777 /*************************************************************************/
778 /*************************************************************************/
779 /**** ****/
780 /**** ****/
781 /**** F O N T D R I V E R S ****/
782 /**** ****/
783 /**** ****/
784 /*************************************************************************/
785 /*************************************************************************/
786 /*************************************************************************/
787
788
789 /* typecast a module into a driver easily */
790#define FT_DRIVER( x ) ( (FT_Driver)(x) )
791
792 /* typecast a module as a driver, and get its driver class */
793#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
794
795
796 /**************************************************************************
797 *
798 * @struct:
799 * FT_DriverRec
800 *
801 * @description:
802 * The root font driver class. A font driver is responsible for managing
803 * and loading font files of a given format.
804 *
805 * @fields:
806 * root ::
807 * Contains the fields of the root module class.
808 *
809 * clazz ::
810 * A pointer to the font driver's class. Note that this is NOT
811 * root.clazz. 'class' wasn't used as it is a reserved word in C++.
812 *
813 * faces_list ::
814 * The list of faces currently opened by this driver.
815 *
816 * glyph_loader ::
817 * Unused. Used to be glyph loader for all faces managed by this
818 * driver.
819 */
820 typedef struct FT_DriverRec_
821 {
822 FT_ModuleRec root;
823 FT_Driver_Class clazz;
824 FT_ListRec faces_list;
825 FT_GlyphLoader glyph_loader;
826
827 } FT_DriverRec;
828
829
830 /*************************************************************************/
831 /*************************************************************************/
832 /*************************************************************************/
833 /**** ****/
834 /**** ****/
835 /**** L I B R A R I E S ****/
836 /**** ****/
837 /**** ****/
838 /*************************************************************************/
839 /*************************************************************************/
840 /*************************************************************************/
841
842
843 /**************************************************************************
844 *
845 * @struct:
846 * FT_LibraryRec
847 *
848 * @description:
849 * The FreeType library class. This is the root of all FreeType data.
850 * Use FT_New_Library() to create a library object, and FT_Done_Library()
851 * to discard it and all child objects.
852 *
853 * @fields:
854 * memory ::
855 * The library's memory object. Manages memory allocation.
856 *
857 * version_major ::
858 * The major version number of the library.
859 *
860 * version_minor ::
861 * The minor version number of the library.
862 *
863 * version_patch ::
864 * The current patch level of the library.
865 *
866 * num_modules ::
867 * The number of modules currently registered within this library.
868 * This is set to 0 for new libraries. New modules are added through
869 * the FT_Add_Module() API function.
870 *
871 * modules ::
872 * A table used to store handles to the currently registered
873 * modules. Note that each font driver contains a list of its opened
874 * faces.
875 *
876 * renderers ::
877 * The list of renderers currently registered within the library.
878 *
879 * cur_renderer ::
880 * The current outline renderer. This is a shortcut used to avoid
881 * parsing the list on each call to FT_Outline_Render(). It is a
882 * handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE
883 * format.
884 *
885 * auto_hinter ::
886 * The auto-hinter module interface.
887 *
888 * debug_hooks ::
889 * An array of four function pointers that allow debuggers to hook into
890 * a font format's interpreter. Currently, only the TrueType bytecode
891 * debugger uses this.
892 *
893 * lcd_weights ::
894 * The LCD filter weights for ClearType-style subpixel rendering.
895 *
896 * lcd_filter_func ::
897 * The LCD filtering callback function for for ClearType-style subpixel
898 * rendering.
899 *
900 * lcd_geometry ::
901 * This array specifies LCD subpixel geometry and controls Harmony LCD
902 * rendering technique, alternative to ClearType.
903 *
904 * pic_container ::
905 * Contains global structs and tables, instead of defining them
906 * globally.
907 *
908 * refcount ::
909 * A counter initialized to~1 at the time an @FT_Library structure is
910 * created. @FT_Reference_Library increments this counter, and
911 * @FT_Done_Library only destroys a library if the counter is~1,
912 * otherwise it simply decrements it.
913 */
914 typedef struct FT_LibraryRec_
915 {
916 FT_Memory memory; /* library's memory manager */
917
918 FT_Int version_major;
919 FT_Int version_minor;
920 FT_Int version_patch;
921
922 FT_UInt num_modules;
923 FT_Module modules[FT_MAX_MODULES]; /* module objects */
924
925 FT_ListRec renderers; /* list of renderers */
926 FT_Renderer cur_renderer; /* current outline renderer */
927 FT_Module auto_hinter;
928
929 FT_DebugHook_Func debug_hooks[4];
930
931#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
932 FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */
933 FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
934#else
935 FT_Vector lcd_geometry[3]; /* RGB subpixel positions */
936#endif
937
938 FT_Int refcount;
939
940 } FT_LibraryRec;
941
942
943 FT_BASE( FT_Renderer )
944 FT_Lookup_Renderer( FT_Library library,
945 FT_Glyph_Format format,
946 FT_ListNode* node );
947
948 FT_BASE( FT_Error )
949 FT_Render_Glyph_Internal( FT_Library library,
950 FT_GlyphSlot slot,
951 FT_Render_Mode render_mode );
952
953 typedef const char*
954 (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
955
956 typedef FT_Error
957 (*FT_Face_GetGlyphNameFunc)( FT_Face face,
958 FT_UInt glyph_index,
959 FT_Pointer buffer,
960 FT_UInt buffer_max );
961
962 typedef FT_UInt
963 (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
964 const FT_String* glyph_name );
965
966
967#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
968
969 /**************************************************************************
970 *
971 * @function:
972 * FT_New_Memory
973 *
974 * @description:
975 * Creates a new memory object.
976 *
977 * @return:
978 * A pointer to the new memory object. 0 in case of error.
979 */
980 FT_BASE( FT_Memory )
981 FT_New_Memory( void );
982
983
984 /**************************************************************************
985 *
986 * @function:
987 * FT_Done_Memory
988 *
989 * @description:
990 * Discards memory manager.
991 *
992 * @input:
993 * memory ::
994 * A handle to the memory manager.
995 */
996 FT_BASE( void )
997 FT_Done_Memory( FT_Memory memory );
998
999#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
1000
1001
1002 /* Define default raster's interface. The default raster is located in */
1003 /* `src/base/ftraster.c'. */
1004 /* */
1005 /* Client applications can register new rasters through the */
1006 /* FT_Set_Raster() API. */
1007
1008#ifndef FT_NO_DEFAULT_RASTER
1009 FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
1010#endif
1011
1012
1013 /**************************************************************************
1014 *
1015 * @macro:
1016 * FT_DEFINE_OUTLINE_FUNCS
1017 *
1018 * @description:
1019 * Used to initialize an instance of FT_Outline_Funcs struct. The struct
1020 * will be allocated in the global scope (or the scope where the macro is
1021 * used).
1022 */
1023#define FT_DEFINE_OUTLINE_FUNCS( \
1024 class_, \
1025 move_to_, \
1026 line_to_, \
1027 conic_to_, \
1028 cubic_to_, \
1029 shift_, \
1030 delta_ ) \
1031 static const FT_Outline_Funcs class_ = \
1032 { \
1033 move_to_, \
1034 line_to_, \
1035 conic_to_, \
1036 cubic_to_, \
1037 shift_, \
1038 delta_ \
1039 };
1040
1041
1042 /**************************************************************************
1043 *
1044 * @macro:
1045 * FT_DEFINE_RASTER_FUNCS
1046 *
1047 * @description:
1048 * Used to initialize an instance of FT_Raster_Funcs struct. The struct
1049 * will be allocated in the global scope (or the scope where the macro is
1050 * used).
1051 */
1052#define FT_DEFINE_RASTER_FUNCS( \
1053 class_, \
1054 glyph_format_, \
1055 raster_new_, \
1056 raster_reset_, \
1057 raster_set_mode_, \
1058 raster_render_, \
1059 raster_done_ ) \
1060 const FT_Raster_Funcs class_ = \
1061 { \
1062 glyph_format_, \
1063 raster_new_, \
1064 raster_reset_, \
1065 raster_set_mode_, \
1066 raster_render_, \
1067 raster_done_ \
1068 };
1069
1070
1071
1072 /**************************************************************************
1073 *
1074 * @macro:
1075 * FT_DEFINE_GLYPH
1076 *
1077 * @description:
1078 * The struct will be allocated in the global scope (or the scope where
1079 * the macro is used).
1080 */
1081#define FT_DECLARE_GLYPH( class_ ) \
1082 FT_CALLBACK_TABLE const FT_Glyph_Class class_;
1083
1084#define FT_DEFINE_GLYPH( \
1085 class_, \
1086 size_, \
1087 format_, \
1088 init_, \
1089 done_, \
1090 copy_, \
1091 transform_, \
1092 bbox_, \
1093 prepare_ ) \
1094 FT_CALLBACK_TABLE_DEF \
1095 const FT_Glyph_Class class_ = \
1096 { \
1097 size_, \
1098 format_, \
1099 init_, \
1100 done_, \
1101 copy_, \
1102 transform_, \
1103 bbox_, \
1104 prepare_ \
1105 };
1106
1107
1108 /**************************************************************************
1109 *
1110 * @macro:
1111 * FT_DECLARE_RENDERER
1112 *
1113 * @description:
1114 * Used to create a forward declaration of a FT_Renderer_Class struct
1115 * instance.
1116 *
1117 * @macro:
1118 * FT_DEFINE_RENDERER
1119 *
1120 * @description:
1121 * Used to initialize an instance of FT_Renderer_Class struct.
1122 *
1123 * The struct will be allocated in the global scope (or the scope where
1124 * the macro is used).
1125 */
1126#define FT_DECLARE_RENDERER( class_ ) \
1127 FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
1128
1129#define FT_DEFINE_RENDERER( \
1130 class_, \
1131 flags_, \
1132 size_, \
1133 name_, \
1134 version_, \
1135 requires_, \
1136 interface_, \
1137 init_, \
1138 done_, \
1139 get_interface_, \
1140 glyph_format_, \
1141 render_glyph_, \
1142 transform_glyph_, \
1143 get_glyph_cbox_, \
1144 set_mode_, \
1145 raster_class_ ) \
1146 FT_CALLBACK_TABLE_DEF \
1147 const FT_Renderer_Class class_ = \
1148 { \
1149 FT_DEFINE_ROOT_MODULE( flags_, \
1150 size_, \
1151 name_, \
1152 version_, \
1153 requires_, \
1154 interface_, \
1155 init_, \
1156 done_, \
1157 get_interface_ ) \
1158 glyph_format_, \
1159 \
1160 render_glyph_, \
1161 transform_glyph_, \
1162 get_glyph_cbox_, \
1163 set_mode_, \
1164 \
1165 raster_class_ \
1166 };
1167
1168
1169 /**************************************************************************
1170 *
1171 * @macro:
1172 * FT_DECLARE_MODULE
1173 *
1174 * @description:
1175 * Used to create a forward declaration of a FT_Module_Class struct
1176 * instance.
1177 *
1178 * @macro:
1179 * FT_DEFINE_MODULE
1180 *
1181 * @description:
1182 * Used to initialize an instance of an FT_Module_Class struct.
1183 *
1184 * The struct will be allocated in the global scope (or the scope where
1185 * the macro is used).
1186 *
1187 * @macro:
1188 * FT_DEFINE_ROOT_MODULE
1189 *
1190 * @description:
1191 * Used to initialize an instance of an FT_Module_Class struct inside
1192 * another struct that contains it or in a function that initializes that
1193 * containing struct.
1194 */
1195#define FT_DECLARE_MODULE( class_ ) \
1196 FT_CALLBACK_TABLE \
1197 const FT_Module_Class class_;
1198
1199#define FT_DEFINE_ROOT_MODULE( \
1200 flags_, \
1201 size_, \
1202 name_, \
1203 version_, \
1204 requires_, \
1205 interface_, \
1206 init_, \
1207 done_, \
1208 get_interface_ ) \
1209 { \
1210 flags_, \
1211 size_, \
1212 \
1213 name_, \
1214 version_, \
1215 requires_, \
1216 \
1217 interface_, \
1218 \
1219 init_, \
1220 done_, \
1221 get_interface_, \
1222 },
1223
1224#define FT_DEFINE_MODULE( \
1225 class_, \
1226 flags_, \
1227 size_, \
1228 name_, \
1229 version_, \
1230 requires_, \
1231 interface_, \
1232 init_, \
1233 done_, \
1234 get_interface_ ) \
1235 FT_CALLBACK_TABLE_DEF \
1236 const FT_Module_Class class_ = \
1237 { \
1238 flags_, \
1239 size_, \
1240 \
1241 name_, \
1242 version_, \
1243 requires_, \
1244 \
1245 interface_, \
1246 \
1247 init_, \
1248 done_, \
1249 get_interface_, \
1250 };
1251
1252
1253FT_END_HEADER
1254
1255#endif /* FTOBJS_H_ */
1256
1257
1258/* END */