1 /***************************************************************************/
5 /* The FreeType private base classes (specification). */
7 /* Copyright 1996-2006, 2008, 2010, 2012-2013 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
;
210 #ifndef FT_CONFIG_OPTION_PIC
212 #define FT_DECLARE_CMAP_CLASS( class_ ) \
213 FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
215 #define FT_DEFINE_CMAP_CLASS( \
226 variantchar_list_ ) \
227 FT_CALLBACK_TABLE_DEF \
228 const FT_CMap_ClassRec class_ = \
242 #else /* FT_CONFIG_OPTION_PIC */
244 #define FT_DECLARE_CMAP_CLASS( class_ ) \
246 FT_Init_Class_ ## class_( FT_Library library, \
247 FT_CMap_ClassRec* clazz );
249 #define FT_DEFINE_CMAP_CLASS( \
260 variantchar_list_ ) \
262 FT_Init_Class_ ## class_( FT_Library library, \
263 FT_CMap_ClassRec* clazz ) \
265 FT_UNUSED( library ); \
267 clazz->size = size_; \
268 clazz->init = init_; \
269 clazz->done = done_; \
270 clazz->char_index = char_index_; \
271 clazz->char_next = char_next_; \
272 clazz->char_var_index = char_var_index_; \
273 clazz->char_var_default = char_var_default_; \
274 clazz->variant_list = variant_list_; \
275 clazz->charvariant_list = charvariant_list_; \
276 clazz->variantchar_list = variantchar_list_; \
279 #endif /* FT_CONFIG_OPTION_PIC */
282 /* create a new charmap and add it to charmap->face */
284 FT_CMap_New( FT_CMap_Class clazz
,
285 FT_Pointer init_data
,
289 /* destroy a charmap and remove it from face's list */
291 FT_CMap_Done( FT_CMap cmap
);
294 /*************************************************************************/
297 /* FT_Face_InternalRec */
300 /* This structure contains the internal fields of each FT_Face */
301 /* object. These fields may change between different releases of */
306 /* The maximum number of points used to store the vectorial outline */
307 /* of any glyph in this face. If this value cannot be known in */
308 /* advance, or if the face isn't scalable, this should be set to 0. */
309 /* Only relevant for scalable formats. */
311 /* max_contours :: */
312 /* The maximum number of contours used to store the vectorial */
313 /* outline of any glyph in this face. If this value cannot be */
314 /* known in advance, or if the face isn't scalable, this should be */
315 /* set to 0. Only relevant for scalable formats. */
317 /* transform_matrix :: */
318 /* A 2x2 matrix of 16.16 coefficients used to transform glyph */
319 /* outlines after they are loaded from the font. Only used by the */
320 /* convenience functions. */
322 /* transform_delta :: */
323 /* A translation vector used to transform glyph outlines after they */
324 /* are loaded from the font. Only used by the convenience */
327 /* transform_flags :: */
328 /* Some flags used to classify the transform. Only used by the */
329 /* convenience functions. */
332 /* A cache for frequently used services. It should be only */
333 /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */
335 /* incremental_interface :: */
336 /* If non-null, the interface through which glyph data and metrics */
337 /* are loaded incrementally for faces that do not provide all of */
338 /* this data when first opened. This field exists only if */
339 /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
341 /* ignore_unpatented_hinter :: */
342 /* This boolean flag instructs the glyph loader to ignore the */
343 /* native font hinter, if one is found. This is exclusively used */
344 /* in the case when the unpatented hinter is compiled within the */
348 /* A counter initialized to~1 at the time an @FT_Face structure is */
349 /* created. @FT_Reference_Face increments this counter, and */
350 /* @FT_Done_Face only destroys a face if the counter is~1, */
351 /* otherwise it simply decrements it. */
353 typedef struct FT_Face_InternalRec_
355 FT_Matrix transform_matrix
;
356 FT_Vector transform_delta
;
357 FT_Int transform_flags
;
359 FT_ServiceCacheRec services
;
361 #ifdef FT_CONFIG_OPTION_INCREMENTAL
362 FT_Incremental_InterfaceRec
* incremental_interface
;
365 FT_Bool ignore_unpatented_hinter
;
368 } FT_Face_InternalRec
;
371 /*************************************************************************/
374 /* FT_Slot_InternalRec */
377 /* This structure contains the internal fields of each FT_GlyphSlot */
378 /* object. These fields may change between different releases of */
382 /* loader :: The glyph loader object used to load outlines */
383 /* into the glyph slot. */
385 /* flags :: Possible values are zero or */
386 /* FT_GLYPH_OWN_BITMAP. The latter indicates */
387 /* that the FT_GlyphSlot structure owns the */
390 /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */
391 /* must be transformed through a specific */
392 /* font transformation. This is _not_ the same */
393 /* as the face transform set through */
394 /* FT_Set_Transform(). */
396 /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */
397 /* transformation, if necessary. */
399 /* glyph_delta :: The 2d translation vector corresponding to */
400 /* the glyph transformation, if necessary. */
402 /* glyph_hints :: Format-specific glyph hints management. */
405 #define FT_GLYPH_OWN_BITMAP 0x1
407 typedef struct FT_Slot_InternalRec_
409 FT_GlyphLoader loader
;
411 FT_Bool glyph_transformed
;
412 FT_Matrix glyph_matrix
;
413 FT_Vector glyph_delta
;
416 } FT_GlyphSlot_InternalRec
;
421 /*************************************************************************/
424 /* FT_Size_InternalRec */
427 /* This structure contains the internal fields of each FT_Size */
428 /* object. Currently, it's empty. */
430 /*************************************************************************/
432 typedef struct FT_Size_InternalRec_
436 } FT_Size_InternalRec
;
441 /*************************************************************************/
442 /*************************************************************************/
443 /*************************************************************************/
446 /**** M O D U L E S ****/
449 /*************************************************************************/
450 /*************************************************************************/
451 /*************************************************************************/
454 /*************************************************************************/
460 /* A module object instance. */
463 /* clazz :: A pointer to the module's class. */
465 /* library :: A handle to the parent library object. */
467 /* memory :: A handle to the memory manager. */
469 typedef struct FT_ModuleRec_
471 FT_Module_Class
* clazz
;
478 /* typecast an object to an FT_Module */
479 #define FT_MODULE( x ) ((FT_Module)( x ))
480 #define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz
481 #define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library
482 #define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory
485 #define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
486 FT_MODULE_FONT_DRIVER )
488 #define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
491 #define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
494 #define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
497 #define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \
498 FT_MODULE_DRIVER_SCALABLE )
500 #define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \
501 FT_MODULE_DRIVER_NO_OUTLINES )
503 #define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \
504 FT_MODULE_DRIVER_HAS_HINTER )
507 /*************************************************************************/
510 /* FT_Get_Module_Interface */
513 /* Finds a module and returns its specific interface as a typeless */
517 /* library :: A handle to the library object. */
519 /* module_name :: The module's name (as an ASCII string). */
522 /* A module-specific interface if available, 0 otherwise. */
525 /* You should better be familiar with FreeType internals to know */
526 /* which module to look for, and what its interface is :-) */
528 FT_BASE( const void* )
529 FT_Get_Module_Interface( FT_Library library
,
530 const char* mod_name
);
532 FT_BASE( FT_Pointer
)
533 ft_module_get_service( FT_Module module
,
534 const char* service_id
);
539 /*************************************************************************/
540 /*************************************************************************/
541 /*************************************************************************/
544 /**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/
547 /*************************************************************************/
548 /*************************************************************************/
549 /*************************************************************************/
551 /* a few macros used to perform easy typecasts with minimal brain damage */
553 #define FT_FACE( x ) ((FT_Face)(x))
554 #define FT_SIZE( x ) ((FT_Size)(x))
555 #define FT_SLOT( x ) ((FT_GlyphSlot)(x))
557 #define FT_FACE_DRIVER( x ) FT_FACE( x )->driver
558 #define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library
559 #define FT_FACE_MEMORY( x ) FT_FACE( x )->memory
560 #define FT_FACE_STREAM( x ) FT_FACE( x )->stream
562 #define FT_SIZE_FACE( x ) FT_SIZE( x )->face
563 #define FT_SLOT_FACE( x ) FT_SLOT( x )->face
565 #define FT_FACE_SLOT( x ) FT_FACE( x )->glyph
566 #define FT_FACE_SIZE( x ) FT_FACE( x )->size
569 /*************************************************************************/
572 /* FT_New_GlyphSlot */
575 /* It is sometimes useful to have more than one glyph slot for a */
576 /* given face object. This function is used to create additional */
577 /* slots. All of them are automatically discarded when the face is */
581 /* face :: A handle to a parent face object. */
584 /* aslot :: A handle to a new glyph slot object. */
587 /* FreeType error code. 0 means success. */
590 FT_New_GlyphSlot( FT_Face face
,
591 FT_GlyphSlot
*aslot
);
594 /*************************************************************************/
597 /* FT_Done_GlyphSlot */
600 /* Destroys a given glyph slot. Remember however that all slots are */
601 /* automatically destroyed with its parent. Using this function is */
602 /* not always mandatory. */
605 /* slot :: A handle to a target glyph slot. */
608 FT_Done_GlyphSlot( FT_GlyphSlot slot
);
612 #define FT_REQUEST_WIDTH( req ) \
613 ( (req)->horiResolution \
614 ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
617 #define FT_REQUEST_HEIGHT( req ) \
618 ( (req)->vertResolution \
619 ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
623 /* Set the metrics according to a bitmap strike. */
625 FT_Select_Metrics( FT_Face face
,
626 FT_ULong strike_index
);
629 /* Set the metrics according to a size request. */
631 FT_Request_Metrics( FT_Face face
,
632 FT_Size_Request req
);
635 /* Match a size request against `available_sizes'. */
637 FT_Match_Size( FT_Face face
,
639 FT_Bool ignore_width
,
640 FT_ULong
* size_index
);
643 /* Use the horizontal metrics to synthesize the vertical metrics. */
644 /* If `advance' is zero, it is also synthesized. */
646 ft_synthesize_vertical_metrics( FT_Glyph_Metrics
* metrics
,
650 /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
651 /* was allocated with ft_glyphslot_alloc_bitmap). */
653 ft_glyphslot_free_bitmap( FT_GlyphSlot slot
);
656 /* Allocate a new bitmap buffer in a glyph slot. */
658 ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot
,
662 /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */
663 /* will not be freed by a later call to ft_glyphslot_free_bitmap. */
665 ft_glyphslot_set_bitmap( FT_GlyphSlot slot
,
669 /*************************************************************************/
670 /*************************************************************************/
671 /*************************************************************************/
674 /**** R E N D E R E R S ****/
677 /*************************************************************************/
678 /*************************************************************************/
679 /*************************************************************************/
682 #define FT_RENDERER( x ) ((FT_Renderer)( x ))
683 #define FT_GLYPH( x ) ((FT_Glyph)( x ))
684 #define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x ))
685 #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
688 typedef struct FT_RendererRec_
691 FT_Renderer_Class
* clazz
;
692 FT_Glyph_Format glyph_format
;
693 FT_Glyph_Class glyph_class
;
696 FT_Raster_Render_Func raster_render
;
697 FT_Renderer_RenderFunc render
;
702 /*************************************************************************/
703 /*************************************************************************/
704 /*************************************************************************/
707 /**** F O N T D R I V E R S ****/
710 /*************************************************************************/
711 /*************************************************************************/
712 /*************************************************************************/
715 /* typecast a module into a driver easily */
716 #define FT_DRIVER( x ) ((FT_Driver)(x))
718 /* typecast a module as a driver, and get its driver class */
719 #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz
722 /*************************************************************************/
728 /* The root font driver class. A font driver is responsible for */
729 /* managing and loading font files of a given format. */
732 /* root :: Contains the fields of the root module class. */
734 /* clazz :: A pointer to the font driver's class. Note that */
735 /* this is NOT root.clazz. `class' wasn't used */
736 /* as it is a reserved word in C++. */
738 /* faces_list :: The list of faces currently opened by this */
741 /* glyph_loader :: The glyph loader for all faces managed by this */
742 /* driver. This object isn't defined for unscalable */
745 typedef struct FT_DriverRec_
748 FT_Driver_Class clazz
;
749 FT_ListRec faces_list
;
750 FT_GlyphLoader glyph_loader
;
755 /*************************************************************************/
756 /*************************************************************************/
757 /*************************************************************************/
760 /**** L I B R A R I E S ****/
763 /*************************************************************************/
764 /*************************************************************************/
765 /*************************************************************************/
768 /* This hook is used by the TrueType debugger. It must be set to an */
769 /* alternate truetype bytecode interpreter function. */
770 #define FT_DEBUG_HOOK_TRUETYPE 0
773 /* Set this debug hook to a non-null pointer to force unpatented hinting */
774 /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */
775 /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */
776 /* during debugging. */
777 #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1
780 typedef void (*FT_Bitmap_LcdFilterFunc
)( FT_Bitmap
* bitmap
,
781 FT_Render_Mode render_mode
,
782 FT_Library library
);
785 /*************************************************************************/
791 /* The FreeType library class. This is the root of all FreeType */
792 /* data. Use FT_New_Library() to create a library object, and */
793 /* FT_Done_Library() to discard it and all child objects. */
796 /* memory :: The library's memory object. Manages memory */
799 /* version_major :: The major version number of the library. */
801 /* version_minor :: The minor version number of the library. */
803 /* version_patch :: The current patch level of the library. */
805 /* num_modules :: The number of modules currently registered */
806 /* within this library. This is set to 0 for new */
807 /* libraries. New modules are added through the */
808 /* FT_Add_Module() API function. */
810 /* modules :: A table used to store handles to the currently */
811 /* registered modules. Note that each font driver */
812 /* contains a list of its opened faces. */
814 /* renderers :: The list of renderers currently registered */
815 /* within the library. */
817 /* cur_renderer :: The current outline renderer. This is a */
818 /* shortcut used to avoid parsing the list on */
819 /* each call to FT_Outline_Render(). It is a */
820 /* handle to the current renderer for the */
821 /* FT_GLYPH_FORMAT_OUTLINE format. */
823 /* auto_hinter :: XXX */
825 /* raster_pool :: The raster object's render pool. This can */
826 /* ideally be changed dynamically at run-time. */
828 /* raster_pool_size :: The size of the render pool in bytes. */
830 /* debug_hooks :: XXX */
832 /* lcd_filter :: If subpixel rendering is activated, the */
833 /* selected LCD filter mode. */
835 /* lcd_extra :: If subpixel rendering is activated, the number */
836 /* of extra pixels needed for the LCD filter. */
838 /* lcd_weights :: If subpixel rendering is activated, the LCD */
839 /* filter weights, if any. */
841 /* lcd_filter_func :: If subpixel rendering is activated, the LCD */
842 /* filtering callback function. */
844 /* pic_container :: Contains global structs and tables, instead */
845 /* of defining them globallly. */
847 /* refcount :: A counter initialized to~1 at the time an */
848 /* @FT_Library structure is created. */
849 /* @FT_Reference_Library increments this counter, */
850 /* and @FT_Done_Library only destroys a library */
851 /* if the counter is~1, otherwise it simply */
854 typedef struct FT_LibraryRec_
856 FT_Memory memory
; /* library's memory manager */
858 FT_Int version_major
;
859 FT_Int version_minor
;
860 FT_Int version_patch
;
863 FT_Module modules
[FT_MAX_MODULES
]; /* module objects */
865 FT_ListRec renderers
; /* list of renderers */
866 FT_Renderer cur_renderer
; /* current outline renderer */
867 FT_Module auto_hinter
;
869 FT_Byte
* raster_pool
; /* scan-line conversion */
871 FT_ULong raster_pool_size
; /* size of render pool in bytes */
873 FT_DebugHook_Func debug_hooks
[4];
875 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
876 FT_LcdFilter lcd_filter
;
877 FT_Int lcd_extra
; /* number of extra pixels */
878 FT_Byte lcd_weights
[7]; /* filter weights, if any */
879 FT_Bitmap_LcdFilterFunc lcd_filter_func
; /* filtering callback */
882 #ifdef FT_CONFIG_OPTION_PIC
883 FT_PIC_Container pic_container
;
891 FT_BASE( FT_Renderer
)
892 FT_Lookup_Renderer( FT_Library library
,
893 FT_Glyph_Format format
,
897 FT_Render_Glyph_Internal( FT_Library library
,
899 FT_Render_Mode render_mode
);
902 (*FT_Face_GetPostscriptNameFunc
)( FT_Face face
);
905 (*FT_Face_GetGlyphNameFunc
)( FT_Face face
,
908 FT_UInt buffer_max
);
911 (*FT_Face_GetGlyphNameIndexFunc
)( FT_Face face
,
912 FT_String
* glyph_name
);
915 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
917 /*************************************************************************/
923 /* Creates a new memory object. */
926 /* A pointer to the new memory object. 0 in case of error. */
929 FT_New_Memory( void );
932 /*************************************************************************/
938 /* Discards memory manager. */
941 /* memory :: A handle to the memory manager. */
944 FT_Done_Memory( FT_Memory memory
);
946 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
949 /* Define default raster's interface. The default raster is located in */
950 /* `src/base/ftraster.c'. */
952 /* Client applications can register new rasters through the */
953 /* FT_Set_Raster() API. */
955 #ifndef FT_NO_DEFAULT_RASTER
956 FT_EXPORT_VAR( FT_Raster_Funcs
) ft_default_raster
;
960 /*************************************************************************/
961 /*************************************************************************/
962 /*************************************************************************/
965 /**** P I C S U P P O R T ****/
968 /*************************************************************************/
969 /*************************************************************************/
970 /*************************************************************************/
973 /* PIC support macros for ftimage.h */
976 /*************************************************************************/
979 /* FT_DEFINE_OUTLINE_FUNCS */
982 /* Used to initialize an instance of FT_Outline_Funcs struct. */
983 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
984 /* be called with a pre-allocated structure to be filled. */
985 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
986 /* allocated in the global scope (or the scope where the macro */
989 #ifndef FT_CONFIG_OPTION_PIC
991 #define FT_DEFINE_OUTLINE_FUNCS( \
999 static const FT_Outline_Funcs class_ = \
1009 #else /* FT_CONFIG_OPTION_PIC */
1011 #define FT_DEFINE_OUTLINE_FUNCS( \
1020 Init_Class_ ## class_( FT_Outline_Funcs* clazz ) \
1022 clazz->move_to = move_to_; \
1023 clazz->line_to = line_to_; \
1024 clazz->conic_to = conic_to_; \
1025 clazz->cubic_to = cubic_to_; \
1026 clazz->shift = shift_; \
1027 clazz->delta = delta_; \
1032 #endif /* FT_CONFIG_OPTION_PIC */
1035 /*************************************************************************/
1038 /* FT_DEFINE_RASTER_FUNCS */
1041 /* Used to initialize an instance of FT_Raster_Funcs struct. */
1042 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
1043 /* be called with a pre-allocated structure to be filled. */
1044 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1045 /* allocated in the global scope (or the scope where the macro */
1048 #ifndef FT_CONFIG_OPTION_PIC
1050 #define FT_DEFINE_RASTER_FUNCS( \
1058 const FT_Raster_Funcs class_ = \
1068 #else /* FT_CONFIG_OPTION_PIC */
1070 #define FT_DEFINE_RASTER_FUNCS( \
1079 FT_Init_Class_ ## class_( FT_Raster_Funcs* clazz ) \
1081 clazz->glyph_format = glyph_format_; \
1082 clazz->raster_new = raster_new_; \
1083 clazz->raster_reset = raster_reset_; \
1084 clazz->raster_set_mode = raster_set_mode_; \
1085 clazz->raster_render = raster_render_; \
1086 clazz->raster_done = raster_done_; \
1089 #endif /* FT_CONFIG_OPTION_PIC */
1092 /* PIC support macros for ftrender.h */
1095 /*************************************************************************/
1098 /* FT_DEFINE_GLYPH */
1101 /* Used to initialize an instance of FT_Glyph_Class struct. */
1102 /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */
1103 /* be called with a pre-allocated stcture to be filled. */
1104 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1105 /* allocated in the global scope (or the scope where the macro */
1108 #ifndef FT_CONFIG_OPTION_PIC
1110 #define FT_DEFINE_GLYPH( \
1120 FT_CALLBACK_TABLE_DEF \
1121 const FT_Glyph_Class class_ = \
1133 #else /* FT_CONFIG_OPTION_PIC */
1135 #define FT_DEFINE_GLYPH( \
1146 FT_Init_Class_ ## class_( FT_Glyph_Class* clazz ) \
1148 clazz->glyph_size = size_; \
1149 clazz->glyph_format = format_; \
1150 clazz->glyph_init = init_; \
1151 clazz->glyph_done = done_; \
1152 clazz->glyph_copy = copy_; \
1153 clazz->glyph_transform = transform_; \
1154 clazz->glyph_bbox = bbox_; \
1155 clazz->glyph_prepare = prepare_; \
1158 #endif /* FT_CONFIG_OPTION_PIC */
1161 /*************************************************************************/
1164 /* FT_DECLARE_RENDERER */
1167 /* Used to create a forward declaration of a */
1168 /* FT_Renderer_Class struct instance. */
1171 /* FT_DEFINE_RENDERER */
1174 /* Used to initialize an instance of FT_Renderer_Class struct. */
1176 /* When FT_CONFIG_OPTION_PIC is defined a `create' funtion will need */
1177 /* to be called with a pointer where the allocated structure is */
1178 /* returned. And when it is no longer needed a `destroy' function */
1179 /* needs to be called to release that allocation. */
1180 /* `fcinit.c' (ft_create_default_module_classes) already contains */
1181 /* a mechanism to call these functions for the default modules */
1182 /* described in `ftmodule.h'. */
1184 /* Notice that the created `create' and `destroy' functions call */
1185 /* `pic_init' and `pic_free' to allow you to manually allocate and */
1186 /* initialize any additional global data, like a module specific */
1187 /* interface, and put them in the global pic container defined in */
1188 /* `ftpic.h'. If you don't need them just implement the functions as */
1189 /* empty to resolve the link error. Also the `pic_init' and */
1190 /* `pic_free' functions should be declared in `pic.h', to be referred */
1191 /* by the renderer definition calling `FT_DEFINE_RENDERER' in the */
1194 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1195 /* allocated in the global scope (or the scope where the macro */
1198 #ifndef FT_CONFIG_OPTION_PIC
1200 #define FT_DECLARE_RENDERER( class_ ) \
1201 FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
1203 #define FT_DEFINE_RENDERER( \
1220 FT_CALLBACK_TABLE_DEF \
1221 const FT_Renderer_Class class_ = \
1223 FT_DEFINE_ROOT_MODULE( flags_, \
1242 #else /* FT_CONFIG_OPTION_PIC */
1244 #define FT_DECLARE_RENDERER( class_ ) FT_DECLARE_MODULE( class_ )
1246 #define FT_DEFINE_RENDERER( \
1264 FT_Destroy_Class_ ## class_( FT_Library library, \
1265 FT_Module_Class* clazz ) \
1267 FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \
1268 FT_Memory memory = library->memory; \
1271 class_ ## _pic_free( library ); \
1273 FT_FREE( rclazz ); \
1278 FT_Create_Class_ ## class_( FT_Library library, \
1279 FT_Module_Class** output_class ) \
1281 FT_Renderer_Class* clazz = NULL; \
1283 FT_Memory memory = library->memory; \
1286 if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \
1289 error = class_ ## _pic_init( library ); \
1296 FT_DEFINE_ROOT_MODULE( flags_, \
1306 clazz->glyph_format = glyph_format_; \
1308 clazz->render_glyph = render_glyph_; \
1309 clazz->transform_glyph = transform_glyph_; \
1310 clazz->get_glyph_cbox = get_glyph_cbox_; \
1311 clazz->set_mode = set_mode_; \
1313 clazz->raster_class = raster_class_; \
1315 *output_class = (FT_Module_Class*)clazz; \
1320 #endif /* FT_CONFIG_OPTION_PIC */
1323 /* PIC support macros for ftmodapi.h **/
1326 #ifdef FT_CONFIG_OPTION_PIC
1328 /*************************************************************************/
1331 /* FT_Module_Creator */
1334 /* A function used to create (allocate) a new module class object. */
1335 /* The object's members are initialized, but the module itself is */
1339 /* memory :: A handle to the memory manager. */
1340 /* output_class :: Initialized with the newly allocated class. */
1343 (*FT_Module_Creator
)( FT_Memory memory
,
1344 FT_Module_Class
** output_class
);
1346 /*************************************************************************/
1349 /* FT_Module_Destroyer */
1352 /* A function used to destroy (deallocate) a module class object. */
1355 /* memory :: A handle to the memory manager. */
1356 /* clazz :: Module class to destroy. */
1359 (*FT_Module_Destroyer
)( FT_Memory memory
,
1360 FT_Module_Class
* clazz
);
1365 /*************************************************************************/
1368 /* FT_DECLARE_MODULE */
1371 /* Used to create a forward declaration of a */
1372 /* FT_Module_Class struct instance. */
1375 /* FT_DEFINE_MODULE */
1378 /* Used to initialize an instance of an FT_Module_Class struct. */
1380 /* When FT_CONFIG_OPTION_PIC is defined a `create' funtion needs to */
1381 /* be called with a pointer where the allocated structure is */
1382 /* returned. And when it is no longer needed a `destroy' function */
1383 /* needs to be called to release that allocation. */
1384 /* `fcinit.c' (ft_create_default_module_classes) already contains */
1385 /* a mechanism to call these functions for the default modules */
1386 /* described in `ftmodule.h'. */
1388 /* Notice that the created `create' and `destroy' functions call */
1389 /* `pic_init' and `pic_free' to allow you to manually allocate and */
1390 /* initialize any additional global data, like a module specific */
1391 /* interface, and put them in the global pic container defined in */
1392 /* `ftpic.h'. If you don't need them just implement the functions as */
1393 /* empty to resolve the link error. Also the `pic_init' and */
1394 /* `pic_free' functions should be declared in `pic.h', to be referred */
1395 /* by the module definition calling `FT_DEFINE_MODULE' in the */
1398 /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */
1399 /* allocated in the global scope (or the scope where the macro */
1403 /* FT_DEFINE_ROOT_MODULE */
1406 /* Used to initialize an instance of an FT_Module_Class struct inside */
1407 /* another struct that contains it or in a function that initializes */
1408 /* that containing struct. */
1410 #ifndef FT_CONFIG_OPTION_PIC
1412 #define FT_DECLARE_MODULE( class_ ) \
1414 const FT_Module_Class class_;
1416 #define FT_DEFINE_ROOT_MODULE( \
1441 #define FT_DEFINE_MODULE( \
1452 FT_CALLBACK_TABLE_DEF \
1453 const FT_Module_Class class_ = \
1470 #else /* FT_CONFIG_OPTION_PIC */
1472 #define FT_DECLARE_MODULE( class_ ) \
1474 FT_Create_Class_ ## class_( FT_Library library, \
1475 FT_Module_Class** output_class ); \
1477 FT_Destroy_Class_ ## class_( FT_Library library, \
1478 FT_Module_Class* clazz );
1480 #define FT_DEFINE_ROOT_MODULE( \
1490 clazz->root.module_flags = flags_; \
1491 clazz->root.module_size = size_; \
1492 clazz->root.module_name = name_; \
1493 clazz->root.module_version = version_; \
1494 clazz->root.module_requires = requires_; \
1496 clazz->root.module_interface = interface_; \
1498 clazz->root.module_init = init_; \
1499 clazz->root.module_done = done_; \
1500 clazz->root.get_interface = get_interface_;
1502 #define FT_DEFINE_MODULE( \
1514 FT_Destroy_Class_ ## class_( FT_Library library, \
1515 FT_Module_Class* clazz ) \
1517 FT_Memory memory = library->memory; \
1520 class_ ## _pic_free( library ); \
1527 FT_Create_Class_ ## class_( FT_Library library, \
1528 FT_Module_Class** output_class ) \
1530 FT_Memory memory = library->memory; \
1531 FT_Module_Class* clazz = NULL; \
1535 if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \
1537 error = class_ ## _pic_init( library ); \
1544 clazz->module_flags = flags_; \
1545 clazz->module_size = size_; \
1546 clazz->module_name = name_; \
1547 clazz->module_version = version_; \
1548 clazz->module_requires = requires_; \
1550 clazz->module_interface = interface_; \
1552 clazz->module_init = init_; \
1553 clazz->module_done = done_; \
1554 clazz->get_interface = get_interface_; \
1556 *output_class = clazz; \
1561 #endif /* FT_CONFIG_OPTION_PIC */
1566 #endif /* __FTOBJS_H__ */