1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftobjs.h                                                               */
4 /*                                                                         */
5 /*    The FreeType private base classes (specification).                   */
6 /*                                                                         */
7 /*  Copyright 1996-2018 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 
26 #ifndef FTOBJS_H_
27 #define FTOBJS_H_
28 
29 #include <ft2build.h>
30 #include FT_RENDER_H
31 #include FT_SIZES_H
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
39 #include FT_INTERNAL_CALC_H
40 
41 #ifdef FT_CONFIG_OPTION_INCREMENTAL
42 #include FT_INCREMENTAL_H
43 #endif
44 
45 
46 FT_BEGIN_HEADER
47 
48 
49   /*************************************************************************/
50   /*                                                                       */
51   /* Some generic definitions.                                             */
52   /*                                                                       */
53 #ifndef TRUE
54 #define TRUE  1
55 #endif
56 
57 #ifndef FALSE
58 #define FALSE  0
59 #endif
60 
61 #ifndef NULL
62 #define NULL  (void*)0
63 #endif
64 
65 
66   /*************************************************************************/
67   /*                                                                       */
68   /* The min and max functions missing in C.  As usual, be careful not to  */
69   /* write things like FT_MIN( a++, b++ ) to avoid side effects.           */
70   /*                                                                       */
71 #define FT_MIN( a, b )  ( (a) < (b) ? (a) : (b) )
72 #define FT_MAX( a, b )  ( (a) > (b) ? (a) : (b) )
73 
74 #define FT_ABS( a )     ( (a) < 0 ? -(a) : (a) )
75 
76   /*
77    *  Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
78    *  algorithm.  We use alpha = 1, beta = 3/8, giving us results with a
79    *  largest error less than 7% compared to the exact value.
80    */
81 #define FT_HYPOT( x, y )                 \
82           ( x = FT_ABS( x ),             \
83             y = FT_ABS( y ),             \
84             x > y ? x + ( 3 * y >> 3 )   \
85                   : y + ( 3 * x >> 3 ) )
86 
87   /* we use FT_TYPEOF to suppress signedness compilation warnings */
88 #define FT_PAD_FLOOR( x, n )  ( (x) & ~FT_TYPEOF( x )( (n) - 1 ) )
89 #define FT_PAD_ROUND( x, n )  FT_PAD_FLOOR( (x) + (n) / 2, n )
90 #define FT_PAD_CEIL( x, n )   FT_PAD_FLOOR( (x) + (n) - 1, n )
91 
92 #define FT_PIX_FLOOR( x )     ( (x) & ~FT_TYPEOF( x )63 )
93 #define FT_PIX_ROUND( x )     FT_PIX_FLOOR( (x) + 32 )
94 #define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )
95 
96   /* specialized versions (for signed values)                   */
97   /* that don't produce run-time errors due to integer overflow */
98 #define FT_PAD_ROUND_LONG( x, n )  FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \
99                                                  n )
100 #define FT_PAD_CEIL_LONG( x, n )   FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \
101                                                  n )
102 #define FT_PIX_ROUND_LONG( x )     FT_PIX_FLOOR( ADD_LONG( (x), 32 ) )
103 #define FT_PIX_CEIL_LONG( x )      FT_PIX_FLOOR( ADD_LONG( (x), 63 ) )
104 
105 #define FT_PAD_ROUND_INT32( x, n )  FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \
106                                                   n )
107 #define FT_PAD_CEIL_INT32( x, n )   FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \
108                                                   n )
109 #define FT_PIX_ROUND_INT32( x )     FT_PIX_FLOOR( ADD_INT32( (x), 32 ) )
110 #define FT_PIX_CEIL_INT32( x )      FT_PIX_FLOOR( ADD_INT32( (x), 63 ) )
111 
112 
113   /*
114    *  character classification functions -- since these are used to parse
115    *  font files, we must not use those in <ctypes.h> which are
116    *  locale-dependent
117    */
118 #define  ft_isdigit( x )   ( ( (unsigned)(x) - '0' ) < 10U )
119 
120 #define  ft_isxdigit( x )  ( ( (unsigned)(x) - '0' ) < 10U || \
121                              ( (unsigned)(x) - 'a' ) < 6U  || \
122                              ( (unsigned)(x) - 'A' ) < 6U  )
123 
124   /* the next two macros assume ASCII representation */
125 #define  ft_isupper( x )  ( ( (unsigned)(x) - 'A' ) < 26U )
126 #define  ft_islower( x )  ( ( (unsigned)(x) - 'a' ) < 26U )
127 
128 #define  ft_isalpha( x )  ( ft_isupper( x ) || ft_islower( x ) )
129 #define  ft_isalnum( x )  ( ft_isdigit( x ) || ft_isalpha( x ) )
130 
131 
132   /*************************************************************************/
133   /*************************************************************************/
134   /*************************************************************************/
135   /****                                                                 ****/
136   /****                                                                 ****/
137   /****                       C H A R M A P S                           ****/
138   /****                                                                 ****/
139   /****                                                                 ****/
140   /*************************************************************************/
141   /*************************************************************************/
142   /*************************************************************************/
143 
144   /* handle to internal charmap object */
145   typedef struct FT_CMapRec_*              FT_CMap;
146 
147   /* handle to charmap class structure */
148   typedef const struct FT_CMap_ClassRec_*  FT_CMap_Class;
149 
150   /* internal charmap object structure */
151   typedef struct  FT_CMapRec_
152   {
153     FT_CharMapRec  charmap;
154     FT_CMap_Class  clazz;
155 
156   } FT_CMapRec;
157 
158   /* typecase any pointer to a charmap handle */
159 #define FT_CMAP( x )  ( (FT_CMap)( x ) )
160 
161   /* obvious macros */
162 #define FT_CMAP_PLATFORM_ID( x )  FT_CMAP( x )->charmap.platform_id
163 #define FT_CMAP_ENCODING_ID( x )  FT_CMAP( x )->charmap.encoding_id
164 #define FT_CMAP_ENCODING( x )     FT_CMAP( x )->charmap.encoding
165 #define FT_CMAP_FACE( x )         FT_CMAP( x )->charmap.face
166 
167 
168   /* class method definitions */
169   typedef FT_Error
170   (*FT_CMap_InitFunc)( FT_CMap     cmap,
171                        FT_Pointer  init_data );
172 
173   typedef void
174   (*FT_CMap_DoneFunc)( FT_CMap  cmap );
175 
176   typedef FT_UInt
177   (*FT_CMap_CharIndexFunc)( FT_CMap    cmap,
178                             FT_UInt32  char_code );
179 
180   typedef FT_UInt
181   (*FT_CMap_CharNextFunc)( FT_CMap     cmap,
182                            FT_UInt32  *achar_code );
183 
184   typedef FT_UInt
185   (*FT_CMap_CharVarIndexFunc)( FT_CMap    cmap,
186                                FT_CMap    unicode_cmap,
187                                FT_UInt32  char_code,
188                                FT_UInt32  variant_selector );
189 
190   typedef FT_Bool
191   (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap    cmap,
192                                    FT_UInt32  char_code,
193                                    FT_UInt32  variant_selector );
194 
195   typedef FT_UInt32 *
196   (*FT_CMap_VariantListFunc)( FT_CMap    cmap,
197                               FT_Memory  mem );
198 
199   typedef FT_UInt32 *
200   (*FT_CMap_CharVariantListFunc)( FT_CMap    cmap,
201                                   FT_Memory  mem,
202                                   FT_UInt32  char_code );
203 
204   typedef FT_UInt32 *
205   (*FT_CMap_VariantCharListFunc)( FT_CMap    cmap,
206                                   FT_Memory  mem,
207                                   FT_UInt32  variant_selector );
208 
209 
210   typedef struct  FT_CMap_ClassRec_
211   {
212     FT_ULong               size;
213 
214     FT_CMap_InitFunc       init;
215     FT_CMap_DoneFunc       done;
216     FT_CMap_CharIndexFunc  char_index;
217     FT_CMap_CharNextFunc   char_next;
218 
219     /* Subsequent entries are special ones for format 14 -- the variant */
220     /* selector subtable which behaves like no other                    */
221 
222     FT_CMap_CharVarIndexFunc      char_var_index;
223     FT_CMap_CharVarIsDefaultFunc  char_var_default;
224     FT_CMap_VariantListFunc       variant_list;
225     FT_CMap_CharVariantListFunc   charvariant_list;
226     FT_CMap_VariantCharListFunc   variantchar_list;
227 
228   } FT_CMap_ClassRec;
229 
230 
231 #ifndef FT_CONFIG_OPTION_PIC
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 #else /* FT_CONFIG_OPTION_PIC */
264 
265 #define FT_DECLARE_CMAP_CLASS( class_ )                  \
266   void                                                   \
267   FT_Init_Class_ ## class_( FT_Library         library,  \
268                             FT_CMap_ClassRec*  clazz );
269 
270 #define FT_DEFINE_CMAP_CLASS(                            \
271           class_,                                        \
272           size_,                                         \
273           init_,                                         \
274           done_,                                         \
275           char_index_,                                   \
276           char_next_,                                    \
277           char_var_index_,                               \
278           char_var_default_,                             \
279           variant_list_,                                 \
280           charvariant_list_,                             \
281           variantchar_list_ )                            \
282   void                                                   \
283   FT_Init_Class_ ## class_( FT_Library         library,  \
284                             FT_CMap_ClassRec*  clazz )   \
285   {                                                      \
286     FT_UNUSED( library );                                \
287                                                          \
288     clazz->size             = size_;                     \
289     clazz->init             = init_;                     \
290     clazz->done             = done_;                     \
291     clazz->char_index       = char_index_;               \
292     clazz->char_next        = char_next_;                \
293     clazz->char_var_index   = char_var_index_;           \
294     clazz->char_var_default = char_var_default_;         \
295     clazz->variant_list     = variant_list_;             \
296     clazz->charvariant_list = charvariant_list_;         \
297     clazz->variantchar_list = variantchar_list_;         \
298   }
299 
300 #endif /* FT_CONFIG_OPTION_PIC */
301 
302 
303   /* create a new charmap and add it to charmap->face */
304   FT_BASE( FT_Error )
305   FT_CMap_New( FT_CMap_Class  clazz,
306                FT_Pointer     init_data,
307                FT_CharMap     charmap,
308                FT_CMap       *acmap );
309 
310   /* destroy a charmap and remove it from face's list */
311   FT_BASE( void )
312   FT_CMap_Done( FT_CMap  cmap );
313 
314 
315   /* adds LCD padding to Min and Max boundaries */
316   FT_BASE( void )
317   ft_lcd_padding( FT_Pos*       Min,
318                   FT_Pos*       Max,
319                   FT_GlyphSlot  slot );
320 
321 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
322 
323   typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
324                                             FT_Render_Mode  render_mode,
325                                             FT_Byte*        weights );
326 
327 
328   /* This is the default LCD filter, an in-place, 5-tap FIR filter. */
329   FT_BASE( void )
330   ft_lcd_filter_fir( FT_Bitmap*           bitmap,
331                      FT_Render_Mode       mode,
332                      FT_LcdFiveTapFilter  weights );
333 
334 #endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
335 
336   /*************************************************************************/
337   /*                                                                       */
338   /* <Struct>                                                              */
339   /*    FT_Face_InternalRec                                                */
340   /*                                                                       */
341   /* <Description>                                                         */
342   /*    This structure contains the internal fields of each FT_Face        */
343   /*    object.  These fields may change between different releases of     */
344   /*    FreeType.                                                          */
345   /*                                                                       */
346   /* <Fields>                                                              */
347   /*    max_points ::                                                      */
348   /*      The maximum number of points used to store the vectorial outline */
349   /*      of any glyph in this face.  If this value cannot be known in     */
350   /*      advance, or if the face isn't scalable, this should be set to 0. */
351   /*      Only relevant for scalable formats.                              */
352   /*                                                                       */
353   /*    max_contours ::                                                    */
354   /*      The maximum number of contours used to store the vectorial       */
355   /*      outline of any glyph in this face.  If this value cannot be      */
356   /*      known in advance, or if the face isn't scalable, this should be  */
357   /*      set to 0.  Only relevant for scalable formats.                   */
358   /*                                                                       */
359   /*    transform_matrix ::                                                */
360   /*      A 2x2 matrix of 16.16 coefficients used to transform glyph       */
361   /*      outlines after they are loaded from the font.  Only used by the  */
362   /*      convenience functions.                                           */
363   /*                                                                       */
364   /*    transform_delta ::                                                 */
365   /*      A translation vector used to transform glyph outlines after they */
366   /*      are loaded from the font.  Only used by the convenience          */
367   /*      functions.                                                       */
368   /*                                                                       */
369   /*    transform_flags ::                                                 */
370   /*      Some flags used to classify the transform.  Only used by the     */
371   /*      convenience functions.                                           */
372   /*                                                                       */
373   /*    services ::                                                        */
374   /*      A cache for frequently used services.  It should be only         */
375   /*      accessed with the macro `FT_FACE_LOOKUP_SERVICE'.                */
376   /*                                                                       */
377   /*    incremental_interface ::                                           */
378   /*      If non-null, the interface through which glyph data and metrics  */
379   /*      are loaded incrementally for faces that do not provide all of    */
380   /*      this data when first opened.  This field exists only if          */
381   /*      @FT_CONFIG_OPTION_INCREMENTAL is defined.                        */
382   /*                                                                       */
383   /*    no_stem_darkening ::                                               */
384   /*      Overrides the module-level default, see @stem-darkening[cff],    */
385   /*      for example.  FALSE and TRUE toggle stem darkening on and off,   */
386   /*      respectively, value~-1 means to use the module/driver default.   */
387   /*                                                                       */
388   /*    random_seed ::                                                     */
389   /*      If positive, override the seed value for the CFF `random'        */
390   /*      operator.  Value~0 means to use the font's value.  Value~-1      */
391   /*      means to use the CFF driver's default.                           */
392   /*                                                                       */
393   /*    lcd_weights      ::                                                */
394   /*    lcd_filter_func  ::                                                */
395   /*      If subpixel rendering is activated, the LCD filtering weights    */
396   /*      and callback function.                                           */
397   /*                                                                       */
398   /*    refcount ::                                                        */
399   /*      A counter initialized to~1 at the time an @FT_Face structure is  */
400   /*      created.  @FT_Reference_Face increments this counter, and        */
401   /*      @FT_Done_Face only destroys a face if the counter is~1,          */
402   /*      otherwise it simply decrements it.                               */
403   /*                                                                       */
404   typedef struct  FT_Face_InternalRec_
405   {
406     FT_Matrix  transform_matrix;
407     FT_Vector  transform_delta;
408     FT_Int     transform_flags;
409 
410     FT_ServiceCacheRec  services;
411 
412 #ifdef FT_CONFIG_OPTION_INCREMENTAL
413     FT_Incremental_InterfaceRec*  incremental_interface;
414 #endif
415 
416     FT_Char              no_stem_darkening;
417     FT_Int32             random_seed;
418 
419 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
420     FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
421     FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
422 #endif
423 
424     FT_Int  refcount;
425 
426   } FT_Face_InternalRec;
427 
428 
429   /*************************************************************************/
430   /*                                                                       */
431   /* <Struct>                                                              */
432   /*    FT_Slot_InternalRec                                                */
433   /*                                                                       */
434   /* <Description>                                                         */
435   /*    This structure contains the internal fields of each FT_GlyphSlot   */
436   /*    object.  These fields may change between different releases of     */
437   /*    FreeType.                                                          */
438   /*                                                                       */
439   /* <Fields>                                                              */
440   /*    loader            :: The glyph loader object used to load outlines */
441   /*                         into the glyph slot.                          */
442   /*                                                                       */
443   /*    flags             :: Possible values are zero or                   */
444   /*                         FT_GLYPH_OWN_BITMAP.  The latter indicates    */
445   /*                         that the FT_GlyphSlot structure owns the      */
446   /*                         bitmap buffer.                                */
447   /*                                                                       */
448   /*    glyph_transformed :: Boolean.  Set to TRUE when the loaded glyph   */
449   /*                         must be transformed through a specific        */
450   /*                         font transformation.  This is _not_ the same  */
451   /*                         as the face transform set through             */
452   /*                         FT_Set_Transform().                           */
453   /*                                                                       */
454   /*    glyph_matrix      :: The 2x2 matrix corresponding to the glyph     */
455   /*                         transformation, if necessary.                 */
456   /*                                                                       */
457   /*    glyph_delta       :: The 2d translation vector corresponding to    */
458   /*                         the glyph transformation, if necessary.       */
459   /*                                                                       */
460   /*    glyph_hints       :: Format-specific glyph hints management.       */
461   /*                                                                       */
462 
463 #define FT_GLYPH_OWN_BITMAP  0x1U
464 
465   typedef struct  FT_Slot_InternalRec_
466   {
467     FT_GlyphLoader  loader;
468     FT_UInt         flags;
469     FT_Bool         glyph_transformed;
470     FT_Matrix       glyph_matrix;
471     FT_Vector       glyph_delta;
472     void*           glyph_hints;
473 
474   } FT_GlyphSlot_InternalRec;
475 
476 
477   /*************************************************************************/
478   /*                                                                       */
479   /* <Struct>                                                              */
480   /*    FT_Size_InternalRec                                                */
481   /*                                                                       */
482   /* <Description>                                                         */
483   /*    This structure contains the internal fields of each FT_Size        */
484   /*    object.                                                            */
485   /*                                                                       */
486   /* <Fields>                                                              */
487   /*    module_data      :: Data specific to a driver module.              */
488   /*                                                                       */
489   /*    autohint_mode    :: The used auto-hinting mode.                    */
490   /*                                                                       */
491   /*    autohint_metrics :: Metrics used by the auto-hinter.               */
492   /*                                                                       */
493   /*************************************************************************/
494 
495   typedef struct  FT_Size_InternalRec_
496   {
497     void*  module_data;
498 
499     FT_Render_Mode   autohint_mode;
500     FT_Size_Metrics  autohint_metrics;
501 
502   } FT_Size_InternalRec;
503 
504 
505   /*************************************************************************/
506   /*************************************************************************/
507   /*************************************************************************/
508   /****                                                                 ****/
509   /****                                                                 ****/
510   /****                         M O D U L E S                           ****/
511   /****                                                                 ****/
512   /****                                                                 ****/
513   /*************************************************************************/
514   /*************************************************************************/
515   /*************************************************************************/
516 
517 
518   /*************************************************************************/
519   /*                                                                       */
520   /* <Struct>                                                              */
521   /*    FT_ModuleRec                                                       */
522   /*                                                                       */
523   /* <Description>                                                         */
524   /*    A module object instance.                                          */
525   /*                                                                       */
526   /* <Fields>                                                              */
527   /*    clazz   :: A pointer to the module's class.                        */
528   /*                                                                       */
529   /*    library :: A handle to the parent library object.                  */
530   /*                                                                       */
531   /*    memory  :: A handle to the memory manager.                         */
532   /*                                                                       */
533   typedef struct  FT_ModuleRec_
534   {
535     FT_Module_Class*  clazz;
536     FT_Library        library;
537     FT_Memory         memory;
538 
539   } FT_ModuleRec;
540 
541 
542   /* typecast an object to an FT_Module */
543 #define FT_MODULE( x )  ( (FT_Module)(x) )
544 
545 #define FT_MODULE_CLASS( x )    FT_MODULE( x )->clazz
546 #define FT_MODULE_LIBRARY( x )  FT_MODULE( x )->library
547 #define FT_MODULE_MEMORY( x )   FT_MODULE( x )->memory
548 
549 
550 #define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
551                                     FT_MODULE_FONT_DRIVER )
552 
553 #define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
554                                       FT_MODULE_RENDERER )
555 
556 #define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
557                                     FT_MODULE_HINTER )
558 
559 #define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
560                                     FT_MODULE_STYLER )
561 
562 #define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS( x )->module_flags & \
563                                       FT_MODULE_DRIVER_SCALABLE )
564 
565 #define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS( x )->module_flags & \
566                                          FT_MODULE_DRIVER_NO_OUTLINES )
567 
568 #define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
569                                      FT_MODULE_DRIVER_HAS_HINTER )
570 
571 #define FT_DRIVER_HINTS_LIGHTLY( x )  ( FT_MODULE_CLASS( x )->module_flags & \
572                                         FT_MODULE_DRIVER_HINTS_LIGHTLY )
573 
574 
575   /*************************************************************************/
576   /*                                                                       */
577   /* <Function>                                                            */
578   /*    FT_Get_Module_Interface                                            */
579   /*                                                                       */
580   /* <Description>                                                         */
581   /*    Finds a module and returns its specific interface as a typeless    */
582   /*    pointer.                                                           */
583   /*                                                                       */
584   /* <Input>                                                               */
585   /*    library     :: A handle to the library object.                     */
586   /*                                                                       */
587   /*    module_name :: The module's name (as an ASCII string).             */
588   /*                                                                       */
589   /* <Return>                                                              */
590   /*    A module-specific interface if available, 0 otherwise.             */
591   /*                                                                       */
592   /* <Note>                                                                */
593   /*    You should better be familiar with FreeType internals to know      */
594   /*    which module to look for, and what its interface is :-)            */
595   /*                                                                       */
596   FT_BASE( const void* )
597   FT_Get_Module_Interface( FT_Library   library,
598                            const char*  mod_name );
599 
600   FT_BASE( FT_Pointer )
601   ft_module_get_service( FT_Module    module,
602                          const char*  service_id,
603                          FT_Bool      global );
604 
605 #ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
606   FT_BASE( FT_Error )
607   ft_property_string_set( FT_Library        library,
608                           const FT_String*  module_name,
609                           const FT_String*  property_name,
610                           FT_String*        value );
611 #endif
612 
613   /* */
614 
615 
616   /*************************************************************************/
617   /*************************************************************************/
618   /*************************************************************************/
619   /****                                                                 ****/
620   /****                                                                 ****/
621   /****   F A C E,   S I Z E   &   G L Y P H   S L O T   O B J E C T S  ****/
622   /****                                                                 ****/
623   /****                                                                 ****/
624   /*************************************************************************/
625   /*************************************************************************/
626   /*************************************************************************/
627 
628   /* a few macros used to perform easy typecasts with minimal brain damage */
629 
630 #define FT_FACE( x )          ( (FT_Face)(x) )
631 #define FT_SIZE( x )          ( (FT_Size)(x) )
632 #define FT_SLOT( x )          ( (FT_GlyphSlot)(x) )
633 
634 #define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
635 #define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
636 #define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
637 #define FT_FACE_STREAM( x )   FT_FACE( x )->stream
638 
639 #define FT_SIZE_FACE( x )     FT_SIZE( x )->face
640 #define FT_SLOT_FACE( x )     FT_SLOT( x )->face
641 
642 #define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
643 #define FT_FACE_SIZE( x )     FT_FACE( x )->size
644 
645 
646   /*************************************************************************/
647   /*                                                                       */
648   /* <Function>                                                            */
649   /*    FT_New_GlyphSlot                                                   */
650   /*                                                                       */
651   /* <Description>                                                         */
652   /*    It is sometimes useful to have more than one glyph slot for a      */
653   /*    given face object.  This function is used to create additional     */
654   /*    slots.  All of them are automatically discarded when the face is   */
655   /*    destroyed.                                                         */
656   /*                                                                       */
657   /* <Input>                                                               */
658   /*    face  :: A handle to a parent face object.                         */
659   /*                                                                       */
660   /* <Output>                                                              */
661   /*    aslot :: A handle to a new glyph slot object.                      */
662   /*                                                                       */
663   /* <Return>                                                              */
664   /*    FreeType error code.  0 means success.                             */
665   /*                                                                       */
666   FT_BASE( FT_Error )
667   FT_New_GlyphSlot( FT_Face        face,
668                     FT_GlyphSlot  *aslot );
669 
670 
671   /*************************************************************************/
672   /*                                                                       */
673   /* <Function>                                                            */
674   /*    FT_Done_GlyphSlot                                                  */
675   /*                                                                       */
676   /* <Description>                                                         */
677   /*    Destroys a given glyph slot.  Remember however that all slots are  */
678   /*    automatically destroyed with its parent.  Using this function is   */
679   /*    not always mandatory.                                              */
680   /*                                                                       */
681   /* <Input>                                                               */
682   /*    slot :: A handle to a target glyph slot.                           */
683   /*                                                                       */
684   FT_BASE( void )
685   FT_Done_GlyphSlot( FT_GlyphSlot  slot );
686 
687  /* */
688 
689 #define FT_REQUEST_WIDTH( req )                                            \
690           ( (req)->horiResolution                                          \
691               ? ( (req)->width * (FT_Pos)(req)->horiResolution + 36 ) / 72 \
692               : (req)->width )
693 
694 #define FT_REQUEST_HEIGHT( req )                                            \
695           ( (req)->vertResolution                                           \
696               ? ( (req)->height * (FT_Pos)(req)->vertResolution + 36 ) / 72 \
697               : (req)->height )
698 
699 
700   /* Set the metrics according to a bitmap strike. */
701   FT_BASE( void )
702   FT_Select_Metrics( FT_Face   face,
703                      FT_ULong  strike_index );
704 
705 
706   /* Set the metrics according to a size request. */
707   FT_BASE( void )
708   FT_Request_Metrics( FT_Face          face,
709                       FT_Size_Request  req );
710 
711 
712   /* Match a size request against `available_sizes'. */
713   FT_BASE( FT_Error )
714   FT_Match_Size( FT_Face          face,
715                  FT_Size_Request  req,
716                  FT_Bool          ignore_width,
717                  FT_ULong*        size_index );
718 
719 
720   /* Use the horizontal metrics to synthesize the vertical metrics. */
721   /* If `advance' is zero, it is also synthesized.                  */
722   FT_BASE( void )
723   ft_synthesize_vertical_metrics( FT_Glyph_Metrics*  metrics,
724                                   FT_Pos             advance );
725 
726 
727   /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
728   /* was allocated with ft_glyphslot_alloc_bitmap).                       */
729   FT_BASE( void )
730   ft_glyphslot_free_bitmap( FT_GlyphSlot  slot );
731 
732 
733   /* Preset bitmap metrics of an outline glyphslot prior to rendering. */
734   FT_BASE( void )
735   ft_glyphslot_preset_bitmap( FT_GlyphSlot      slot,
736                               FT_Render_Mode    mode,
737                               const FT_Vector*  origin );
738 
739   /* Allocate a new bitmap buffer in a glyph slot. */
740   FT_BASE( FT_Error )
741   ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
742                              FT_ULong      size );
743 
744 
745   /* Set the bitmap buffer in a glyph slot to a given pointer.  The buffer */
746   /* will not be freed by a later call to ft_glyphslot_free_bitmap.        */
747   FT_BASE( void )
748   ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
749                            FT_Byte*      buffer );
750 
751 
752   /*************************************************************************/
753   /*************************************************************************/
754   /*************************************************************************/
755   /****                                                                 ****/
756   /****                                                                 ****/
757   /****                        R E N D E R E R S                        ****/
758   /****                                                                 ****/
759   /****                                                                 ****/
760   /*************************************************************************/
761   /*************************************************************************/
762   /*************************************************************************/
763 
764 
765 #define FT_RENDERER( x )       ( (FT_Renderer)(x) )
766 #define FT_GLYPH( x )          ( (FT_Glyph)(x) )
767 #define FT_BITMAP_GLYPH( x )   ( (FT_BitmapGlyph)(x) )
768 #define FT_OUTLINE_GLYPH( x )  ( (FT_OutlineGlyph)(x) )
769 
770 
771   typedef struct  FT_RendererRec_
772   {
773     FT_ModuleRec            root;
774     FT_Renderer_Class*      clazz;
775     FT_Glyph_Format         glyph_format;
776     FT_Glyph_Class          glyph_class;
777 
778     FT_Raster               raster;
779     FT_Raster_Render_Func   raster_render;
780     FT_Renderer_RenderFunc  render;
781 
782   } FT_RendererRec;
783 
784 
785   /*************************************************************************/
786   /*************************************************************************/
787   /*************************************************************************/
788   /****                                                                 ****/
789   /****                                                                 ****/
790   /****                    F O N T   D R I V E R S                      ****/
791   /****                                                                 ****/
792   /****                                                                 ****/
793   /*************************************************************************/
794   /*************************************************************************/
795   /*************************************************************************/
796 
797 
798   /* typecast a module into a driver easily */
799 #define FT_DRIVER( x )  ( (FT_Driver)(x) )
800 
801   /* typecast a module as a driver, and get its driver class */
802 #define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz
803 
804 
805   /*************************************************************************/
806   /*                                                                       */
807   /* <Struct>                                                              */
808   /*    FT_DriverRec                                                       */
809   /*                                                                       */
810   /* <Description>                                                         */
811   /*    The root font driver class.  A font driver is responsible for      */
812   /*    managing and loading font files of a given format.                 */
813   /*                                                                       */
814   /*  <Fields>                                                             */
815   /*     root         :: Contains the fields of the root module class.     */
816   /*                                                                       */
817   /*     clazz        :: A pointer to the font driver's class.  Note that  */
818   /*                     this is NOT root.clazz.  `class' wasn't used      */
819   /*                     as it is a reserved word in C++.                  */
820   /*                                                                       */
821   /*     faces_list   :: The list of faces currently opened by this        */
822   /*                     driver.                                           */
823   /*                                                                       */
824   /*     glyph_loader :: Unused.  Used to be glyph loader for all faces    */
825   /*                     managed by this driver.                           */
826   /*                                                                       */
827   typedef struct  FT_DriverRec_
828   {
829     FT_ModuleRec     root;
830     FT_Driver_Class  clazz;
831     FT_ListRec       faces_list;
832     FT_GlyphLoader   glyph_loader;
833 
834   } FT_DriverRec;
835 
836 
837   /*************************************************************************/
838   /*************************************************************************/
839   /*************************************************************************/
840   /****                                                                 ****/
841   /****                                                                 ****/
842   /****                       L I B R A R I E S                         ****/
843   /****                                                                 ****/
844   /****                                                                 ****/
845   /*************************************************************************/
846   /*************************************************************************/
847   /*************************************************************************/
848 
849 
850   /* This hook is used by the TrueType debugger.  It must be set to an */
851   /* alternate truetype bytecode interpreter function.                 */
852 #define FT_DEBUG_HOOK_TRUETYPE  0
853 
854 
855   /*************************************************************************/
856   /*                                                                       */
857   /* <Struct>                                                              */
858   /*    FT_LibraryRec                                                      */
859   /*                                                                       */
860   /* <Description>                                                         */
861   /*    The FreeType library class.  This is the root of all FreeType      */
862   /*    data.  Use FT_New_Library() to create a library object, and        */
863   /*    FT_Done_Library() to discard it and all child objects.             */
864   /*                                                                       */
865   /* <Fields>                                                              */
866   /*    memory           :: The library's memory object.  Manages memory   */
867   /*                        allocation.                                    */
868   /*                                                                       */
869   /*    version_major    :: The major version number of the library.       */
870   /*                                                                       */
871   /*    version_minor    :: The minor version number of the library.       */
872   /*                                                                       */
873   /*    version_patch    :: The current patch level of the library.        */
874   /*                                                                       */
875   /*    num_modules      :: The number of modules currently registered     */
876   /*                        within this library.  This is set to 0 for new */
877   /*                        libraries.  New modules are added through the  */
878   /*                        FT_Add_Module() API function.                  */
879   /*                                                                       */
880   /*    modules          :: A table used to store handles to the currently */
881   /*                        registered modules. Note that each font driver */
882   /*                        contains a list of its opened faces.           */
883   /*                                                                       */
884   /*    renderers        :: The list of renderers currently registered     */
885   /*                        within the library.                            */
886   /*                                                                       */
887   /*    cur_renderer     :: The current outline renderer.  This is a       */
888   /*                        shortcut used to avoid parsing the list on     */
889   /*                        each call to FT_Outline_Render().  It is a     */
890   /*                        handle to the current renderer for the         */
891   /*                        FT_GLYPH_FORMAT_OUTLINE format.                */
892   /*                                                                       */
893   /*    auto_hinter      :: The auto-hinter module interface.              */
894   /*                                                                       */
895   /*    debug_hooks      :: An array of four function pointers that allow  */
896   /*                        debuggers to hook into a font format's         */
897   /*                        interpreter.  Currently, only the TrueType     */
898   /*                        bytecode debugger uses this.                   */
899   /*                                                                       */
900   /*    lcd_weights      :: If subpixel rendering is activated, the LCD    */
901   /*                        filter weights, if any.                        */
902   /*                                                                       */
903   /*    lcd_filter_func  :: If subpixel rendering is activated, the LCD    */
904   /*                        filtering callback function.                   */
905   /*                                                                       */
906   /*    pic_container    :: Contains global structs and tables, instead    */
907   /*                        of defining them globally.                     */
908   /*                                                                       */
909   /*    refcount         :: A counter initialized to~1 at the time an      */
910   /*                        @FT_Library structure is created.              */
911   /*                        @FT_Reference_Library increments this counter, */
912   /*                        and @FT_Done_Library only destroys a library   */
913   /*                        if the counter is~1, otherwise it simply       */
914   /*                        decrements it.                                 */
915   /*                                                                       */
916   typedef struct  FT_LibraryRec_
917   {
918     FT_Memory          memory;           /* library's memory manager */
919 
920     FT_Int             version_major;
921     FT_Int             version_minor;
922     FT_Int             version_patch;
923 
924     FT_UInt            num_modules;
925     FT_Module          modules[FT_MAX_MODULES];  /* module objects  */
926 
927     FT_ListRec         renderers;        /* list of renderers        */
928     FT_Renderer        cur_renderer;     /* current outline renderer */
929     FT_Module          auto_hinter;
930 
931     FT_DebugHook_Func  debug_hooks[4];
932 
933 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
934     FT_LcdFiveTapFilter      lcd_weights;      /* filter weights, if any */
935     FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
936 #endif
937 
938 #ifdef FT_CONFIG_OPTION_PIC
939     FT_PIC_Container   pic_container;
940 #endif
941 
942     FT_Int             refcount;
943 
944   } FT_LibraryRec;
945 
946 
947   FT_BASE( FT_Renderer )
948   FT_Lookup_Renderer( FT_Library       library,
949                       FT_Glyph_Format  format,
950                       FT_ListNode*     node );
951 
952   FT_BASE( FT_Error )
953   FT_Render_Glyph_Internal( FT_Library      library,
954                             FT_GlyphSlot    slot,
955                             FT_Render_Mode  render_mode );
956 
957   typedef const char*
958   (*FT_Face_GetPostscriptNameFunc)( FT_Face  face );
959 
960   typedef FT_Error
961   (*FT_Face_GetGlyphNameFunc)( FT_Face     face,
962                                FT_UInt     glyph_index,
963                                FT_Pointer  buffer,
964                                FT_UInt     buffer_max );
965 
966   typedef FT_UInt
967   (*FT_Face_GetGlyphNameIndexFunc)( FT_Face     face,
968                                     FT_String*  glyph_name );
969 
970 
971 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
972 
973   /*************************************************************************/
974   /*                                                                       */
975   /* <Function>                                                            */
976   /*    FT_New_Memory                                                      */
977   /*                                                                       */
978   /* <Description>                                                         */
979   /*    Creates a new memory object.                                       */
980   /*                                                                       */
981   /* <Return>                                                              */
982   /*    A pointer to the new memory object.  0 in case of error.           */
983   /*                                                                       */
984   FT_BASE( FT_Memory )
985   FT_New_Memory( void );
986 
987 
988   /*************************************************************************/
989   /*                                                                       */
990   /* <Function>                                                            */
991   /*    FT_Done_Memory                                                     */
992   /*                                                                       */
993   /* <Description>                                                         */
994   /*    Discards memory manager.                                           */
995   /*                                                                       */
996   /* <Input>                                                               */
997   /*    memory :: A handle to the memory manager.                          */
998   /*                                                                       */
999   FT_BASE( void )
1000   FT_Done_Memory( FT_Memory  memory );
1001 
1002 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
1003 
1004 
1005   /* Define default raster's interface.  The default raster is located in  */
1006   /* `src/base/ftraster.c'.                                                */
1007   /*                                                                       */
1008   /* Client applications can register new rasters through the              */
1009   /* FT_Set_Raster() API.                                                  */
1010 
1011 #ifndef FT_NO_DEFAULT_RASTER
1012   FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
1013 #endif
1014 
1015 
1016   /*************************************************************************/
1017   /*************************************************************************/
1018   /*************************************************************************/
1019   /****                                                                 ****/
1020   /****                                                                 ****/
1021   /****                      P I C   S U P P O R T                      ****/
1022   /****                                                                 ****/
1023   /****                                                                 ****/
1024   /*************************************************************************/
1025   /*************************************************************************/
1026   /*************************************************************************/
1027 
1028 
1029   /* PIC support macros for ftimage.h */
1030 
1031 
1032   /*************************************************************************/
1033   /*                                                                       */
1034   /* <Macro>                                                               */
1035   /*    FT_DEFINE_OUTLINE_FUNCS                                            */
1036   /*                                                                       */
1037   /* <Description>                                                         */
1038   /*    Used to initialize an instance of FT_Outline_Funcs struct.         */
1039   /*    When FT_CONFIG_OPTION_PIC is defined an init function will need    */
1040   /*    to be called with a pre-allocated structure to be filled.          */
1041   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
1042   /*    allocated in the global scope (or the scope where the macro        */
1043   /*    is used).                                                          */
1044   /*                                                                       */
1045 #ifndef FT_CONFIG_OPTION_PIC
1046 
1047 #define FT_DEFINE_OUTLINE_FUNCS(           \
1048           class_,                          \
1049           move_to_,                        \
1050           line_to_,                        \
1051           conic_to_,                       \
1052           cubic_to_,                       \
1053           shift_,                          \
1054           delta_ )                         \
1055   static const  FT_Outline_Funcs class_ =  \
1056   {                                        \
1057     move_to_,                              \
1058     line_to_,                              \
1059     conic_to_,                             \
1060     cubic_to_,                             \
1061     shift_,                                \
1062     delta_                                 \
1063   };
1064 
1065 #else /* FT_CONFIG_OPTION_PIC */
1066 
1067 #define FT_DEFINE_OUTLINE_FUNCS(                     \
1068           class_,                                    \
1069           move_to_,                                  \
1070           line_to_,                                  \
1071           conic_to_,                                 \
1072           cubic_to_,                                 \
1073           shift_,                                    \
1074           delta_ )                                   \
1075   static FT_Error                                    \
1076   Init_Class_ ## class_( FT_Outline_Funcs*  clazz )  \
1077   {                                                  \
1078     clazz->move_to  = move_to_;                      \
1079     clazz->line_to  = line_to_;                      \
1080     clazz->conic_to = conic_to_;                     \
1081     clazz->cubic_to = cubic_to_;                     \
1082     clazz->shift    = shift_;                        \
1083     clazz->delta    = delta_;                        \
1084                                                      \
1085     return FT_Err_Ok;                                \
1086   }
1087 
1088 #endif /* FT_CONFIG_OPTION_PIC */
1089 
1090 
1091   /*************************************************************************/
1092   /*                                                                       */
1093   /* <Macro>                                                               */
1094   /*    FT_DEFINE_RASTER_FUNCS                                             */
1095   /*                                                                       */
1096   /* <Description>                                                         */
1097   /*    Used to initialize an instance of FT_Raster_Funcs struct.          */
1098   /*    When FT_CONFIG_OPTION_PIC is defined an init function will need    */
1099   /*    to be called with a pre-allocated structure to be filled.          */
1100   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
1101   /*    allocated in the global scope (or the scope where the macro        */
1102   /*    is used).                                                          */
1103   /*                                                                       */
1104 #ifndef FT_CONFIG_OPTION_PIC
1105 
1106 #define FT_DEFINE_RASTER_FUNCS(    \
1107           class_,                  \
1108           glyph_format_,           \
1109           raster_new_,             \
1110           raster_reset_,           \
1111           raster_set_mode_,        \
1112           raster_render_,          \
1113           raster_done_ )           \
1114   const FT_Raster_Funcs  class_ =  \
1115   {                                \
1116     glyph_format_,                 \
1117     raster_new_,                   \
1118     raster_reset_,                 \
1119     raster_set_mode_,              \
1120     raster_render_,                \
1121     raster_done_                   \
1122   };
1123 
1124 #else /* FT_CONFIG_OPTION_PIC */
1125 
1126 #define FT_DEFINE_RASTER_FUNCS(                        \
1127           class_,                                      \
1128           glyph_format_,                               \
1129           raster_new_,                                 \
1130           raster_reset_,                               \
1131           raster_set_mode_,                            \
1132           raster_render_,                              \
1133           raster_done_ )                               \
1134   void                                                 \
1135   FT_Init_Class_ ## class_( FT_Raster_Funcs*  clazz )  \
1136   {                                                    \
1137     clazz->glyph_format    = glyph_format_;            \
1138     clazz->raster_new      = raster_new_;              \
1139     clazz->raster_reset    = raster_reset_;            \
1140     clazz->raster_set_mode = raster_set_mode_;         \
1141     clazz->raster_render   = raster_render_;           \
1142     clazz->raster_done     = raster_done_;             \
1143   }
1144 
1145 #endif /* FT_CONFIG_OPTION_PIC */
1146 
1147 
1148   /* PIC support macros for ftrender.h */
1149 
1150 
1151   /*************************************************************************/
1152   /*                                                                       */
1153   /* <Macro>                                                               */
1154   /*    FT_DEFINE_GLYPH                                                    */
1155   /*                                                                       */
1156   /* <Description>                                                         */
1157   /*    Used to initialize an instance of FT_Glyph_Class struct.           */
1158   /*    When FT_CONFIG_OPTION_PIC is defined an init function will need    */
1159   /*    to be called with a pre-allocated structure to be filled.          */
1160   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
1161   /*    allocated in the global scope (or the scope where the macro        */
1162   /*    is used).                                                          */
1163   /*                                                                       */
1164 #ifndef FT_CONFIG_OPTION_PIC
1165 
1166 #define FT_DEFINE_GLYPH(          \
1167           class_,                 \
1168           size_,                  \
1169           format_,                \
1170           init_,                  \
1171           done_,                  \
1172           copy_,                  \
1173           transform_,             \
1174           bbox_,                  \
1175           prepare_ )              \
1176   FT_CALLBACK_TABLE_DEF           \
1177   const FT_Glyph_Class  class_ =  \
1178   {                               \
1179     size_,                        \
1180     format_,                      \
1181     init_,                        \
1182     done_,                        \
1183     copy_,                        \
1184     transform_,                   \
1185     bbox_,                        \
1186     prepare_                      \
1187   };
1188 
1189 #else /* FT_CONFIG_OPTION_PIC */
1190 
1191 #define FT_DEFINE_GLYPH(                              \
1192           class_,                                     \
1193           size_,                                      \
1194           format_,                                    \
1195           init_,                                      \
1196           done_,                                      \
1197           copy_,                                      \
1198           transform_,                                 \
1199           bbox_,                                      \
1200           prepare_ )                                  \
1201   void                                                \
1202   FT_Init_Class_ ## class_( FT_Glyph_Class*  clazz )  \
1203   {                                                   \
1204     clazz->glyph_size      = size_;                   \
1205     clazz->glyph_format    = format_;                 \
1206     clazz->glyph_init      = init_;                   \
1207     clazz->glyph_done      = done_;                   \
1208     clazz->glyph_copy      = copy_;                   \
1209     clazz->glyph_transform = transform_;              \
1210     clazz->glyph_bbox      = bbox_;                   \
1211     clazz->glyph_prepare   = prepare_;                \
1212   }
1213 
1214 #endif /* FT_CONFIG_OPTION_PIC */
1215 
1216 
1217   /*************************************************************************/
1218   /*                                                                       */
1219   /* <Macro>                                                               */
1220   /*    FT_DECLARE_RENDERER                                                */
1221   /*                                                                       */
1222   /* <Description>                                                         */
1223   /*    Used to create a forward declaration of a                          */
1224   /*    FT_Renderer_Class struct instance.                                 */
1225   /*                                                                       */
1226   /* <Macro>                                                               */
1227   /*    FT_DEFINE_RENDERER                                                 */
1228   /*                                                                       */
1229   /* <Description>                                                         */
1230   /*    Used to initialize an instance of FT_Renderer_Class struct.        */
1231   /*                                                                       */
1232   /*    When FT_CONFIG_OPTION_PIC is defined a `create' function will      */
1233   /*    need to be called with a pointer where the allocated structure is  */
1234   /*    returned.  And when it is no longer needed a `destroy' function    */
1235   /*    needs to be called to release that allocation.                     */
1236   /*    `ftinit.c' (ft_create_default_module_classes) already contains     */
1237   /*    a mechanism to call these functions for the default modules        */
1238   /*    described in `ftmodule.h'.                                         */
1239   /*                                                                       */
1240   /*    Notice that the created `create' and `destroy' functions call      */
1241   /*    `pic_init' and `pic_free' to allow you to manually allocate and    */
1242   /*    initialize any additional global data, like a module specific      */
1243   /*    interface, and put them in the global pic container defined in     */
1244   /*    `ftpic.h'.  If you don't need them just implement the functions as */
1245   /*    empty to resolve the link error.  Also the `pic_init' and          */
1246   /*    `pic_free' functions should be declared in `pic.h', to be referred */
1247   /*    by the renderer definition calling `FT_DEFINE_RENDERER' in the     */
1248   /*    following.                                                         */
1249   /*                                                                       */
1250   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
1251   /*    allocated in the global scope (or the scope where the macro        */
1252   /*    is used).                                                          */
1253   /*                                                                       */
1254 #ifndef FT_CONFIG_OPTION_PIC
1255 
1256 #define FT_DECLARE_RENDERER( class_ )               \
1257   FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
1258 
1259 #define FT_DEFINE_RENDERER(                  \
1260           class_,                            \
1261           flags_,                            \
1262           size_,                             \
1263           name_,                             \
1264           version_,                          \
1265           requires_,                         \
1266           interface_,                        \
1267           init_,                             \
1268           done_,                             \
1269           get_interface_,                    \
1270           glyph_format_,                     \
1271           render_glyph_,                     \
1272           transform_glyph_,                  \
1273           get_glyph_cbox_,                   \
1274           set_mode_,                         \
1275           raster_class_ )                    \
1276   FT_CALLBACK_TABLE_DEF                      \
1277   const FT_Renderer_Class  class_ =          \
1278   {                                          \
1279     FT_DEFINE_ROOT_MODULE( flags_,           \
1280                            size_,            \
1281                            name_,            \
1282                            version_,         \
1283                            requires_,        \
1284                            interface_,       \
1285                            init_,            \
1286                            done_,            \
1287                            get_interface_ )  \
1288     glyph_format_,                           \
1289                                              \
1290     render_glyph_,                           \
1291     transform_glyph_,                        \
1292     get_glyph_cbox_,                         \
1293     set_mode_,                               \
1294                                              \
1295     raster_class_                            \
1296   };
1297 
1298 #else /* FT_CONFIG_OPTION_PIC */
1299 
1300 #define FT_DECLARE_RENDERER( class_ )  FT_DECLARE_MODULE( class_ )
1301 
1302 #define FT_DEFINE_RENDERER(                                      \
1303           class_,                                                \
1304           flags_,                                                \
1305           size_,                                                 \
1306           name_,                                                 \
1307           version_,                                              \
1308           requires_,                                             \
1309           interface_,                                            \
1310           init_,                                                 \
1311           done_,                                                 \
1312           get_interface_,                                        \
1313           glyph_format_,                                         \
1314           render_glyph_,                                         \
1315           transform_glyph_,                                      \
1316           get_glyph_cbox_,                                       \
1317           set_mode_,                                             \
1318           raster_class_ )                                        \
1319   void                                                           \
1320   FT_Destroy_Class_ ## class_( FT_Library        library,        \
1321                                FT_Module_Class*  clazz )         \
1322   {                                                              \
1323     FT_Renderer_Class*  rclazz = (FT_Renderer_Class*)clazz;      \
1324     FT_Memory           memory = library->memory;                \
1325                                                                  \
1326                                                                  \
1327     class_ ## _pic_free( library );                              \
1328     if ( rclazz )                                                \
1329       FT_FREE( rclazz );                                         \
1330   }                                                              \
1331                                                                  \
1332                                                                  \
1333   FT_Error                                                       \
1334   FT_Create_Class_ ## class_( FT_Library         library,        \
1335                               FT_Module_Class**  output_class )  \
1336   {                                                              \
1337     FT_Renderer_Class*  clazz = NULL;                            \
1338     FT_Error            error;                                   \
1339     FT_Memory           memory = library->memory;                \
1340                                                                  \
1341                                                                  \
1342     if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) )                  \
1343       return error;                                              \
1344                                                                  \
1345     error = class_ ## _pic_init( library );                      \
1346     if ( error )                                                 \
1347     {                                                            \
1348       FT_FREE( clazz );                                          \
1349       return error;                                              \
1350     }                                                            \
1351                                                                  \
1352     FT_DEFINE_ROOT_MODULE( flags_,                               \
1353                            size_,                                \
1354                            name_,                                \
1355                            version_,                             \
1356                            requires_,                            \
1357                            interface_,                           \
1358                            init_,                                \
1359                            done_,                                \
1360                            get_interface_ )                      \
1361                                                                  \
1362     clazz->glyph_format    = glyph_format_;                      \
1363                                                                  \
1364     clazz->render_glyph    = render_glyph_;                      \
1365     clazz->transform_glyph = transform_glyph_;                   \
1366     clazz->get_glyph_cbox  = get_glyph_cbox_;                    \
1367     clazz->set_mode        = set_mode_;                          \
1368                                                                  \
1369     clazz->raster_class    = raster_class_;                      \
1370                                                                  \
1371     *output_class = (FT_Module_Class*)clazz;                     \
1372                                                                  \
1373     return FT_Err_Ok;                                            \
1374   }
1375 
1376 #endif /* FT_CONFIG_OPTION_PIC */
1377 
1378 
1379   /* PIC support macros for ftmodapi.h **/
1380 
1381 
1382 #ifdef FT_CONFIG_OPTION_PIC
1383 
1384   /*************************************************************************/
1385   /*                                                                       */
1386   /* <FuncType>                                                            */
1387   /*    FT_Module_Creator                                                  */
1388   /*                                                                       */
1389   /* <Description>                                                         */
1390   /*    A function used to create (allocate) a new module class object.    */
1391   /*    The object's members are initialized, but the module itself is     */
1392   /*    not.                                                               */
1393   /*                                                                       */
1394   /* <Input>                                                               */
1395   /*    memory       :: A handle to the memory manager.                    */
1396   /*    output_class :: Initialized with the newly allocated class.        */
1397   /*                                                                       */
1398   typedef FT_Error
1399   (*FT_Module_Creator)( FT_Memory          memory,
1400                         FT_Module_Class**  output_class );
1401 
1402   /*************************************************************************/
1403   /*                                                                       */
1404   /* <FuncType>                                                            */
1405   /*    FT_Module_Destroyer                                                */
1406   /*                                                                       */
1407   /* <Description>                                                         */
1408   /*    A function used to destroy (deallocate) a module class object.     */
1409   /*                                                                       */
1410   /* <Input>                                                               */
1411   /*    memory :: A handle to the memory manager.                          */
1412   /*    clazz  :: Module class to destroy.                                 */
1413   /*                                                                       */
1414   typedef void
1415   (*FT_Module_Destroyer)( FT_Memory         memory,
1416                           FT_Module_Class*  clazz );
1417 
1418 #endif
1419 
1420 
1421   /*************************************************************************/
1422   /*                                                                       */
1423   /* <Macro>                                                               */
1424   /*    FT_DECLARE_MODULE                                                  */
1425   /*                                                                       */
1426   /* <Description>                                                         */
1427   /*    Used to create a forward declaration of a                          */
1428   /*    FT_Module_Class struct instance.                                   */
1429   /*                                                                       */
1430   /* <Macro>                                                               */
1431   /*    FT_DEFINE_MODULE                                                   */
1432   /*                                                                       */
1433   /* <Description>                                                         */
1434   /*    Used to initialize an instance of an FT_Module_Class struct.       */
1435   /*                                                                       */
1436   /*    When FT_CONFIG_OPTION_PIC is defined a `create' function needs     */
1437   /*    to be called with a pointer where the allocated structure is       */
1438   /*    returned.  And when it is no longer needed a `destroy' function    */
1439   /*    needs to be called to release that allocation.                     */
1440   /*    `ftinit.c' (ft_create_default_module_classes) already contains     */
1441   /*    a mechanism to call these functions for the default modules        */
1442   /*    described in `ftmodule.h'.                                         */
1443   /*                                                                       */
1444   /*    Notice that the created `create' and `destroy' functions call      */
1445   /*    `pic_init' and `pic_free' to allow you to manually allocate and    */
1446   /*    initialize any additional global data, like a module specific      */
1447   /*    interface, and put them in the global pic container defined in     */
1448   /*    `ftpic.h'.  If you don't need them just implement the functions as */
1449   /*    empty to resolve the link error.  Also the `pic_init' and          */
1450   /*    `pic_free' functions should be declared in `pic.h', to be referred */
1451   /*    by the module definition calling `FT_DEFINE_MODULE' in the         */
1452   /*    following.                                                         */
1453   /*                                                                       */
1454   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
1455   /*    allocated in the global scope (or the scope where the macro        */
1456   /*    is used).                                                          */
1457   /*                                                                       */
1458   /* <Macro>                                                               */
1459   /*    FT_DEFINE_ROOT_MODULE                                              */
1460   /*                                                                       */
1461   /* <Description>                                                         */
1462   /*    Used to initialize an instance of an FT_Module_Class struct inside */
1463   /*    another struct that contains it or in a function that initializes  */
1464   /*    that containing struct.                                            */
1465   /*                                                                       */
1466 #ifndef FT_CONFIG_OPTION_PIC
1467 
1468 #define FT_DECLARE_MODULE( class_ )  \
1469   FT_CALLBACK_TABLE                  \
1470   const FT_Module_Class  class_;
1471 
1472 #define FT_DEFINE_ROOT_MODULE(  \
1473           flags_,               \
1474           size_,                \
1475           name_,                \
1476           version_,             \
1477           requires_,            \
1478           interface_,           \
1479           init_,                \
1480           done_,                \
1481           get_interface_ )      \
1482   {                             \
1483     flags_,                     \
1484     size_,                      \
1485                                 \
1486     name_,                      \
1487     version_,                   \
1488     requires_,                  \
1489                                 \
1490     interface_,                 \
1491                                 \
1492     init_,                      \
1493     done_,                      \
1494     get_interface_,             \
1495   },
1496 
1497 #define FT_DEFINE_MODULE(         \
1498           class_,                 \
1499           flags_,                 \
1500           size_,                  \
1501           name_,                  \
1502           version_,               \
1503           requires_,              \
1504           interface_,             \
1505           init_,                  \
1506           done_,                  \
1507           get_interface_ )        \
1508   FT_CALLBACK_TABLE_DEF           \
1509   const FT_Module_Class class_ =  \
1510   {                               \
1511     flags_,                       \
1512     size_,                        \
1513                                   \
1514     name_,                        \
1515     version_,                     \
1516     requires_,                    \
1517                                   \
1518     interface_,                   \
1519                                   \
1520     init_,                        \
1521     done_,                        \
1522     get_interface_,               \
1523   };
1524 
1525 
1526 #else /* FT_CONFIG_OPTION_PIC */
1527 
1528 #define FT_DECLARE_MODULE( class_ )                               \
1529   FT_Error                                                        \
1530   FT_Create_Class_ ## class_( FT_Library         library,         \
1531                               FT_Module_Class**  output_class );  \
1532   void                                                            \
1533   FT_Destroy_Class_ ## class_( FT_Library        library,         \
1534                                FT_Module_Class*  clazz );
1535 
1536 #define FT_DEFINE_ROOT_MODULE(                      \
1537           flags_,                                   \
1538           size_,                                    \
1539           name_,                                    \
1540           version_,                                 \
1541           requires_,                                \
1542           interface_,                               \
1543           init_,                                    \
1544           done_,                                    \
1545           get_interface_ )                          \
1546     clazz->root.module_flags     = flags_;          \
1547     clazz->root.module_size      = size_;           \
1548     clazz->root.module_name      = name_;           \
1549     clazz->root.module_version   = version_;        \
1550     clazz->root.module_requires  = requires_;       \
1551                                                     \
1552     clazz->root.module_interface = interface_;      \
1553                                                     \
1554     clazz->root.module_init      = init_;           \
1555     clazz->root.module_done      = done_;           \
1556     clazz->root.get_interface    = get_interface_;
1557 
1558 #define FT_DEFINE_MODULE(                                        \
1559           class_,                                                \
1560           flags_,                                                \
1561           size_,                                                 \
1562           name_,                                                 \
1563           version_,                                              \
1564           requires_,                                             \
1565           interface_,                                            \
1566           init_,                                                 \
1567           done_,                                                 \
1568           get_interface_ )                                       \
1569   void                                                           \
1570   FT_Destroy_Class_ ## class_( FT_Library        library,        \
1571                                FT_Module_Class*  clazz )         \
1572   {                                                              \
1573     FT_Memory memory = library->memory;                          \
1574                                                                  \
1575                                                                  \
1576     class_ ## _pic_free( library );                              \
1577     if ( clazz )                                                 \
1578       FT_FREE( clazz );                                          \
1579   }                                                              \
1580                                                                  \
1581                                                                  \
1582   FT_Error                                                       \
1583   FT_Create_Class_ ## class_( FT_Library         library,        \
1584                               FT_Module_Class**  output_class )  \
1585   {                                                              \
1586     FT_Memory         memory = library->memory;                  \
1587     FT_Module_Class*  clazz  = NULL;                             \
1588     FT_Error          error;                                     \
1589                                                                  \
1590                                                                  \
1591     if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) )                  \
1592       return error;                                              \
1593     error = class_ ## _pic_init( library );                      \
1594     if ( error )                                                 \
1595     {                                                            \
1596       FT_FREE( clazz );                                          \
1597       return error;                                              \
1598     }                                                            \
1599                                                                  \
1600     clazz->module_flags     = flags_;                            \
1601     clazz->module_size      = size_;                             \
1602     clazz->module_name      = name_;                             \
1603     clazz->module_version   = version_;                          \
1604     clazz->module_requires  = requires_;                         \
1605                                                                  \
1606     clazz->module_interface = interface_;                        \
1607                                                                  \
1608     clazz->module_init      = init_;                             \
1609     clazz->module_done      = done_;                             \
1610     clazz->get_interface    = get_interface_;                    \
1611                                                                  \
1612     *output_class = clazz;                                       \
1613                                                                  \
1614     return FT_Err_Ok;                                            \
1615   }
1616 
1617 #endif /* FT_CONFIG_OPTION_PIC */
1618 
1619 
1620 FT_END_HEADER
1621 
1622 #endif /* FTOBJS_H_ */
1623 
1624 
1625 /* END */
1626