1 /***************************************************************************/
5 /* The FreeType private base classes (specification). */
7 /* Copyright 1996-2006, 2008, 2010, 2012 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 /*************************************************************************/
21 /* This file contains the definition of all internal FreeType classes. */
23 /*************************************************************************/
32 #include FT_LCD_FILTER_H
33 #include FT_INTERNAL_MEMORY_H
34 #include FT_INTERNAL_GLYPH_LOADER_H
35 #include FT_INTERNAL_DRIVER_H
36 #include FT_INTERNAL_AUTOHINT_H
37 #include FT_INTERNAL_SERVICE_H
38 #include FT_INTERNAL_PIC_H
40 #ifdef FT_CONFIG_OPTION_INCREMENTAL
41 #include FT_INCREMENTAL_H
48 /*************************************************************************/
50 /* Some generic definitions. */
65 /*************************************************************************/
67 /* The min and max functions missing in C. As usual, be careful not to */
68 /* write things like FT_MIN( a++, b++ ) to avoid side effects. */
70 #define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
71 #define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
73 #define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
76 #define FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) )
77 #define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + ((n)/2), n )
78 #define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + ((n)-1), n )
80 #define FT_PIX_FLOOR( x ) ( (x) & ~63 )
81 #define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
82 #define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
86 * Return the highest power of 2 that is <= value; this correspond to
87 * the highest bit in a given 32-bit value.
90 ft_highpow2( FT_UInt32 value );
94 * character classification functions -- since these are used to parse
95 * font files, we must not use those in <ctypes.h> which are
98 #define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U )
100 #define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \
101 ( (unsigned)(x) - 'a' ) < 6U || \
102 ( (unsigned)(x) - 'A' ) < 6U )
104 /* the next two macros assume ASCII representation */
105 #define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U )
106 #define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U )
108 #define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) )
109 #define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) )
112 /*************************************************************************/
113 /*************************************************************************/
114 /*************************************************************************/
117 /**** C H A R M A P S ****/
120 /*************************************************************************/
121 /*************************************************************************/
122 /*************************************************************************/
124 /* handle to internal charmap object */
125 typedef struct FT_CMapRec_* FT_CMap;
127 /* handle to charmap class structure */
128 typedef const struct FT_CMap_ClassRec_* FT_CMap_Class;
130 /* internal charmap object structure */
131 typedef struct FT_CMapRec_
133 FT_CharMapRec charmap;
138 /* typecase any pointer to a charmap handle */
139 #define FT_CMAP( x ) ((FT_CMap)( x ))
142 #define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id
143 #define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id
144 #define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding
145 #define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face
148 /* class method definitions */
150 (*FT_CMap_InitFunc)( FT_CMap cmap,
151 FT_Pointer init_data );
154 (*FT_CMap_DoneFunc)( FT_CMap cmap );
157 (*FT_CMap_CharIndexFunc)( FT_CMap cmap,
158 FT_UInt32 char_code );
161 (*FT_CMap_CharNextFunc)( FT_CMap cmap,
162 FT_UInt32 *achar_code );
165 (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
166 FT_CMap unicode_cmap,
168 FT_UInt32 variant_selector );
171 (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
173 FT_UInt32 variant_selector );
176 (*FT_CMap_VariantListFunc)( FT_CMap cmap,
180 (*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
182 FT_UInt32 char_code );
185 (*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
187 FT_UInt32 variant_selector );
190 typedef struct FT_CMap_ClassRec_
193 FT_CMap_InitFunc init;
194 FT_CMap_DoneFunc done;
195 FT_CMap_CharIndexFunc char_index;
196 FT_CMap_CharNextFunc char_next;
198 /* Subsequent entries are special ones for format 14 -- the variant */
199 /* selector subtable which behaves like no other */
201 FT_CMap_CharVarIndexFunc char_var_index;
202 FT_CMap_CharVarIsDefaultFunc char_var_default;
203 FT_CMap_VariantListFunc variant_list;
204 FT_CMap_CharVariantListFunc charvariant_list;
205 FT_CMap_VariantCharListFunc variantchar_list;
209 #ifndef FT_CONFIG_OPTION_PIC
211 #define FT_DECLARE_CMAP_CLASS(class_) \
212 FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
214 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
215 char_next_, char_var_index_, char_var_default_, variant_list_, \
216 charvariant_list_, variantchar_list_) \
217 FT_CALLBACK_TABLE_DEF \
218 const FT_CMap_ClassRec class_ = \
220 size_, init_, done_, char_index_, char_next_, char_var_index_, \
221 char_var_default_, variant_list_, charvariant_list_, variantchar_list_ \
223 #else /* FT_CONFIG_OPTION_PIC */
225 #define FT_DECLARE_CMAP_CLASS(class_) \
226 void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec* clazz);
228 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_, \
229 char_next_, char_var_index_, char_var_default_, variant_list_, \
230 charvariant_list_, variantchar_list_) \
232 FT_Init_Class_##class_( FT_Library library, \
233 FT_CMap_ClassRec* clazz) \
235 FT_UNUSED(library); \
236 clazz->size = size_; \
237 clazz->init = init_; \
238 clazz->done = done_; \
239 clazz->char_index = char_index_; \
240 clazz->char_next = char_next_; \
241 clazz->char_var_index = char_var_index_; \
242 clazz->char_var_default = char_var_default_; \
243 clazz->variant_list = variant_list_; \
244 clazz->charvariant_list = charvariant_list_; \
245 clazz->variantchar_list = variantchar_list_; \
247 #endif /* FT_CONFIG_OPTION_PIC */
249 /* create a new charmap and add it to charmap->face */
251 FT_CMap_New( FT_CMap_Class clazz,
252 FT_Pointer init_data,
256 /* destroy a charmap and remove it from face's list */
258 FT_CMap_Done( FT_CMap cmap );
261 /*************************************************************************/
264 /* FT_Face_InternalRec */
267 /* This structure contains the internal fields of each FT_Face */
268 /* object. These fields may change between different releases of */
273 /* The maximal number of points used to store the vectorial outline */
274 /* of any glyph in this face. If this value cannot be known in */
275 /* advance, or if the face isn't scalable, this should be set to 0. */
276 /* Only relevant for scalable formats. */
278 /* max_contours :: */
279 /* The maximal number of contours used to store the vectorial */
280 /* outline of any glyph in this face. If this value cannot be */
281 /* known in advance, or if the face isn't scalable, this should be */
282 /* set to 0. Only relevant for scalable formats. */
284 /* transform_matrix :: */
285 /* A 2x2 matrix of 16.16 coefficients used to transform glyph */
286 /* outlines after they are loaded from the font. Only used by the */
287 /* convenience functions. */
289 /* transform_delta :: */
290 /* A translation vector used to transform glyph outlines after they */
291 /* are loaded from the font. Only used by the convenience */
294 /* transform_flags :: */
295 /* Some flags used to classify the transform. Only used by the */
296 /* convenience functions. */
299 /* A cache for frequently used services. It should be only */
300 /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */
302 /* incremental_interface :: */
303 /* If non-null, the interface through which glyph data and metrics */
304 /* are loaded incrementally for faces that do not provide all of */
305 /* this data when first opened. This field exists only if */
306 /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
308 /* ignore_unpatented_hinter :: */
309 /* This boolean flag instructs the glyph loader to ignore the */
310 /* native font hinter, if one is found. This is exclusively used */
311 /* in the case when the unpatented hinter is compiled within the */
315 /* A counter initialized to~1 at the time an @FT_Face structure is */
316 /* created. @FT_Reference_Face increments this counter, and */
317 /* @FT_Done_Face only destroys a face if the counter is~1, */
318 /* otherwise it simply decrements it. */
320 typedef struct FT_Face_InternalRec_
322 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
326 FT_Matrix transform_matrix;
327 FT_Vector transform_delta;
328 FT_Int transform_flags;
330 FT_ServiceCacheRec services;
332 #ifdef FT_CONFIG_OPTION_INCREMENTAL
333 FT_Incremental_InterfaceRec* incremental_interface;
336 FT_Bool ignore_unpatented_hinter;
339 } FT_Face_InternalRec;
342 /*************************************************************************/
345 /* FT_Slot_InternalRec */
348 /* This structure contains the internal fields of each FT_GlyphSlot */
349 /* object. These fields may change between different releases of */
353 /* loader :: The glyph loader object used to load outlines */
354 /* into the glyph slot. */
356 /* flags :: Possible values are zero or */
357 /* FT_GLYPH_OWN_BITMAP. The latter indicates */
358 /* that the FT_GlyphSlot structure owns the */
361 /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */
362 /* must be transformed through a specific */
363 /* font transformation. This is _not_ the same */
364 /* as the face transform set through */
365 /* FT_Set_Transform(). */
367 /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */
368 /* transformation, if necessary. */
370 /* glyph_delta :: The 2d translation vector corresponding to */
371 /* the glyph transformation, if necessary. */
373 /* glyph_hints :: Format-specific glyph hints management. */
376 #define FT_GLYPH_OWN_BITMAP 0x1
378 typedef struct FT_Slot_InternalRec_
380 FT_GlyphLoader loader;
382 FT_Bool glyph_transformed;
383 FT_Matrix glyph_matrix;
384 FT_Vector glyph_delta;
387 } FT_GlyphSlot_InternalRec;
392 /*************************************************************************/
395 /* FT_Size_InternalRec */
398 /* This structure contains the internal fields of each FT_Size */
399 /* object. Currently, it's empty. */
401 /*************************************************************************/
403 typedef struct FT_Size_InternalRec_
407 } FT_Size_InternalRec;
412 /*************************************************************************/
413 /*************************************************************************/
416 /**** M O D U L E S ****/
419 /*************************************************************************/
420 /*************************************************************************/
421 /*************************************************************************/
424 /*************************************************************************/
430 /* A module object instance. */
433 /* clazz :: A pointer to the module's class. */
435 /* library :: A handle to the parent library object. */
437 /* memory :: A handle to the memory manager. */
439 typedef struct FT_ModuleRec_
441 FT_Module_Class* clazz;
448 /* typecast an object to an FT_Module */
449 #define FT_MODULE( x ) ((FT_Module)( x ))
450 #define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
451 #define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
452 #define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
455 #define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
456 FT_MODULE_FONT_DRIVER )
458 #define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
461 #define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
464 #define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
467 #define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
468 FT_MODULE_DRIVER_SCALABLE )
470 #define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
471 FT_MODULE_DRIVER_NO_OUTLINES )
473 #define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
474 FT_MODULE_DRIVER_HAS_HINTER )
477 /*************************************************************************/
480 /* FT_Get_Module_Interface */
483 /* Finds a module and returns its specific interface as a typeless */
487 /* library :: A handle to the library object. */
489 /* module_name :: The module's name (as an ASCII string). */
492 /* A module-specific interface if available, 0 otherwise. */
495 /* You should better be familiar with FreeType internals to know */
496 /* which module to look for, and what its interface is :-) */
498 FT_BASE( const void* )
499 FT_Get_Module_Interface( FT_Library library,
500 const char* mod_name );
502 FT_BASE( FT_Pointer )
503 ft_module_get_service( FT_Module module,
504 const char* service_id );
509 /*************************************************************************/
510 /*************************************************************************/
511 /*************************************************************************/
514 /**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
517 /*************************************************************************/
518 /*************************************************************************/
519 /*************************************************************************/
521 /* a few macros used to perform easy typecasts with minimal brain damage */
523 #define FT_FACE( x ) ((FT_Face)(x))
524 #define FT_SIZE( x ) ((FT_Size)(x))
525 #define FT_SLOT( x ) ((FT_GlyphSlot)(x))
527 #define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
528 #define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
529 #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
530 #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
532 #define FT_SIZE_FACE( x ) FT_SIZE( x )->face
533 #define FT_SLOT_FACE( x ) FT_SLOT( x )->face
535 #define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
536 #define FT_FACE_SIZE( x ) FT_FACE( x )->size
539 /*************************************************************************/
542 /* FT_New_GlyphSlot */
545 /* It is sometimes useful to have more than one glyph slot for a */
546 /* given face object. This function is used to create additional */
547 /* slots. All of them are automatically discarded when the face is */
551 /* face :: A handle to a parent face object. */
554 /* aslot :: A handle to a new glyph slot object. */
557 /* FreeType error code. 0 means success. */
560 FT_New_GlyphSlot( FT_Face face,
561 FT_GlyphSlot *aslot );
564 /*************************************************************************/
567 /* FT_Done_GlyphSlot */
570 /* Destroys a given glyph slot. Remember however that all slots are */
571 /* automatically destroyed with its parent. Using this function is */
572 /* not always mandatory. */
575 /* slot :: A handle to a target glyph slot. */
578 FT_Done_GlyphSlot( FT_GlyphSlot slot );
582 #define FT_REQUEST_WIDTH( req ) \
583 ( (req)->horiResolution \
584 ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
587 #define FT_REQUEST_HEIGHT( req ) \
588 ( (req)->vertResolution \
589 ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
593 /* Set the metrics according to a bitmap strike. */
595 FT_Select_Metrics( FT_Face face,
596 FT_ULong strike_index );
599 /* Set the metrics according to a size request. */
601 FT_Request_Metrics( FT_Face face,
602 FT_Size_Request req );
605 /* Match a size request against `available_sizes'. */
607 FT_Match_Size( FT_Face face,
609 FT_Bool ignore_width,
610 FT_ULong* size_index );
613 /* Use the horizontal metrics to synthesize the vertical metrics. */
614 /* If `advance' is zero, it is also synthesized. */
616 ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
620 /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
621 /* was allocated with ft_glyphslot_alloc_bitmap). */
623 ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
626 /* Allocate a new bitmap buffer in a glyph slot. */
628 ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
632 /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
633 /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
635 ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
639 /*************************************************************************/
640 /*************************************************************************/
641 /*************************************************************************/
644 /**** R E N D E R E R S ****/
647 /*************************************************************************/
648 /*************************************************************************/
649 /*************************************************************************/
652 #define FT_RENDERER( x ) ((FT_Renderer)( x ))
653 #define FT_GLYPH( x ) ((FT_Glyph)( x ))
654 #define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
655 #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
658 typedef struct FT_RendererRec_
661 FT_Renderer_Class* clazz;
662 FT_Glyph_Format glyph_format;
663 FT_Glyph_Class glyph_class;
666 FT_Raster_Render_Func raster_render;
667 FT_Renderer_RenderFunc render;
672 /*************************************************************************/
673 /*************************************************************************/
674 /*************************************************************************/
677 /**** F O N T D R I V E R S ****/
680 /*************************************************************************/
681 /*************************************************************************/
682 /*************************************************************************/
685 /* typecast a module into a driver easily */
686 #define FT_DRIVER( x ) ((FT_Driver)(x))
688 /* typecast a module as a driver, and get its driver class */
689 #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
692 /*************************************************************************/
698 /* The root font driver class. A font driver is responsible for */
699 /* managing and loading font files of a given format. */
702 /* root :: Contains the fields of the root module class. */
704 /* clazz :: A pointer to the font driver's class. Note that */
705 /* this is NOT root.clazz. `class' wasn't used */
706 /* as it is a reserved word in C++. */
708 /* faces_list :: The list of faces currently opened by this */
711 /* glyph_loader :: The glyph loader for all faces managed by this */
712 /* driver. This object isn't defined for unscalable */
715 typedef struct FT_DriverRec_
718 FT_Driver_Class clazz;
719 FT_ListRec faces_list;
720 FT_GlyphLoader glyph_loader;
725 /*************************************************************************/
726 /*************************************************************************/
727 /*************************************************************************/
730 /**** L I B R A R I E S ****/
733 /*************************************************************************/
734 /*************************************************************************/
735 /*************************************************************************/
738 /* This hook is used by the TrueType debugger. It must be set to an */
739 /* alternate truetype bytecode interpreter function. */
740 #define FT_DEBUG_HOOK_TRUETYPE 0
743 /* Set this debug hook to a non-null pointer to force unpatented hinting */
744 /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */
745 /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */
746 /* during debugging. */
747 #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1
750 typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
751 FT_Render_Mode render_mode,
752 FT_Library library );
755 /*************************************************************************/
761 /* The FreeType library class. This is the root of all FreeType */
762 /* data. Use FT_New_Library() to create a library object, and */
763 /* FT_Done_Library() to discard it and all child objects. */
766 /* memory :: The library's memory object. Manages memory */
769 /* version_major :: The major version number of the library. */
771 /* version_minor :: The minor version number of the library. */
773 /* version_patch :: The current patch level of the library. */
775 /* num_modules :: The number of modules currently registered */
776 /* within this library. This is set to 0 for new */
777 /* libraries. New modules are added through the */
778 /* FT_Add_Module() API function. */
780 /* modules :: A table used to store handles to the currently */
781 /* registered modules. Note that each font driver */
782 /* contains a list of its opened faces. */
784 /* renderers :: The list of renderers currently registered */
785 /* within the library. */
787 /* cur_renderer :: The current outline renderer. This is a */
788 /* shortcut used to avoid parsing the list on */
789 /* each call to FT_Outline_Render(). It is a */
790 /* handle to the current renderer for the */
791 /* FT_GLYPH_FORMAT_OUTLINE format. */
793 /* auto_hinter :: XXX */
795 /* raster_pool :: The raster object's render pool. This can */
796 /* ideally be changed dynamically at run-time. */
798 /* raster_pool_size :: The size of the render pool in bytes. */
800 /* debug_hooks :: XXX */
802 /* lcd_filter :: If subpixel rendering is activated, the */
803 /* selected LCD filter mode. */
805 /* lcd_extra :: If subpixel rendering is activated, the number */
806 /* of extra pixels needed for the LCD filter. */
808 /* lcd_weights :: If subpixel rendering is activated, the LCD */
809 /* filter weights, if any. */
811 /* lcd_filter_func :: If subpixel rendering is activated, the LCD */
812 /* filtering callback function. */
814 /* pic_container :: Contains global structs and tables, instead */
815 /* of defining them globallly. */
817 /* refcount :: A counter initialized to~1 at the time an */
818 /* @FT_Library structure is created. */
819 /* @FT_Reference_Library increments this counter, */
820 /* and @FT_Done_Library only destroys a library */
821 /* if the counter is~1, otherwise it simply */
824 typedef struct FT_LibraryRec_
826 FT_Memory memory; /* library's memory manager */
828 FT_Int version_major;
829 FT_Int version_minor;
830 FT_Int version_patch;
833 FT_Module modules[FT_MAX_MODULES]; /* module objects */
835 FT_ListRec renderers; /* list of renderers */
836 FT_Renderer cur_renderer; /* current outline renderer */
837 FT_Module auto_hinter;
839 FT_Byte* raster_pool; /* scan-line conversion */
841 FT_ULong raster_pool_size; /* size of render pool in bytes */
843 FT_DebugHook_Func debug_hooks[4];
845 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
846 FT_LcdFilter lcd_filter;
847 FT_Int lcd_extra; /* number of extra pixels */
848 FT_Byte lcd_weights[7]; /* filter weights, if any */
849 FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
852 #ifdef FT_CONFIG_OPTION_PIC
853 FT_PIC_Container pic_container;
861 FT_BASE( FT_Renderer )
862 FT_Lookup_Renderer( FT_Library library,
863 FT_Glyph_Format format,
867 FT_Render_Glyph_Internal( FT_Library library,
869 FT_Render_Mode render_mode );
872 (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
875 (*FT_Face_GetGlyphNameFunc)( FT_Face face,
878 FT_UInt buffer_max );
881 (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face,
882 FT_String* glyph_name );
885 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
887 /*************************************************************************/
893 /* Creates a new memory object. */
896 /* A pointer to the new memory object. 0 in case of error. */
899 FT_New_Memory( void );
902 /*************************************************************************/
908 /* Discards memory manager. */
911 /* memory :: A handle to the memory manager. */
914 FT_Done_Memory( FT_Memory memory );
916 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
919 /* Define default raster's interface. The default raster is located in */
920 /* `src/base/ftraster.c'. */
922 /* Client applications can register new rasters through the */
923 /* FT_Set_Raster() API. */
925 #ifndef FT_NO_DEFAULT_RASTER
926 FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster;
929 /*************************************************************************/
930 /*************************************************************************/
931 /*************************************************************************/
934 /**** PIC-Support Macros for ftimage.h ****/
937 /*************************************************************************/
938 /*************************************************************************/
939 /*************************************************************************/
942 /*************************************************************************/
945 /* FT_DEFINE_OUTLINE_FUNCS */
948 /* Used to initialize an instance of FT_Outline_Funcs struct. */
949 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
950 /* called with a pre-allocated stracture to be filled. */
951 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
952 /* allocated in the global scope (or the scope where the macro */
955 #ifndef FT_CONFIG_OPTION_PIC
957 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
958 cubic_to_, shift_, delta_) \
959 static const FT_Outline_Funcs class_ = \
961 move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_ \
964 #else /* FT_CONFIG_OPTION_PIC */
966 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_, \
967 cubic_to_, shift_, delta_) \
969 Init_Class_##class_( FT_Outline_Funcs* clazz ) \
971 clazz->move_to = move_to_; \
972 clazz->line_to = line_to_; \
973 clazz->conic_to = conic_to_; \
974 clazz->cubic_to = cubic_to_; \
975 clazz->shift = shift_; \
976 clazz->delta = delta_; \
980 #endif /* FT_CONFIG_OPTION_PIC */
982 /*************************************************************************/
985 /* FT_DEFINE_RASTER_FUNCS */
988 /* Used to initialize an instance of FT_Raster_Funcs struct. */
989 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
990 /* called with a pre-allocated stracture to be filled. */
991 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
992 /* allocated in the global scope (or the scope where the macro */
995 #ifndef FT_CONFIG_OPTION_PIC
997 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
998 raster_reset_, raster_set_mode_, \
999 raster_render_, raster_done_) \
1000 const FT_Raster_Funcs class_ = \
1002 glyph_format_, raster_new_, raster_reset_, \
1003 raster_set_mode_, raster_render_, raster_done_ \
1006 #else /* FT_CONFIG_OPTION_PIC */
1008 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_, \
1009 raster_reset_, raster_set_mode_, raster_render_, raster_done_) \
1011 FT_Init_Class_##class_( FT_Raster_Funcs* clazz ) \
1013 clazz->glyph_format = glyph_format_; \
1014 clazz->raster_new = raster_new_; \
1015 clazz->raster_reset = raster_reset_; \
1016 clazz->raster_set_mode = raster_set_mode_; \
1017 clazz->raster_render = raster_render_; \
1018 clazz->raster_done = raster_done_; \
1021 #endif /* FT_CONFIG_OPTION_PIC */
1023 /*************************************************************************/
1024 /*************************************************************************/
1025 /*************************************************************************/
1028 /**** PIC-Support Macros for ftrender.h ****/
1031 /*************************************************************************/
1032 /*************************************************************************/
1033 /*************************************************************************/
1037 /*************************************************************************/
1040 /* FT_DEFINE_GLYPH */
1043 /* Used to initialize an instance of FT_Glyph_Class struct. */
1044 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
1045 /* called with a pre-allocated stracture to be filled. */
1046 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1047 /* allocated in the global scope (or the scope where the macro */
1050 #ifndef FT_CONFIG_OPTION_PIC
1052 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
1053 transform_, bbox_, prepare_) \
1054 FT_CALLBACK_TABLE_DEF \
1055 const FT_Glyph_Class class_ = \
1057 size_, format_, init_, done_, copy_, transform_, bbox_, prepare_ \
1060 #else /* FT_CONFIG_OPTION_PIC */
1062 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_, \
1063 transform_, bbox_, prepare_) \
1065 FT_Init_Class_##class_( FT_Glyph_Class* clazz ) \
1067 clazz->glyph_size = size_; \
1068 clazz->glyph_format = format_; \
1069 clazz->glyph_init = init_; \
1070 clazz->glyph_done = done_; \
1071 clazz->glyph_copy = copy_; \
1072 clazz->glyph_transform = transform_; \
1073 clazz->glyph_bbox = bbox_; \
1074 clazz->glyph_prepare = prepare_; \
1077 #endif /* FT_CONFIG_OPTION_PIC */
1079 /*************************************************************************/
1082 /* FT_DECLARE_RENDERER */
1085 /* Used to create a forward declaration of a */
1086 /* FT_Renderer_Class stract instance. */
1089 /* FT_DEFINE_RENDERER */
1092 /* Used to initialize an instance of FT_Renderer_Class struct. */
1094 /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
1095 /* to called with a pointer where the allocated stracture is returned.*/
1096 /* And when it is no longer needed a Destroy function needs */
1097 /* to be called to release that allocation. */
1098 /* fcinit.c (ft_create_default_module_classes) already contains */
1099 /* a mechanism to call these functions for the default modules */
1100 /* described in ftmodule.h */
1102 /* Notice that the created Create and Destroy functions call */
1103 /* pic_init and pic_free function to allow you to manually allocate */
1104 /* and initialize any additional global data, like module specific */
1105 /* interface, and put them in the global pic container defined in */
1106 /* ftpic.h. if you don't need them just implement the functions as */
1107 /* empty to resolve the link error. Also the pic_init and pic_free */
1108 /* functions should be declared in pic.h, to be referred by renderer */
1109 /* definition calling FT_DEFINE_RENDERER() in following. */
1111 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1112 /* allocated in the global scope (or the scope where the macro */
1115 #ifndef FT_CONFIG_OPTION_PIC
1117 #define FT_DECLARE_RENDERER(class_) \
1118 FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
1120 #define FT_DEFINE_RENDERER(class_, \
1121 flags_, size_, name_, version_, requires_, \
1122 interface_, init_, done_, get_interface_, \
1123 glyph_format_, render_glyph_, transform_glyph_, \
1124 get_glyph_cbox_, set_mode_, raster_class_ ) \
1125 FT_CALLBACK_TABLE_DEF \
1126 const FT_Renderer_Class class_ = \
1128 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
1129 interface_,init_,done_,get_interface_) \
1140 #else /* FT_CONFIG_OPTION_PIC */
1142 #define FT_DECLARE_RENDERER(class_) FT_DECLARE_MODULE(class_)
1144 #define FT_DEFINE_RENDERER(class_, \
1145 flags_, size_, name_, version_, requires_, \
1146 interface_, init_, done_, get_interface_, \
1147 glyph_format_, render_glyph_, transform_glyph_, \
1148 get_glyph_cbox_, set_mode_, raster_class_ ) \
1151 FT_Destroy_Class_##class_( FT_Library library, \
1152 FT_Module_Class* clazz ) \
1154 FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
1155 FT_Memory memory = library->memory; \
1156 class_##_pic_free( library ); \
1158 FT_FREE( rclazz ); \
1162 FT_Create_Class_##class_( FT_Library library, \
1163 FT_Module_Class** output_class ) \
1165 FT_Renderer_Class* clazz; \
1167 FT_Memory memory = library->memory; \
1169 if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
1172 error = class_##_pic_init( library ); \
1179 FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_, \
1180 interface_,init_,done_,get_interface_) \
1182 clazz->glyph_format = glyph_format_; \
1184 clazz->render_glyph = render_glyph_; \
1185 clazz->transform_glyph = transform_glyph_; \
1186 clazz->get_glyph_cbox = get_glyph_cbox_; \
1187 clazz->set_mode = set_mode_; \
1189 clazz->raster_class = raster_class_; \
1191 *output_class = (FT_Module_Class*)clazz; \
1197 #endif /* FT_CONFIG_OPTION_PIC */
1199 /*************************************************************************/
1200 /*************************************************************************/
1201 /*************************************************************************/
1204 /**** PIC-Support Macros for ftmodapi.h ****/
1207 /*************************************************************************/
1208 /*************************************************************************/
1209 /*************************************************************************/
1212 #ifdef FT_CONFIG_OPTION_PIC
1214 /*************************************************************************/
1217 /* FT_Module_Creator */
1220 /* A function used to create (allocate) a new module class object. */
1221 /* The object's members are initialized, but the module itself is */
1225 /* memory :: A handle to the memory manager. */
1226 /* output_class :: Initialized with the newly allocated class. */
1229 (*FT_Module_Creator)( FT_Memory memory,
1230 FT_Module_Class** output_class );
1232 /*************************************************************************/
1235 /* FT_Module_Destroyer */
1238 /* A function used to destroy (deallocate) a module class object. */
1241 /* memory :: A handle to the memory manager. */
1242 /* clazz :: Module class to destroy. */
1245 (*FT_Module_Destroyer)( FT_Memory memory,
1246 FT_Module_Class* clazz );
1250 /*************************************************************************/
1253 /* FT_DECLARE_MODULE */
1256 /* Used to create a forward declaration of a */
1257 /* FT_Module_Class stract instance. */
1260 /* FT_DEFINE_MODULE */
1263 /* Used to initialize an instance of FT_Module_Class struct. */
1265 /* When FT_CONFIG_OPTION_PIC is defined a Create funtion will need */
1266 /* to called with a pointer where the allocated stracture is returned.*/
1267 /* And when it is no longer needed a Destroy function needs */
1268 /* to be called to release that allocation. */
1269 /* fcinit.c (ft_create_default_module_classes) already contains */
1270 /* a mechanism to call these functions for the default modules */
1271 /* described in ftmodule.h */
1273 /* Notice that the created Create and Destroy functions call */
1274 /* pic_init and pic_free function to allow you to manually allocate */
1275 /* and initialize any additional global data, like module specific */
1276 /* interface, and put them in the global pic container defined in */
1277 /* ftpic.h. if you don't need them just implement the functions as */
1278 /* empty to resolve the link error. Also the pic_init and pic_free */
1279 /* functions should be declared in pic.h, to be referred by module */
1280 /* definition calling FT_DEFINE_MODULE() in following. */
1282 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1283 /* allocated in the global scope (or the scope where the macro */
1287 /* FT_DEFINE_ROOT_MODULE */
1290 /* Used to initialize an instance of FT_Module_Class struct inside */
1291 /* another stract that contains it or in a function that initializes */
1292 /* that containing stract */
1294 #ifndef FT_CONFIG_OPTION_PIC
1296 #define FT_DECLARE_MODULE(class_) \
1298 const FT_Module_Class class_; \
1300 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
1301 interface_, init_, done_, get_interface_) \
1317 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
1318 interface_, init_, done_, get_interface_) \
1319 FT_CALLBACK_TABLE_DEF \
1320 const FT_Module_Class class_ = \
1337 #else /* FT_CONFIG_OPTION_PIC */
1339 #define FT_DECLARE_MODULE(class_) \
1340 FT_Error FT_Create_Class_##class_( FT_Library library, \
1341 FT_Module_Class** output_class ); \
1342 void FT_Destroy_Class_##class_( FT_Library library, \
1343 FT_Module_Class* clazz );
1345 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_, \
1346 interface_, init_, done_, get_interface_) \
1347 clazz->root.module_flags = flags_; \
1348 clazz->root.module_size = size_; \
1349 clazz->root.module_name = name_; \
1350 clazz->root.module_version = version_; \
1351 clazz->root.module_requires = requires_; \
1353 clazz->root.module_interface = interface_; \
1355 clazz->root.module_init = init_; \
1356 clazz->root.module_done = done_; \
1357 clazz->root.get_interface = get_interface_;
1359 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_, \
1360 interface_, init_, done_, get_interface_) \
1363 FT_Destroy_Class_##class_( FT_Library library, \
1364 FT_Module_Class* clazz ) \
1366 FT_Memory memory = library->memory; \
1367 class_##_pic_free( library ); \
1373 FT_Create_Class_##class_( FT_Library library, \
1374 FT_Module_Class** output_class ) \
1376 FT_Memory memory = library->memory; \
1377 FT_Module_Class* clazz; \
1380 if ( FT_ALLOC( clazz, sizeof(*clazz) ) ) \
1382 error = class_##_pic_init( library ); \
1389 clazz->module_flags = flags_; \
1390 clazz->module_size = size_; \
1391 clazz->module_name = name_; \
1392 clazz->module_version = version_; \
1393 clazz->module_requires = requires_; \
1395 clazz->module_interface = interface_; \
1397 clazz->module_init = init_; \
1398 clazz->module_done = done_; \
1399 clazz->get_interface = get_interface_; \
1401 *output_class = clazz; \
1405 #endif /* FT_CONFIG_OPTION_PIC */
1410 #endif /* __FTOBJS_H__ */