Home | History | Annotate | Download | only in internal
      1 /***************************************************************************/
      2 /*                                                                         */
      3 /*  ftobjs.h                                                               */
      4 /*                                                                         */
      5 /*    The FreeType private base classes (specification).                   */
      6 /*                                                                         */
      7 /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 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 
     40 #ifdef FT_CONFIG_OPTION_INCREMENTAL
     41 #include FT_INCREMENTAL_H
     42 #endif
     43 
     44 
     45 FT_BEGIN_HEADER
     46 
     47 
     48   /*************************************************************************/
     49   /*                                                                       */
     50   /* Some generic definitions.                                             */
     51   /*                                                                       */
     52 #ifndef TRUE
     53 #define TRUE  1
     54 #endif
     55 
     56 #ifndef FALSE
     57 #define FALSE  0
     58 #endif
     59 
     60 #ifndef NULL
     61 #define NULL  (void*)0
     62 #endif
     63 
     64 
     65   /*************************************************************************/
     66   /*                                                                       */
     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.           */
     69   /*                                                                       */
     70 #define FT_MIN( a, b )  ( (a) < (b) ? (a) : (b) )
     71 #define FT_MAX( a, b )  ( (a) > (b) ? (a) : (b) )
     72 
     73 #define FT_ABS( a )     ( (a) < 0 ? -(a) : (a) )
     74 
     75 
     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 )
     79 
     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 )
     83 
     84 
     85   /*
     86    *  Return the highest power of 2 that is <= value; this correspond to
     87    *  the highest bit in a given 32-bit value.
     88    */
     89   FT_BASE( FT_UInt32 )
     90   ft_highpow2( FT_UInt32  value );
     91 
     92 
     93   /*
     94    *  character classification functions -- since these are used to parse
     95    *  font files, we must not use those in <ctypes.h> which are
     96    *  locale-dependent
     97    */
     98 #define  ft_isdigit( x )   ( ( (unsigned)(x) - '0' ) < 10U )
     99 
    100 #define  ft_isxdigit( x )  ( ( (unsigned)(x) - '0' ) < 10U || \
    101                              ( (unsigned)(x) - 'a' ) < 6U  || \
    102                              ( (unsigned)(x) - 'A' ) < 6U  )
    103 
    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 )
    107 
    108 #define  ft_isalpha( x )  ( ft_isupper( x ) || ft_islower( x ) )
    109 #define  ft_isalnum( x )  ( ft_isdigit( x ) || ft_isalpha( x ) )
    110 
    111 
    112   /*************************************************************************/
    113   /*************************************************************************/
    114   /*************************************************************************/
    115   /****                                                                 ****/
    116   /****                                                                 ****/
    117   /****                       C H A R M A P S                           ****/
    118   /****                                                                 ****/
    119   /****                                                                 ****/
    120   /*************************************************************************/
    121   /*************************************************************************/
    122   /*************************************************************************/
    123 
    124   /* handle to internal charmap object */
    125   typedef struct FT_CMapRec_*              FT_CMap;
    126 
    127   /* handle to charmap class structure */
    128   typedef const struct FT_CMap_ClassRec_*  FT_CMap_Class;
    129 
    130   /* internal charmap object structure */
    131   typedef struct  FT_CMapRec_
    132   {
    133     FT_CharMapRec  charmap;
    134     FT_CMap_Class  clazz;
    135 
    136   } FT_CMapRec;
    137 
    138   /* typecase any pointer to a charmap handle */
    139 #define FT_CMAP( x )              ((FT_CMap)( x ))
    140 
    141   /* obvious macros */
    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
    146 
    147 
    148   /* class method definitions */
    149   typedef FT_Error
    150   (*FT_CMap_InitFunc)( FT_CMap     cmap,
    151                        FT_Pointer  init_data );
    152 
    153   typedef void
    154   (*FT_CMap_DoneFunc)( FT_CMap  cmap );
    155 
    156   typedef FT_UInt
    157   (*FT_CMap_CharIndexFunc)( FT_CMap    cmap,
    158                             FT_UInt32  char_code );
    159 
    160   typedef FT_UInt
    161   (*FT_CMap_CharNextFunc)( FT_CMap     cmap,
    162                            FT_UInt32  *achar_code );
    163 
    164   typedef FT_UInt
    165   (*FT_CMap_CharVarIndexFunc)( FT_CMap    cmap,
    166                                FT_CMap    unicode_cmap,
    167                                FT_UInt32  char_code,
    168                                FT_UInt32  variant_selector );
    169 
    170   typedef FT_Bool
    171   (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap    cmap,
    172                                    FT_UInt32  char_code,
    173                                    FT_UInt32  variant_selector );
    174 
    175   typedef FT_UInt32 *
    176   (*FT_CMap_VariantListFunc)( FT_CMap    cmap,
    177                               FT_Memory  mem );
    178 
    179   typedef FT_UInt32 *
    180   (*FT_CMap_CharVariantListFunc)( FT_CMap    cmap,
    181                                   FT_Memory  mem,
    182                                   FT_UInt32  char_code );
    183 
    184   typedef FT_UInt32 *
    185   (*FT_CMap_VariantCharListFunc)( FT_CMap    cmap,
    186                                   FT_Memory  mem,
    187                                   FT_UInt32  variant_selector );
    188 
    189 
    190   typedef struct  FT_CMap_ClassRec_
    191   {
    192     FT_ULong               size;
    193     FT_CMap_InitFunc       init;
    194     FT_CMap_DoneFunc       done;
    195     FT_CMap_CharIndexFunc  char_index;
    196     FT_CMap_CharNextFunc   char_next;
    197 
    198     /* Subsequent entries are special ones for format 14 -- the variant */
    199     /* selector subtable which behaves like no other                    */
    200 
    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;
    206 
    207   } FT_CMap_ClassRec;
    208 
    209 #ifndef FT_CONFIG_OPTION_PIC
    210 
    211 #define FT_DECLARE_CMAP_CLASS(class_) \
    212     FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
    213 
    214 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_,       \
    215         char_next_, char_var_index_, char_var_default_, variant_list_,       \
    216         charvariant_list_, variantchar_list_)                                \
    217   FT_CALLBACK_TABLE_DEF                                                      \
    218   const FT_CMap_ClassRec class_ =                                            \
    219   {                                                                          \
    220     size_, init_, done_, char_index_, char_next_, char_var_index_,           \
    221     char_var_default_, variant_list_, charvariant_list_, variantchar_list_   \
    222   };
    223 #else /* FT_CONFIG_OPTION_PIC */
    224 
    225 #define FT_DECLARE_CMAP_CLASS(class_) \
    226     void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec*  clazz);
    227 
    228 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_,       \
    229         char_next_, char_var_index_, char_var_default_, variant_list_,       \
    230         charvariant_list_, variantchar_list_)                                \
    231   void                                                                       \
    232   FT_Init_Class_##class_( FT_Library library,                                \
    233                           FT_CMap_ClassRec*  clazz)                          \
    234   {                                                                          \
    235     FT_UNUSED(library);                                                      \
    236     clazz->size = size_;                                                     \
    237     clazz->init = init_;                                                     \
    238     clazz->done = done_;                                                     \
    239     clazz->char_index = char_index_;                                         \
    240     clazz->char_next = char_next_;                                           \
    241     clazz->char_var_index = char_var_index_;                                 \
    242     clazz->char_var_default = char_var_default_;                             \
    243     clazz->variant_list = variant_list_;                                     \
    244     clazz->charvariant_list = charvariant_list_;                             \
    245     clazz->variantchar_list = variantchar_list_;                             \
    246   }
    247 #endif /* FT_CONFIG_OPTION_PIC */
    248 
    249   /* create a new charmap and add it to charmap->face */
    250   FT_BASE( FT_Error )
    251   FT_CMap_New( FT_CMap_Class  clazz,
    252                FT_Pointer     init_data,
    253                FT_CharMap     charmap,
    254                FT_CMap       *acmap );
    255 
    256   /* destroy a charmap and remove it from face's list */
    257   FT_BASE( void )
    258   FT_CMap_Done( FT_CMap  cmap );
    259 
    260 
    261   /*************************************************************************/
    262   /*                                                                       */
    263   /* <Struct>                                                              */
    264   /*    FT_Face_InternalRec                                                */
    265   /*                                                                       */
    266   /* <Description>                                                         */
    267   /*    This structure contains the internal fields of each FT_Face        */
    268   /*    object.  These fields may change between different releases of     */
    269   /*    FreeType.                                                          */
    270   /*                                                                       */
    271   /* <Fields>                                                              */
    272   /*    max_points ::                                                      */
    273   /*      The maximal number of points used to store the vectorial outline */
    274   /*      of any glyph in this face.  If this value cannot be known in     */
    275   /*      advance, or if the face isn't scalable, this should be set to 0. */
    276   /*      Only relevant for scalable formats.                              */
    277   /*                                                                       */
    278   /*    max_contours ::                                                    */
    279   /*      The maximal number of contours used to store the vectorial       */
    280   /*      outline of any glyph in this face.  If this value cannot be      */
    281   /*      known in advance, or if the face isn't scalable, this should be  */
    282   /*      set to 0.  Only relevant for scalable formats.                   */
    283   /*                                                                       */
    284   /*    transform_matrix ::                                                */
    285   /*      A 2x2 matrix of 16.16 coefficients used to transform glyph       */
    286   /*      outlines after they are loaded from the font.  Only used by the  */
    287   /*      convenience functions.                                           */
    288   /*                                                                       */
    289   /*    transform_delta ::                                                 */
    290   /*      A translation vector used to transform glyph outlines after they */
    291   /*      are loaded from the font.  Only used by the convenience          */
    292   /*      functions.                                                       */
    293   /*                                                                       */
    294   /*    transform_flags ::                                                 */
    295   /*      Some flags used to classify the transform.  Only used by the     */
    296   /*      convenience functions.                                           */
    297   /*                                                                       */
    298   /*    services ::                                                        */
    299   /*      A cache for frequently used services.  It should be only         */
    300   /*      accessed with the macro `FT_FACE_LOOKUP_SERVICE'.                */
    301   /*                                                                       */
    302   /*    incremental_interface ::                                           */
    303   /*      If non-null, the interface through which glyph data and metrics  */
    304   /*      are loaded incrementally for faces that do not provide all of    */
    305   /*      this data when first opened.  This field exists only if          */
    306   /*      @FT_CONFIG_OPTION_INCREMENTAL is defined.                        */
    307   /*                                                                       */
    308   /*    ignore_unpatented_hinter ::                                        */
    309   /*      This boolean flag instructs the glyph loader to ignore the       */
    310   /*      native font hinter, if one is found.  This is exclusively used   */
    311   /*      in the case when the unpatented hinter is compiled within the    */
    312   /*      library.                                                         */
    313   /*                                                                       */
    314   typedef struct  FT_Face_InternalRec_
    315   {
    316 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
    317     FT_UShort           reserved1;
    318     FT_Short            reserved2;
    319 #endif
    320     FT_Matrix           transform_matrix;
    321     FT_Vector           transform_delta;
    322     FT_Int              transform_flags;
    323 
    324     FT_ServiceCacheRec  services;
    325 
    326 #ifdef FT_CONFIG_OPTION_INCREMENTAL
    327     FT_Incremental_InterfaceRec*  incremental_interface;
    328 #endif
    329 
    330     FT_Bool             ignore_unpatented_hinter;
    331 
    332   } FT_Face_InternalRec;
    333 
    334 
    335   /*************************************************************************/
    336   /*                                                                       */
    337   /* <Struct>                                                              */
    338   /*    FT_Slot_InternalRec                                                */
    339   /*                                                                       */
    340   /* <Description>                                                         */
    341   /*    This structure contains the internal fields of each FT_GlyphSlot   */
    342   /*    object.  These fields may change between different releases of     */
    343   /*    FreeType.                                                          */
    344   /*                                                                       */
    345   /* <Fields>                                                              */
    346   /*    loader            :: The glyph loader object used to load outlines */
    347   /*                         into the glyph slot.                          */
    348   /*                                                                       */
    349   /*    flags             :: Possible values are zero or                   */
    350   /*                         FT_GLYPH_OWN_BITMAP.  The latter indicates    */
    351   /*                         that the FT_GlyphSlot structure owns the      */
    352   /*                         bitmap buffer.                                */
    353   /*                                                                       */
    354   /*    glyph_transformed :: Boolean.  Set to TRUE when the loaded glyph   */
    355   /*                         must be transformed through a specific        */
    356   /*                         font transformation.  This is _not_ the same  */
    357   /*                         as the face transform set through             */
    358   /*                         FT_Set_Transform().                           */
    359   /*                                                                       */
    360   /*    glyph_matrix      :: The 2x2 matrix corresponding to the glyph     */
    361   /*                         transformation, if necessary.                 */
    362   /*                                                                       */
    363   /*    glyph_delta       :: The 2d translation vector corresponding to    */
    364   /*                         the glyph transformation, if necessary.       */
    365   /*                                                                       */
    366   /*    glyph_hints       :: Format-specific glyph hints management.       */
    367   /*                                                                       */
    368 
    369 #define FT_GLYPH_OWN_BITMAP  0x1
    370 
    371   typedef struct  FT_Slot_InternalRec_
    372   {
    373     FT_GlyphLoader  loader;
    374     FT_UInt         flags;
    375     FT_Bool         glyph_transformed;
    376     FT_Matrix       glyph_matrix;
    377     FT_Vector       glyph_delta;
    378     void*           glyph_hints;
    379 
    380   } FT_GlyphSlot_InternalRec;
    381 
    382 
    383 #if 0
    384 
    385   /*************************************************************************/
    386   /*                                                                       */
    387   /* <Struct>                                                              */
    388   /*    FT_Size_InternalRec                                                */
    389   /*                                                                       */
    390   /* <Description>                                                         */
    391   /*    This structure contains the internal fields of each FT_Size        */
    392   /*    object.  Currently, it's empty.                                    */
    393   /*                                                                       */
    394   /*************************************************************************/
    395 
    396   typedef struct  FT_Size_InternalRec_
    397   {
    398     /* empty */
    399 
    400   } FT_Size_InternalRec;
    401 
    402 #endif
    403 
    404 
    405   /*************************************************************************/
    406   /*************************************************************************/
    407   /****                                                                 ****/
    408   /****                                                                 ****/
    409   /****                         M O D U L E S                           ****/
    410   /****                                                                 ****/
    411   /****                                                                 ****/
    412   /*************************************************************************/
    413   /*************************************************************************/
    414   /*************************************************************************/
    415 
    416 
    417   /*************************************************************************/
    418   /*                                                                       */
    419   /* <Struct>                                                              */
    420   /*    FT_ModuleRec                                                       */
    421   /*                                                                       */
    422   /* <Description>                                                         */
    423   /*    A module object instance.                                          */
    424   /*                                                                       */
    425   /* <Fields>                                                              */
    426   /*    clazz   :: A pointer to the module's class.                        */
    427   /*                                                                       */
    428   /*    library :: A handle to the parent library object.                  */
    429   /*                                                                       */
    430   /*    memory  :: A handle to the memory manager.                         */
    431   /*                                                                       */
    432   /*    generic :: A generic structure for user-level extensibility (?).   */
    433   /*                                                                       */
    434   typedef struct  FT_ModuleRec_
    435   {
    436     FT_Module_Class*  clazz;
    437     FT_Library        library;
    438     FT_Memory         memory;
    439     FT_Generic        generic;
    440 
    441   } FT_ModuleRec;
    442 
    443 
    444   /* typecast an object to a FT_Module */
    445 #define FT_MODULE( x )          ((FT_Module)( x ))
    446 #define FT_MODULE_CLASS( x )    FT_MODULE( x )->clazz
    447 #define FT_MODULE_LIBRARY( x )  FT_MODULE( x )->library
    448 #define FT_MODULE_MEMORY( x )   FT_MODULE( x )->memory
    449 
    450 
    451 #define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    452                                     FT_MODULE_FONT_DRIVER )
    453 
    454 #define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    455                                       FT_MODULE_RENDERER )
    456 
    457 #define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    458                                     FT_MODULE_HINTER )
    459 
    460 #define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    461                                     FT_MODULE_STYLER )
    462 
    463 #define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    464                                       FT_MODULE_DRIVER_SCALABLE )
    465 
    466 #define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS( x )->module_flags & \
    467                                          FT_MODULE_DRIVER_NO_OUTLINES )
    468 
    469 #define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
    470                                      FT_MODULE_DRIVER_HAS_HINTER )
    471 
    472 
    473   /*************************************************************************/
    474   /*                                                                       */
    475   /* <Function>                                                            */
    476   /*    FT_Get_Module_Interface                                            */
    477   /*                                                                       */
    478   /* <Description>                                                         */
    479   /*    Finds a module and returns its specific interface as a typeless    */
    480   /*    pointer.                                                           */
    481   /*                                                                       */
    482   /* <Input>                                                               */
    483   /*    library     :: A handle to the library object.                     */
    484   /*                                                                       */
    485   /*    module_name :: The module's name (as an ASCII string).             */
    486   /*                                                                       */
    487   /* <Return>                                                              */
    488   /*    A module-specific interface if available, 0 otherwise.             */
    489   /*                                                                       */
    490   /* <Note>                                                                */
    491   /*    You should better be familiar with FreeType internals to know      */
    492   /*    which module to look for, and what its interface is :-)            */
    493   /*                                                                       */
    494   FT_BASE( const void* )
    495   FT_Get_Module_Interface( FT_Library   library,
    496                            const char*  mod_name );
    497 
    498   FT_BASE( FT_Pointer )
    499   ft_module_get_service( FT_Module    module,
    500                          const char*  service_id );
    501 
    502  /* */
    503 
    504 
    505   /*************************************************************************/
    506   /*************************************************************************/
    507   /*************************************************************************/
    508   /****                                                                 ****/
    509   /****                                                                 ****/
    510   /****               FACE, SIZE & GLYPH SLOT OBJECTS                   ****/
    511   /****                                                                 ****/
    512   /****                                                                 ****/
    513   /*************************************************************************/
    514   /*************************************************************************/
    515   /*************************************************************************/
    516 
    517   /* a few macros used to perform easy typecasts with minimal brain damage */
    518 
    519 #define FT_FACE( x )          ((FT_Face)(x))
    520 #define FT_SIZE( x )          ((FT_Size)(x))
    521 #define FT_SLOT( x )          ((FT_GlyphSlot)(x))
    522 
    523 #define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
    524 #define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
    525 #define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
    526 #define FT_FACE_STREAM( x )   FT_FACE( x )->stream
    527 
    528 #define FT_SIZE_FACE( x )     FT_SIZE( x )->face
    529 #define FT_SLOT_FACE( x )     FT_SLOT( x )->face
    530 
    531 #define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
    532 #define FT_FACE_SIZE( x )     FT_FACE( x )->size
    533 
    534 
    535   /*************************************************************************/
    536   /*                                                                       */
    537   /* <Function>                                                            */
    538   /*    FT_New_GlyphSlot                                                   */
    539   /*                                                                       */
    540   /* <Description>                                                         */
    541   /*    It is sometimes useful to have more than one glyph slot for a      */
    542   /*    given face object.  This function is used to create additional     */
    543   /*    slots.  All of them are automatically discarded when the face is   */
    544   /*    destroyed.                                                         */
    545   /*                                                                       */
    546   /* <Input>                                                               */
    547   /*    face  :: A handle to a parent face object.                         */
    548   /*                                                                       */
    549   /* <Output>                                                              */
    550   /*    aslot :: A handle to a new glyph slot object.                      */
    551   /*                                                                       */
    552   /* <Return>                                                              */
    553   /*    FreeType error code.  0 means success.                             */
    554   /*                                                                       */
    555   FT_BASE( FT_Error )
    556   FT_New_GlyphSlot( FT_Face        face,
    557                     FT_GlyphSlot  *aslot );
    558 
    559 
    560   /*************************************************************************/
    561   /*                                                                       */
    562   /* <Function>                                                            */
    563   /*    FT_Done_GlyphSlot                                                  */
    564   /*                                                                       */
    565   /* <Description>                                                         */
    566   /*    Destroys a given glyph slot.  Remember however that all slots are  */
    567   /*    automatically destroyed with its parent.  Using this function is   */
    568   /*    not always mandatory.                                              */
    569   /*                                                                       */
    570   /* <Input>                                                               */
    571   /*    slot :: A handle to a target glyph slot.                           */
    572   /*                                                                       */
    573   FT_BASE( void )
    574   FT_Done_GlyphSlot( FT_GlyphSlot  slot );
    575 
    576  /* */
    577 
    578 #define FT_REQUEST_WIDTH( req )                                            \
    579           ( (req)->horiResolution                                          \
    580               ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
    581               : (req)->width )
    582 
    583 #define FT_REQUEST_HEIGHT( req )                                            \
    584           ( (req)->vertResolution                                           \
    585               ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
    586               : (req)->height )
    587 
    588 
    589   /* Set the metrics according to a bitmap strike. */
    590   FT_BASE( void )
    591   FT_Select_Metrics( FT_Face   face,
    592                      FT_ULong  strike_index );
    593 
    594 
    595   /* Set the metrics according to a size request. */
    596   FT_BASE( void )
    597   FT_Request_Metrics( FT_Face          face,
    598                       FT_Size_Request  req );
    599 
    600 
    601   /* Match a size request against `available_sizes'. */
    602   FT_BASE( FT_Error )
    603   FT_Match_Size( FT_Face          face,
    604                  FT_Size_Request  req,
    605                  FT_Bool          ignore_width,
    606                  FT_ULong*        size_index );
    607 
    608 
    609   /* Use the horizontal metrics to synthesize the vertical metrics. */
    610   /* If `advance' is zero, it is also synthesized.                  */
    611   FT_BASE( void )
    612   ft_synthesize_vertical_metrics( FT_Glyph_Metrics*  metrics,
    613                                   FT_Pos             advance );
    614 
    615 
    616   /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
    617   /* was allocated with ft_glyphslot_alloc_bitmap).                       */
    618   FT_BASE( void )
    619   ft_glyphslot_free_bitmap( FT_GlyphSlot  slot );
    620 
    621 
    622   /* Allocate a new bitmap buffer in a glyph slot. */
    623   FT_BASE( FT_Error )
    624   ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
    625                              FT_ULong      size );
    626 
    627 
    628   /* Set the bitmap buffer in a glyph slot to a given pointer.  The buffer */
    629   /* will not be freed by a later call to ft_glyphslot_free_bitmap.        */
    630   FT_BASE( void )
    631   ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
    632                            FT_Byte*      buffer );
    633 
    634 
    635   /*************************************************************************/
    636   /*************************************************************************/
    637   /*************************************************************************/
    638   /****                                                                 ****/
    639   /****                                                                 ****/
    640   /****                        R E N D E R E R S                        ****/
    641   /****                                                                 ****/
    642   /****                                                                 ****/
    643   /*************************************************************************/
    644   /*************************************************************************/
    645   /*************************************************************************/
    646 
    647 
    648 #define FT_RENDERER( x )      ((FT_Renderer)( x ))
    649 #define FT_GLYPH( x )         ((FT_Glyph)( x ))
    650 #define FT_BITMAP_GLYPH( x )  ((FT_BitmapGlyph)( x ))
    651 #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
    652 
    653 
    654   typedef struct  FT_RendererRec_
    655   {
    656     FT_ModuleRec            root;
    657     FT_Renderer_Class*      clazz;
    658     FT_Glyph_Format         glyph_format;
    659     FT_Glyph_Class          glyph_class;
    660 
    661     FT_Raster               raster;
    662     FT_Raster_Render_Func   raster_render;
    663     FT_Renderer_RenderFunc  render;
    664 
    665   } FT_RendererRec;
    666 
    667 
    668   /*************************************************************************/
    669   /*************************************************************************/
    670   /*************************************************************************/
    671   /****                                                                 ****/
    672   /****                                                                 ****/
    673   /****                    F O N T   D R I V E R S                      ****/
    674   /****                                                                 ****/
    675   /****                                                                 ****/
    676   /*************************************************************************/
    677   /*************************************************************************/
    678   /*************************************************************************/
    679 
    680 
    681   /* typecast a module into a driver easily */
    682 #define FT_DRIVER( x )        ((FT_Driver)(x))
    683 
    684   /* typecast a module as a driver, and get its driver class */
    685 #define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz
    686 
    687 
    688   /*************************************************************************/
    689   /*                                                                       */
    690   /* <Struct>                                                              */
    691   /*    FT_DriverRec                                                       */
    692   /*                                                                       */
    693   /* <Description>                                                         */
    694   /*    The root font driver class.  A font driver is responsible for      */
    695   /*    managing and loading font files of a given format.                 */
    696   /*                                                                       */
    697   /*  <Fields>                                                             */
    698   /*     root         :: Contains the fields of the root module class.     */
    699   /*                                                                       */
    700   /*     clazz        :: A pointer to the font driver's class.  Note that  */
    701   /*                     this is NOT root.clazz.  `class' wasn't used      */
    702   /*                     as it is a reserved word in C++.                  */
    703   /*                                                                       */
    704   /*     faces_list   :: The list of faces currently opened by this        */
    705   /*                     driver.                                           */
    706   /*                                                                       */
    707   /*     extensions   :: A typeless pointer to the driver's extensions     */
    708   /*                     registry, if they are supported through the       */
    709   /*                     configuration macro FT_CONFIG_OPTION_EXTENSIONS.  */
    710   /*                                                                       */
    711   /*     glyph_loader :: The glyph loader for all faces managed by this    */
    712   /*                     driver.  This object isn't defined for unscalable */
    713   /*                     formats.                                          */
    714   /*                                                                       */
    715   typedef struct  FT_DriverRec_
    716   {
    717     FT_ModuleRec     root;
    718     FT_Driver_Class  clazz;
    719 
    720     FT_ListRec       faces_list;
    721     void*            extensions;
    722 
    723     FT_GlyphLoader   glyph_loader;
    724 
    725   } FT_DriverRec;
    726 
    727 
    728   /*************************************************************************/
    729   /*************************************************************************/
    730   /*************************************************************************/
    731   /****                                                                 ****/
    732   /****                                                                 ****/
    733   /****                       L I B R A R I E S                         ****/
    734   /****                                                                 ****/
    735   /****                                                                 ****/
    736   /*************************************************************************/
    737   /*************************************************************************/
    738   /*************************************************************************/
    739 
    740 
    741   /* This hook is used by the TrueType debugger.  It must be set to an */
    742   /* alternate truetype bytecode interpreter function.                 */
    743 #define FT_DEBUG_HOOK_TRUETYPE            0
    744 
    745 
    746   /* Set this debug hook to a non-null pointer to force unpatented hinting */
    747   /* for all faces when both TT_USE_BYTECODE_INTERPRETER and               */
    748   /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined.  This is only used   */
    749   /* during debugging.                                                     */
    750 #define FT_DEBUG_HOOK_UNPATENTED_HINTING  1
    751 
    752 
    753   typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
    754                                             FT_Render_Mode  render_mode,
    755                                             FT_Library      library );
    756 
    757 
    758   /*************************************************************************/
    759   /*                                                                       */
    760   /* <Struct>                                                              */
    761   /*    FT_LibraryRec                                                      */
    762   /*                                                                       */
    763   /* <Description>                                                         */
    764   /*    The FreeType library class.  This is the root of all FreeType      */
    765   /*    data.  Use FT_New_Library() to create a library object, and        */
    766   /*    FT_Done_Library() to discard it and all child objects.             */
    767   /*                                                                       */
    768   /* <Fields>                                                              */
    769   /*    memory           :: The library's memory object.  Manages memory   */
    770   /*                        allocation.                                    */
    771   /*                                                                       */
    772   /*    generic          :: Client data variable.  Used to extend the      */
    773   /*                        Library class by higher levels and clients.    */
    774   /*                                                                       */
    775   /*    version_major    :: The major version number of the library.       */
    776   /*                                                                       */
    777   /*    version_minor    :: The minor version number of the library.       */
    778   /*                                                                       */
    779   /*    version_patch    :: The current patch level of the library.        */
    780   /*                                                                       */
    781   /*    num_modules      :: The number of modules currently registered     */
    782   /*                        within this library.  This is set to 0 for new */
    783   /*                        libraries.  New modules are added through the  */
    784   /*                        FT_Add_Module() API function.                  */
    785   /*                                                                       */
    786   /*    modules          :: A table used to store handles to the currently */
    787   /*                        registered modules. Note that each font driver */
    788   /*                        contains a list of its opened faces.           */
    789   /*                                                                       */
    790   /*    renderers        :: The list of renderers currently registered     */
    791   /*                        within the library.                            */
    792   /*                                                                       */
    793   /*    cur_renderer     :: The current outline renderer.  This is a       */
    794   /*                        shortcut used to avoid parsing the list on     */
    795   /*                        each call to FT_Outline_Render().  It is a     */
    796   /*                        handle to the current renderer for the         */
    797   /*                        FT_GLYPH_FORMAT_OUTLINE format.                */
    798   /*                                                                       */
    799   /*    auto_hinter      :: XXX                                            */
    800   /*                                                                       */
    801   /*    raster_pool      :: The raster object's render pool.  This can     */
    802   /*                        ideally be changed dynamically at run-time.    */
    803   /*                                                                       */
    804   /*    raster_pool_size :: The size of the render pool in bytes.          */
    805   /*                                                                       */
    806   /*    debug_hooks      :: XXX                                            */
    807   /*                                                                       */
    808   /*    pic_container    :: Contains global structs and tables, instead    */
    809   /*                        of defining them globallly.                    */
    810   /*                                                                       */
    811 
    812   typedef struct  FT_LibraryRec_
    813   {
    814     FT_Memory          memory;           /* library's memory manager */
    815 
    816     FT_Generic         generic;
    817 
    818     FT_Int             version_major;
    819     FT_Int             version_minor;
    820     FT_Int             version_patch;
    821 
    822     FT_UInt            num_modules;
    823     FT_Module          modules[FT_MAX_MODULES];  /* module objects  */
    824 
    825     FT_ListRec         renderers;        /* list of renderers        */
    826     FT_Renderer        cur_renderer;     /* current outline renderer */
    827     FT_Module          auto_hinter;
    828 
    829     FT_Byte*           raster_pool;      /* scan-line conversion */
    830                                          /* render pool          */
    831     FT_ULong           raster_pool_size; /* size of render pool in bytes */
    832 
    833     FT_DebugHook_Func  debug_hooks[4];
    834 
    835 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    836     FT_LcdFilter             lcd_filter;
    837     FT_Int                   lcd_extra;        /* number of extra pixels */
    838     FT_Byte                  lcd_weights[7];   /* filter weights, if any */
    839     FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
    840 #endif
    841 
    842 #ifdef FT_CONFIG_OPTION_PIC
    843     FT_PIC_Container   pic_container;
    844 #endif
    845 
    846   } FT_LibraryRec;
    847 
    848 
    849   FT_BASE( FT_Renderer )
    850   FT_Lookup_Renderer( FT_Library       library,
    851                       FT_Glyph_Format  format,
    852                       FT_ListNode*     node );
    853 
    854   FT_BASE( FT_Error )
    855   FT_Render_Glyph_Internal( FT_Library      library,
    856                             FT_GlyphSlot    slot,
    857                             FT_Render_Mode  render_mode );
    858 
    859   typedef const char*
    860   (*FT_Face_GetPostscriptNameFunc)( FT_Face  face );
    861 
    862   typedef FT_Error
    863   (*FT_Face_GetGlyphNameFunc)( FT_Face     face,
    864                                FT_UInt     glyph_index,
    865                                FT_Pointer  buffer,
    866                                FT_UInt     buffer_max );
    867 
    868   typedef FT_UInt
    869   (*FT_Face_GetGlyphNameIndexFunc)( FT_Face     face,
    870                                     FT_String*  glyph_name );
    871 
    872 
    873 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
    874 
    875   /*************************************************************************/
    876   /*                                                                       */
    877   /* <Function>                                                            */
    878   /*    FT_New_Memory                                                      */
    879   /*                                                                       */
    880   /* <Description>                                                         */
    881   /*    Creates a new memory object.                                       */
    882   /*                                                                       */
    883   /* <Return>                                                              */
    884   /*    A pointer to the new memory object.  0 in case of error.           */
    885   /*                                                                       */
    886   FT_BASE( FT_Memory )
    887   FT_New_Memory( void );
    888 
    889 
    890   /*************************************************************************/
    891   /*                                                                       */
    892   /* <Function>                                                            */
    893   /*    FT_Done_Memory                                                     */
    894   /*                                                                       */
    895   /* <Description>                                                         */
    896   /*    Discards memory manager.                                           */
    897   /*                                                                       */
    898   /* <Input>                                                               */
    899   /*    memory :: A handle to the memory manager.                          */
    900   /*                                                                       */
    901   FT_BASE( void )
    902   FT_Done_Memory( FT_Memory  memory );
    903 
    904 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
    905 
    906 
    907   /* Define default raster's interface.  The default raster is located in  */
    908   /* `src/base/ftraster.c'.                                                */
    909   /*                                                                       */
    910   /* Client applications can register new rasters through the              */
    911   /* FT_Set_Raster() API.                                                  */
    912 
    913 #ifndef FT_NO_DEFAULT_RASTER
    914   FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
    915 #endif
    916 
    917   /*************************************************************************/
    918   /*************************************************************************/
    919   /*************************************************************************/
    920   /****                                                                 ****/
    921   /****                                                                 ****/
    922   /****              PIC-Support Macros for ftimage.h                   ****/
    923   /****                                                                 ****/
    924   /****                                                                 ****/
    925   /*************************************************************************/
    926   /*************************************************************************/
    927   /*************************************************************************/
    928 
    929 
    930   /*************************************************************************/
    931   /*                                                                       */
    932   /* <Macro>                                                               */
    933   /*    FT_DEFINE_OUTLINE_FUNCS                                            */
    934   /*                                                                       */
    935   /* <Description>                                                         */
    936   /*    Used to initialize an instance of FT_Outline_Funcs struct.         */
    937   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
    938   /*    called with a pre-allocated stracture to be filled.                */
    939   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
    940   /*    allocated in the global scope (or the scope where the macro        */
    941   /*    is used).                                                          */
    942   /*                                                                       */
    943 #ifndef FT_CONFIG_OPTION_PIC
    944 
    945 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_,       \
    946                                 cubic_to_, shift_, delta_)                   \
    947   static const FT_Outline_Funcs class_ =                                     \
    948   {                                                                          \
    949     move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_                 \
    950   };
    951 
    952 #else /* FT_CONFIG_OPTION_PIC */
    953 
    954 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_,       \
    955                                 cubic_to_, shift_, delta_)                   \
    956   static FT_Error                                                            \
    957   Init_Class_##class_( FT_Outline_Funcs*  clazz )                            \
    958   {                                                                          \
    959     clazz->move_to = move_to_;                                               \
    960     clazz->line_to = line_to_;                                               \
    961     clazz->conic_to = conic_to_;                                             \
    962     clazz->cubic_to = cubic_to_;                                             \
    963     clazz->shift = shift_;                                                   \
    964     clazz->delta = delta_;                                                   \
    965     return FT_Err_Ok;                                                        \
    966   }
    967 
    968 #endif /* FT_CONFIG_OPTION_PIC */
    969 
    970   /*************************************************************************/
    971   /*                                                                       */
    972   /* <Macro>                                                               */
    973   /*    FT_DEFINE_RASTER_FUNCS                                             */
    974   /*                                                                       */
    975   /* <Description>                                                         */
    976   /*    Used to initialize an instance of FT_Raster_Funcs struct.          */
    977   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
    978   /*    called with a pre-allocated stracture to be filled.                */
    979   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
    980   /*    allocated in the global scope (or the scope where the macro        */
    981   /*    is used).                                                          */
    982   /*                                                                       */
    983 #ifndef FT_CONFIG_OPTION_PIC
    984 
    985 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_,           \
    986                                raster_reset_, raster_set_mode_,              \
    987                                raster_render_, raster_done_)                 \
    988   const FT_Raster_Funcs class_ =                                      \
    989   {                                                                          \
    990     glyph_format_, raster_new_, raster_reset_,                               \
    991     raster_set_mode_, raster_render_, raster_done_                           \
    992   };
    993 
    994 #else /* FT_CONFIG_OPTION_PIC */
    995 
    996 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_,           \
    997     raster_reset_, raster_set_mode_, raster_render_, raster_done_)           \
    998   void                                                                       \
    999   FT_Init_Class_##class_( FT_Raster_Funcs*  clazz )                          \
   1000   {                                                                          \
   1001     clazz->glyph_format = glyph_format_;                                     \
   1002     clazz->raster_new = raster_new_;                                         \
   1003     clazz->raster_reset = raster_reset_;                                     \
   1004     clazz->raster_set_mode = raster_set_mode_;                               \
   1005     clazz->raster_render = raster_render_;                                   \
   1006     clazz->raster_done = raster_done_;                                       \
   1007   }
   1008 
   1009 #endif /* FT_CONFIG_OPTION_PIC */
   1010 
   1011   /*************************************************************************/
   1012   /*************************************************************************/
   1013   /*************************************************************************/
   1014   /****                                                                 ****/
   1015   /****                                                                 ****/
   1016   /****              PIC-Support Macros for ftrender.h                  ****/
   1017   /****                                                                 ****/
   1018   /****                                                                 ****/
   1019   /*************************************************************************/
   1020   /*************************************************************************/
   1021   /*************************************************************************/
   1022 
   1023 
   1024 
   1025   /*************************************************************************/
   1026   /*                                                                       */
   1027   /* <Macro>                                                               */
   1028   /*    FT_DEFINE_GLYPH                                                    */
   1029   /*                                                                       */
   1030   /* <Description>                                                         */
   1031   /*    Used to initialize an instance of FT_Glyph_Class struct.           */
   1032   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
   1033   /*    called with a pre-allocated stracture to be filled.                */
   1034   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
   1035   /*    allocated in the global scope (or the scope where the macro        */
   1036   /*    is used).                                                          */
   1037   /*                                                                       */
   1038 #ifndef FT_CONFIG_OPTION_PIC
   1039 
   1040 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_,         \
   1041                         transform_, bbox_, prepare_)                         \
   1042   FT_CALLBACK_TABLE_DEF                                                      \
   1043   const FT_Glyph_Class class_ =                                              \
   1044   {                                                                          \
   1045     size_, format_, init_, done_, copy_, transform_, bbox_, prepare_         \
   1046   };
   1047 
   1048 #else /* FT_CONFIG_OPTION_PIC */
   1049 
   1050 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_,         \
   1051                         transform_, bbox_, prepare_)                         \
   1052   void                                                                       \
   1053   FT_Init_Class_##class_( FT_Glyph_Class*  clazz )                           \
   1054   {                                                                          \
   1055     clazz->glyph_size = size_;                                               \
   1056     clazz->glyph_format = format_;                                           \
   1057     clazz->glyph_init = init_;                                               \
   1058     clazz->glyph_done = done_;                                               \
   1059     clazz->glyph_copy = copy_;                                               \
   1060     clazz->glyph_transform = transform_;                                     \
   1061     clazz->glyph_bbox = bbox_;                                               \
   1062     clazz->glyph_prepare = prepare_;                                         \
   1063   }
   1064 
   1065 #endif /* FT_CONFIG_OPTION_PIC */
   1066 
   1067   /*************************************************************************/
   1068   /*                                                                       */
   1069   /* <Macro>                                                               */
   1070   /*    FT_DECLARE_RENDERER                                                */
   1071   /*                                                                       */
   1072   /* <Description>                                                         */
   1073   /*    Used to create a forward declaration of a                          */
   1074   /*    FT_Renderer_Class stract instance.                                 */
   1075   /*                                                                       */
   1076   /* <Macro>                                                               */
   1077   /*    FT_DEFINE_RENDERER                                                 */
   1078   /*                                                                       */
   1079   /* <Description>                                                         */
   1080   /*    Used to initialize an instance of FT_Renderer_Class struct.        */
   1081   /*                                                                       */
   1082   /*    When FT_CONFIG_OPTION_PIC is defined a Create funtion will need    */
   1083   /*    to called with a pointer where the allocated stracture is returned.*/
   1084   /*    And when it is no longer needed a Destroy function needs           */
   1085   /*    to be called to release that allocation.                           */
   1086   /*    fcinit.c (ft_create_default_module_classes) already contains       */
   1087   /*    a mechanism to call these functions for the default modules        */
   1088   /*    described in ftmodule.h                                            */
   1089   /*                                                                       */
   1090   /*    Notice that the created Create and Destroy functions call          */
   1091   /*    pic_init and pic_free function to allow you to manually allocate   */
   1092   /*    and initialize any additional global data, like module specific    */
   1093   /*    interface, and put them in the global pic container defined in     */
   1094   /*    ftpic.h. if you don't need them just implement the functions as    */
   1095   /*    empty to resolve the link error.                                   */
   1096   /*                                                                       */
   1097   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
   1098   /*    allocated in the global scope (or the scope where the macro        */
   1099   /*    is used).                                                          */
   1100   /*                                                                       */
   1101 #ifndef FT_CONFIG_OPTION_PIC
   1102 
   1103 #define FT_DECLARE_RENDERER(class_)                                          \
   1104     FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
   1105 
   1106 #define FT_DEFINE_RENDERER(class_,                                           \
   1107                            flags_, size_, name_, version_, requires_,        \
   1108                            interface_, init_, done_, get_interface_,         \
   1109                            glyph_format_, render_glyph_, transform_glyph_,   \
   1110                            get_glyph_cbox_, set_mode_, raster_class_ )       \
   1111   FT_CALLBACK_TABLE_DEF                                                      \
   1112   const FT_Renderer_Class  class_ =                                          \
   1113   {                                                                          \
   1114     FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,             \
   1115                           interface_,init_,done_,get_interface_)             \
   1116     glyph_format_,                                                           \
   1117                                                                              \
   1118     render_glyph_,                                                           \
   1119     transform_glyph_,                                                        \
   1120     get_glyph_cbox_,                                                         \
   1121     set_mode_,                                                               \
   1122                                                                              \
   1123     raster_class_                                                            \
   1124   };
   1125 
   1126 #else /* FT_CONFIG_OPTION_PIC */
   1127 
   1128 #define FT_DECLARE_RENDERER(class_)  FT_DECLARE_MODULE(class_)
   1129 
   1130 #define FT_DEFINE_RENDERER(class_, \
   1131                            flags_, size_, name_, version_, requires_,        \
   1132                            interface_, init_, done_, get_interface_,         \
   1133                            glyph_format_, render_glyph_, transform_glyph_,   \
   1134                            get_glyph_cbox_, set_mode_, raster_class_ )       \
   1135   void class_##_pic_free( FT_Library library );                              \
   1136   FT_Error class_##_pic_init( FT_Library library );                          \
   1137                                                                              \
   1138   void                                                                       \
   1139   FT_Destroy_Class_##class_( FT_Library        library,                      \
   1140                         FT_Module_Class*  clazz )                            \
   1141   {                                                                          \
   1142     FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz;                   \
   1143     FT_Memory         memory = library->memory;                              \
   1144     class_##_pic_free( library );                                            \
   1145     if ( rclazz )                                                            \
   1146       FT_FREE( rclazz );                                                     \
   1147   }                                                                          \
   1148                                                                              \
   1149   FT_Error                                                                   \
   1150   FT_Create_Class_##class_( FT_Library         library,                      \
   1151                             FT_Module_Class**  output_class )                \
   1152   {                                                                          \
   1153     FT_Renderer_Class*  clazz;                                               \
   1154     FT_Error            error;                                               \
   1155     FT_Memory           memory = library->memory;                            \
   1156                                                                              \
   1157     if ( FT_ALLOC( clazz, sizeof(*clazz) ) )                                 \
   1158       return error;                                                          \
   1159                                                                              \
   1160     error = class_##_pic_init( library );                                    \
   1161     if(error)                                                                \
   1162     {                                                                        \
   1163       FT_FREE( clazz );                                                      \
   1164       return error;                                                          \
   1165     }                                                                        \
   1166                                                                              \
   1167     FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,             \
   1168                           interface_,init_,done_,get_interface_)             \
   1169                                                                              \
   1170     clazz->glyph_format       = glyph_format_;                               \
   1171                                                                              \
   1172     clazz->render_glyph       = render_glyph_;                               \
   1173     clazz->transform_glyph    = transform_glyph_;                            \
   1174     clazz->get_glyph_cbox     = get_glyph_cbox_;                             \
   1175     clazz->set_mode           = set_mode_;                                   \
   1176                                                                              \
   1177     clazz->raster_class       = raster_class_;                               \
   1178                                                                              \
   1179     *output_class = (FT_Module_Class*)clazz;                                 \
   1180     return FT_Err_Ok;                                                        \
   1181   }
   1182 
   1183 
   1184 
   1185 #endif /* FT_CONFIG_OPTION_PIC */
   1186 
   1187   /*************************************************************************/
   1188   /*************************************************************************/
   1189   /*************************************************************************/
   1190   /****                                                                 ****/
   1191   /****                                                                 ****/
   1192   /****              PIC-Support Macros for ftmodapi.h                  ****/
   1193   /****                                                                 ****/
   1194   /****                                                                 ****/
   1195   /*************************************************************************/
   1196   /*************************************************************************/
   1197   /*************************************************************************/
   1198 
   1199 
   1200 #ifdef FT_CONFIG_OPTION_PIC
   1201 
   1202   /*************************************************************************/
   1203   /*                                                                       */
   1204   /* <FuncType>                                                            */
   1205   /*    FT_Module_Creator                                                  */
   1206   /*                                                                       */
   1207   /* <Description>                                                         */
   1208   /*    A function used to create (allocate) a new module class object.    */
   1209   /*    The object's members are initialized, but the module itself is     */
   1210   /*    not.                                                               */
   1211   /*                                                                       */
   1212   /* <Input>                                                               */
   1213   /*    memory       :: A handle to the memory manager.                    */
   1214   /*    output_class :: Initialized with the newly allocated class.        */
   1215   /*                                                                       */
   1216   typedef FT_Error
   1217   (*FT_Module_Creator)( FT_Memory          memory,
   1218                         FT_Module_Class**  output_class );
   1219 
   1220   /*************************************************************************/
   1221   /*                                                                       */
   1222   /* <FuncType>                                                            */
   1223   /*    FT_Module_Destroyer                                                */
   1224   /*                                                                       */
   1225   /* <Description>                                                         */
   1226   /*    A function used to destroy (deallocate) a module class object.     */
   1227   /*                                                                       */
   1228   /* <Input>                                                               */
   1229   /*    memory :: A handle to the memory manager.                          */
   1230   /*    clazz  :: Module class to destroy.                                 */
   1231   /*                                                                       */
   1232   typedef void
   1233   (*FT_Module_Destroyer)( FT_Memory         memory,
   1234                           FT_Module_Class*  clazz );
   1235 
   1236 #endif
   1237 
   1238   /*************************************************************************/
   1239   /*                                                                       */
   1240   /* <Macro>                                                               */
   1241   /*    FT_DECLARE_MODULE                                                  */
   1242   /*                                                                       */
   1243   /* <Description>                                                         */
   1244   /*    Used to create a forward declaration of a                          */
   1245   /*    FT_Module_Class stract instance.                                   */
   1246   /*                                                                       */
   1247   /* <Macro>                                                               */
   1248   /*    FT_DEFINE_MODULE                                                   */
   1249   /*                                                                       */
   1250   /* <Description>                                                         */
   1251   /*    Used to initialize an instance of FT_Module_Class struct.          */
   1252   /*                                                                       */
   1253   /*    When FT_CONFIG_OPTION_PIC is defined a Create funtion will need    */
   1254   /*    to called with a pointer where the allocated stracture is returned.*/
   1255   /*    And when it is no longer needed a Destroy function needs           */
   1256   /*    to be called to release that allocation.                           */
   1257   /*    fcinit.c (ft_create_default_module_classes) already contains       */
   1258   /*    a mechanism to call these functions for the default modules        */
   1259   /*    described in ftmodule.h                                            */
   1260   /*                                                                       */
   1261   /*    Notice that the created Create and Destroy functions call          */
   1262   /*    pic_init and pic_free function to allow you to manually allocate   */
   1263   /*    and initialize any additional global data, like module specific    */
   1264   /*    interface, and put them in the global pic container defined in     */
   1265   /*    ftpic.h. if you don't need them just implement the functions as    */
   1266   /*    empty to resolve the link error.                                   */
   1267   /*                                                                       */
   1268   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
   1269   /*    allocated in the global scope (or the scope where the macro        */
   1270   /*    is used).                                                          */
   1271   /*                                                                       */
   1272   /* <Macro>                                                               */
   1273   /*    FT_DEFINE_ROOT_MODULE                                              */
   1274   /*                                                                       */
   1275   /* <Description>                                                         */
   1276   /*    Used to initialize an instance of FT_Module_Class struct inside    */
   1277   /*    another stract that contains it or in a function that initializes  */
   1278   /*    that containing stract                                             */
   1279   /*                                                                       */
   1280 #ifndef FT_CONFIG_OPTION_PIC
   1281 
   1282 #define FT_DECLARE_MODULE(class_)                                            \
   1283   FT_CALLBACK_TABLE                                                          \
   1284   const FT_Module_Class  class_;                                             \
   1285 
   1286 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_,     \
   1287                               interface_, init_, done_, get_interface_)      \
   1288   {                                                                          \
   1289     flags_,                                                                  \
   1290     size_,                                                                   \
   1291                                                                              \
   1292     name_,                                                                   \
   1293     version_,                                                                \
   1294     requires_,                                                               \
   1295                                                                              \
   1296     interface_,                                                              \
   1297                                                                              \
   1298     init_,                                                                   \
   1299     done_,                                                                   \
   1300     get_interface_,                                                          \
   1301   },
   1302 
   1303 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_,  \
   1304                          interface_, init_, done_, get_interface_)           \
   1305   FT_CALLBACK_TABLE_DEF                                                      \
   1306   const FT_Module_Class class_ =                                             \
   1307   {                                                                          \
   1308     flags_,                                                                  \
   1309     size_,                                                                   \
   1310                                                                              \
   1311     name_,                                                                   \
   1312     version_,                                                                \
   1313     requires_,                                                               \
   1314                                                                              \
   1315     interface_,                                                              \
   1316                                                                              \
   1317     init_,                                                                   \
   1318     done_,                                                                   \
   1319     get_interface_,                                                          \
   1320   };
   1321 
   1322 
   1323 #else /* FT_CONFIG_OPTION_PIC */
   1324 
   1325 #define FT_DECLARE_MODULE(class_)                                            \
   1326   FT_Error FT_Create_Class_##class_( FT_Library library,                     \
   1327                                      FT_Module_Class** output_class );       \
   1328   void     FT_Destroy_Class_##class_( FT_Library library,                    \
   1329                                       FT_Module_Class*  clazz );
   1330 
   1331 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_,     \
   1332                               interface_, init_, done_, get_interface_)      \
   1333     clazz->root.module_flags       = flags_;                                 \
   1334     clazz->root.module_size        = size_;                                  \
   1335     clazz->root.module_name        = name_;                                  \
   1336     clazz->root.module_version     = version_;                               \
   1337     clazz->root.module_requires    = requires_;                              \
   1338                                                                              \
   1339     clazz->root.module_interface   = interface_;                             \
   1340                                                                              \
   1341     clazz->root.module_init        = init_;                                  \
   1342     clazz->root.module_done        = done_;                                  \
   1343     clazz->root.get_interface      = get_interface_;
   1344 
   1345 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_,  \
   1346                          interface_, init_, done_, get_interface_)           \
   1347   void class_##_pic_free( FT_Library library );                              \
   1348   FT_Error class_##_pic_init( FT_Library library );                          \
   1349                                                                              \
   1350   void                                                                       \
   1351   FT_Destroy_Class_##class_( FT_Library library,                             \
   1352                              FT_Module_Class*  clazz )                       \
   1353   {                                                                          \
   1354     FT_Memory memory = library->memory;                                      \
   1355     class_##_pic_free( library );                                            \
   1356     if ( clazz )                                                             \
   1357       FT_FREE( clazz );                                                      \
   1358   }                                                                          \
   1359                                                                              \
   1360   FT_Error                                                                   \
   1361   FT_Create_Class_##class_( FT_Library library,                              \
   1362                             FT_Module_Class**  output_class )                \
   1363   {                                                                          \
   1364     FT_Memory memory = library->memory;                                      \
   1365     FT_Module_Class*  clazz;                                                 \
   1366     FT_Error          error;                                                 \
   1367                                                                              \
   1368     if ( FT_ALLOC( clazz, sizeof(*clazz) ) )                                 \
   1369       return error;                                                          \
   1370     error = class_##_pic_init( library );                                    \
   1371     if(error)                                                                \
   1372     {                                                                        \
   1373       FT_FREE( clazz );                                                      \
   1374       return error;                                                          \
   1375     }                                                                        \
   1376                                                                              \
   1377     clazz->module_flags       = flags_;                                      \
   1378     clazz->module_size        = size_;                                       \
   1379     clazz->module_name        = name_;                                       \
   1380     clazz->module_version     = version_;                                    \
   1381     clazz->module_requires    = requires_;                                   \
   1382                                                                              \
   1383     clazz->module_interface   = interface_;                                  \
   1384                                                                              \
   1385     clazz->module_init        = init_;                                       \
   1386     clazz->module_done        = done_;                                       \
   1387     clazz->get_interface      = get_interface_;                              \
   1388                                                                              \
   1389     *output_class = clazz;                                                   \
   1390     return FT_Err_Ok;                                                        \
   1391   }
   1392 
   1393 #endif /* FT_CONFIG_OPTION_PIC */
   1394 
   1395 
   1396 FT_END_HEADER
   1397 
   1398 #endif /* __FTOBJS_H__ */
   1399 
   1400 
   1401 /* END */
   1402