ftobjs.h

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftobjs.h                                                               */
00004 /*                                                                         */
00005 /*    The FreeType private base classes (specification).                   */
00006 /*                                                                         */
00007 /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by             */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019   /*************************************************************************/
00020   /*                                                                       */
00021   /*  This file contains the definition of all internal FreeType classes.  */
00022   /*                                                                       */
00023   /*************************************************************************/
00024 
00025 
00026 #ifndef __FTOBJS_H__
00027 #define __FTOBJS_H__
00028 
00029 #include <ft2build.h>
00030 #include FT_RENDER_H
00031 #include FT_SIZES_H
00032 #include FT_LCD_FILTER_H
00033 #include FT_INTERNAL_MEMORY_H
00034 #include FT_INTERNAL_GLYPH_LOADER_H
00035 #include FT_INTERNAL_DRIVER_H
00036 #include FT_INTERNAL_AUTOHINT_H
00037 #include FT_INTERNAL_SERVICE_H
00038 #include FT_INTERNAL_PIC_H
00039 
00040 #ifdef FT_CONFIG_OPTION_INCREMENTAL
00041 #include FT_INCREMENTAL_H
00042 #endif
00043 
00044 
00045 FT_BEGIN_HEADER
00046 
00047 
00048   /*************************************************************************/
00049   /*                                                                       */
00050   /* Some generic definitions.                                             */
00051   /*                                                                       */
00052 #ifndef TRUE
00053 #define TRUE  1
00054 #endif
00055 
00056 #ifndef FALSE
00057 #define FALSE  0
00058 #endif
00059 
00060 #ifndef NULL
00061 #define NULL  (void*)0
00062 #endif
00063 
00064 
00065   /*************************************************************************/
00066   /*                                                                       */
00067   /* The min and max functions missing in C.  As usual, be careful not to  */
00068   /* write things like FT_MIN( a++, b++ ) to avoid side effects.           */
00069   /*                                                                       */
00070 #define FT_MIN( a, b )  ( (a) < (b) ? (a) : (b) )
00071 #define FT_MAX( a, b )  ( (a) > (b) ? (a) : (b) )
00072 
00073 #define FT_ABS( a )     ( (a) < 0 ? -(a) : (a) )
00074 
00075 
00076 #define FT_PAD_FLOOR( x, n )  ( (x) & ~((n)-1) )
00077 #define FT_PAD_ROUND( x, n )  FT_PAD_FLOOR( (x) + ((n)/2), n )
00078 #define FT_PAD_CEIL( x, n )   FT_PAD_FLOOR( (x) + ((n)-1), n )
00079 
00080 #define FT_PIX_FLOOR( x )     ( (x) & ~63 )
00081 #define FT_PIX_ROUND( x )     FT_PIX_FLOOR( (x) + 32 )
00082 #define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )
00083 
00084 
00085   /*
00086    *  Return the highest power of 2 that is <= value; this correspond to
00087    *  the highest bit in a given 32-bit value.
00088    */
00089   FT_BASE( FT_UInt32 )
00090   ft_highpow2( FT_UInt32  value );
00091 
00092 
00093   /*
00094    *  character classification functions -- since these are used to parse
00095    *  font files, we must not use those in <ctypes.h> which are
00096    *  locale-dependent
00097    */
00098 #define  ft_isdigit( x )   ( ( (unsigned)(x) - '0' ) < 10U )
00099 
00100 #define  ft_isxdigit( x )  ( ( (unsigned)(x) - '0' ) < 10U || \
00101                              ( (unsigned)(x) - 'a' ) < 6U  || \
00102                              ( (unsigned)(x) - 'A' ) < 6U  )
00103 
00104   /* the next two macros assume ASCII representation */
00105 #define  ft_isupper( x )  ( ( (unsigned)(x) - 'A' ) < 26U )
00106 #define  ft_islower( x )  ( ( (unsigned)(x) - 'a' ) < 26U )
00107 
00108 #define  ft_isalpha( x )  ( ft_isupper( x ) || ft_islower( x ) )
00109 #define  ft_isalnum( x )  ( ft_isdigit( x ) || ft_isalpha( x ) )
00110 
00111 
00112   /*************************************************************************/
00113   /*************************************************************************/
00114   /*************************************************************************/
00115   /****                                                                 ****/
00116   /****                                                                 ****/
00117   /****                       C H A R M A P S                           ****/
00118   /****                                                                 ****/
00119   /****                                                                 ****/
00120   /*************************************************************************/
00121   /*************************************************************************/
00122   /*************************************************************************/
00123 
00124   /* handle to internal charmap object */
00125   typedef struct FT_CMapRec_*              FT_CMap;
00126 
00127   /* handle to charmap class structure */
00128   typedef const struct FT_CMap_ClassRec_*  FT_CMap_Class;
00129 
00130   /* internal charmap object structure */
00131   typedef struct  FT_CMapRec_
00132   {
00133     FT_CharMapRec  charmap;
00134     FT_CMap_Class  clazz;
00135 
00136   } FT_CMapRec;
00137 
00138   /* typecase any pointer to a charmap handle */
00139 #define FT_CMAP( x )              ((FT_CMap)( x ))
00140 
00141   /* obvious macros */
00142 #define FT_CMAP_PLATFORM_ID( x )  FT_CMAP( x )->charmap.platform_id
00143 #define FT_CMAP_ENCODING_ID( x )  FT_CMAP( x )->charmap.encoding_id
00144 #define FT_CMAP_ENCODING( x )     FT_CMAP( x )->charmap.encoding
00145 #define FT_CMAP_FACE( x )         FT_CMAP( x )->charmap.face
00146 
00147 
00148   /* class method definitions */
00149   typedef FT_Error
00150   (*FT_CMap_InitFunc)( FT_CMap     cmap,
00151                        FT_Pointer  init_data );
00152 
00153   typedef void
00154   (*FT_CMap_DoneFunc)( FT_CMap  cmap );
00155 
00156   typedef FT_UInt
00157   (*FT_CMap_CharIndexFunc)( FT_CMap    cmap,
00158                             FT_UInt32  char_code );
00159 
00160   typedef FT_UInt
00161   (*FT_CMap_CharNextFunc)( FT_CMap     cmap,
00162                            FT_UInt32  *achar_code );
00163 
00164   typedef FT_UInt
00165   (*FT_CMap_CharVarIndexFunc)( FT_CMap    cmap,
00166                                FT_CMap    unicode_cmap,
00167                                FT_UInt32  char_code,
00168                                FT_UInt32  variant_selector );
00169 
00170   typedef FT_Bool
00171   (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap    cmap,
00172                                    FT_UInt32  char_code,
00173                                    FT_UInt32  variant_selector );
00174 
00175   typedef FT_UInt32 *
00176   (*FT_CMap_VariantListFunc)( FT_CMap    cmap,
00177                               FT_Memory  mem );
00178 
00179   typedef FT_UInt32 *
00180   (*FT_CMap_CharVariantListFunc)( FT_CMap    cmap,
00181                                   FT_Memory  mem,
00182                                   FT_UInt32  char_code );
00183 
00184   typedef FT_UInt32 *
00185   (*FT_CMap_VariantCharListFunc)( FT_CMap    cmap,
00186                                   FT_Memory  mem,
00187                                   FT_UInt32  variant_selector );
00188 
00189 
00190   typedef struct  FT_CMap_ClassRec_
00191   {
00192     FT_ULong               size;
00193     FT_CMap_InitFunc       init;
00194     FT_CMap_DoneFunc       done;
00195     FT_CMap_CharIndexFunc  char_index;
00196     FT_CMap_CharNextFunc   char_next;
00197 
00198     /* Subsequent entries are special ones for format 14 -- the variant */
00199     /* selector subtable which behaves like no other                    */
00200 
00201     FT_CMap_CharVarIndexFunc      char_var_index;
00202     FT_CMap_CharVarIsDefaultFunc  char_var_default;
00203     FT_CMap_VariantListFunc       variant_list;
00204     FT_CMap_CharVariantListFunc   charvariant_list;
00205     FT_CMap_VariantCharListFunc   variantchar_list;
00206 
00207   } FT_CMap_ClassRec;
00208 
00209 #ifndef FT_CONFIG_OPTION_PIC
00210 
00211 #define FT_DECLARE_CMAP_CLASS(class_) \
00212     FT_CALLBACK_TABLE const FT_CMap_ClassRec class_;
00213 
00214 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_,       \
00215         char_next_, char_var_index_, char_var_default_, variant_list_,       \
00216         charvariant_list_, variantchar_list_)                                \
00217   FT_CALLBACK_TABLE_DEF                                                      \
00218   const FT_CMap_ClassRec class_ =                                            \
00219   {                                                                          \
00220     size_, init_, done_, char_index_, char_next_, char_var_index_,           \
00221     char_var_default_, variant_list_, charvariant_list_, variantchar_list_   \
00222   };
00223 #else /* FT_CONFIG_OPTION_PIC */
00224 
00225 #define FT_DECLARE_CMAP_CLASS(class_) \
00226     void FT_Init_Class_##class_( FT_Library library, FT_CMap_ClassRec*  clazz);
00227 
00228 #define FT_DEFINE_CMAP_CLASS(class_, size_, init_, done_, char_index_,       \
00229         char_next_, char_var_index_, char_var_default_, variant_list_,       \
00230         charvariant_list_, variantchar_list_)                                \
00231   void                                                                       \
00232   FT_Init_Class_##class_( FT_Library library,                                \
00233                           FT_CMap_ClassRec*  clazz)                          \
00234   {                                                                          \
00235     FT_UNUSED(library);                                                      \
00236     clazz->size = size_;                                                     \
00237     clazz->init = init_;                                                     \
00238     clazz->done = done_;                                                     \
00239     clazz->char_index = char_index_;                                         \
00240     clazz->char_next = char_next_;                                           \
00241     clazz->char_var_index = char_var_index_;                                 \
00242     clazz->char_var_default = char_var_default_;                             \
00243     clazz->variant_list = variant_list_;                                     \
00244     clazz->charvariant_list = charvariant_list_;                             \
00245     clazz->variantchar_list = variantchar_list_;                             \
00246   } 
00247 #endif /* FT_CONFIG_OPTION_PIC */
00248 
00249   /* create a new charmap and add it to charmap->face */
00250   FT_BASE( FT_Error )
00251   FT_CMap_New( FT_CMap_Class  clazz,
00252                FT_Pointer     init_data,
00253                FT_CharMap     charmap,
00254                FT_CMap       *acmap );
00255 
00256   /* destroy a charmap and remove it from face's list */
00257   FT_BASE( void )
00258   FT_CMap_Done( FT_CMap  cmap );
00259 
00260 
00261   /*************************************************************************/
00262   /*                                                                       */
00263   /* <Struct>                                                              */
00264   /*    FT_Face_InternalRec                                                */
00265   /*                                                                       */
00266   /* <Description>                                                         */
00267   /*    This structure contains the internal fields of each FT_Face        */
00268   /*    object.  These fields may change between different releases of     */
00269   /*    FreeType.                                                          */
00270   /*                                                                       */
00271   /* <Fields>                                                              */
00272   /*    max_points ::                                                      */
00273   /*      The maximal number of points used to store the vectorial outline */
00274   /*      of any glyph in this face.  If this value cannot be known in     */
00275   /*      advance, or if the face isn't scalable, this should be set to 0. */
00276   /*      Only relevant for scalable formats.                              */
00277   /*                                                                       */
00278   /*    max_contours ::                                                    */
00279   /*      The maximal number of contours used to store the vectorial       */
00280   /*      outline of any glyph in this face.  If this value cannot be      */
00281   /*      known in advance, or if the face isn't scalable, this should be  */
00282   /*      set to 0.  Only relevant for scalable formats.                   */
00283   /*                                                                       */
00284   /*    transform_matrix ::                                                */
00285   /*      A 2x2 matrix of 16.16 coefficients used to transform glyph       */
00286   /*      outlines after they are loaded from the font.  Only used by the  */
00287   /*      convenience functions.                                           */
00288   /*                                                                       */
00289   /*    transform_delta ::                                                 */
00290   /*      A translation vector used to transform glyph outlines after they */
00291   /*      are loaded from the font.  Only used by the convenience          */
00292   /*      functions.                                                       */
00293   /*                                                                       */
00294   /*    transform_flags ::                                                 */
00295   /*      Some flags used to classify the transform.  Only used by the     */
00296   /*      convenience functions.                                           */
00297   /*                                                                       */
00298   /*    services ::                                                        */
00299   /*      A cache for frequently used services.  It should be only         */
00300   /*      accessed with the macro `FT_FACE_LOOKUP_SERVICE'.                */
00301   /*                                                                       */
00302   /*    incremental_interface ::                                           */
00303   /*      If non-null, the interface through which glyph data and metrics  */
00304   /*      are loaded incrementally for faces that do not provide all of    */
00305   /*      this data when first opened.  This field exists only if          */
00306   /*      @FT_CONFIG_OPTION_INCREMENTAL is defined.                        */
00307   /*                                                                       */
00308   /*    ignore_unpatented_hinter ::                                        */
00309   /*      This boolean flag instructs the glyph loader to ignore the       */
00310   /*      native font hinter, if one is found.  This is exclusively used   */
00311   /*      in the case when the unpatented hinter is compiled within the    */
00312   /*      library.                                                         */
00313   /*                                                                       */
00314   typedef struct  FT_Face_InternalRec_
00315   {
00316 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
00317     FT_UShort           reserved1;
00318     FT_Short            reserved2;
00319 #endif
00320     FT_Matrix           transform_matrix;
00321     FT_Vector           transform_delta;
00322     FT_Int              transform_flags;
00323 
00324     FT_ServiceCacheRec  services;
00325 
00326 #ifdef FT_CONFIG_OPTION_INCREMENTAL
00327     FT_Incremental_InterfaceRec*  incremental_interface;
00328 #endif
00329 
00330     FT_Bool             ignore_unpatented_hinter;
00331 
00332   } FT_Face_InternalRec;
00333 
00334 
00335   /*************************************************************************/
00336   /*                                                                       */
00337   /* <Struct>                                                              */
00338   /*    FT_Slot_InternalRec                                                */
00339   /*                                                                       */
00340   /* <Description>                                                         */
00341   /*    This structure contains the internal fields of each FT_GlyphSlot   */
00342   /*    object.  These fields may change between different releases of     */
00343   /*    FreeType.                                                          */
00344   /*                                                                       */
00345   /* <Fields>                                                              */
00346   /*    loader            :: The glyph loader object used to load outlines */
00347   /*                         into the glyph slot.                          */
00348   /*                                                                       */
00349   /*    flags             :: Possible values are zero or                   */
00350   /*                         FT_GLYPH_OWN_BITMAP.  The latter indicates    */
00351   /*                         that the FT_GlyphSlot structure owns the      */
00352   /*                         bitmap buffer.                                */
00353   /*                                                                       */
00354   /*    glyph_transformed :: Boolean.  Set to TRUE when the loaded glyph   */
00355   /*                         must be transformed through a specific        */
00356   /*                         font transformation.  This is _not_ the same  */
00357   /*                         as the face transform set through             */
00358   /*                         FT_Set_Transform().                           */
00359   /*                                                                       */
00360   /*    glyph_matrix      :: The 2x2 matrix corresponding to the glyph     */
00361   /*                         transformation, if necessary.                 */
00362   /*                                                                       */
00363   /*    glyph_delta       :: The 2d translation vector corresponding to    */
00364   /*                         the glyph transformation, if necessary.       */
00365   /*                                                                       */
00366   /*    glyph_hints       :: Format-specific glyph hints management.       */
00367   /*                                                                       */
00368 
00369 #define FT_GLYPH_OWN_BITMAP  0x1
00370 
00371   typedef struct  FT_Slot_InternalRec_
00372   {
00373     FT_GlyphLoader  loader;
00374     FT_UInt         flags;
00375     FT_Bool         glyph_transformed;
00376     FT_Matrix       glyph_matrix;
00377     FT_Vector       glyph_delta;
00378     void*           glyph_hints;
00379 
00380   } FT_GlyphSlot_InternalRec;
00381 
00382 
00383 #if 0
00384 
00385   /*************************************************************************/
00386   /*                                                                       */
00387   /* <Struct>                                                              */
00388   /*    FT_Size_InternalRec                                                */
00389   /*                                                                       */
00390   /* <Description>                                                         */
00391   /*    This structure contains the internal fields of each FT_Size        */
00392   /*    object.  Currently, it's empty.                                    */
00393   /*                                                                       */
00394   /*************************************************************************/
00395 
00396   typedef struct  FT_Size_InternalRec_
00397   {
00398     /* empty */
00399 
00400   } FT_Size_InternalRec;
00401 
00402 #endif
00403 
00404 
00405   /*************************************************************************/
00406   /*************************************************************************/
00407   /****                                                                 ****/
00408   /****                                                                 ****/
00409   /****                         M O D U L E S                           ****/
00410   /****                                                                 ****/
00411   /****                                                                 ****/
00412   /*************************************************************************/
00413   /*************************************************************************/
00414   /*************************************************************************/
00415 
00416 
00417   /*************************************************************************/
00418   /*                                                                       */
00419   /* <Struct>                                                              */
00420   /*    FT_ModuleRec                                                       */
00421   /*                                                                       */
00422   /* <Description>                                                         */
00423   /*    A module object instance.                                          */
00424   /*                                                                       */
00425   /* <Fields>                                                              */
00426   /*    clazz   :: A pointer to the module's class.                        */
00427   /*                                                                       */
00428   /*    library :: A handle to the parent library object.                  */
00429   /*                                                                       */
00430   /*    memory  :: A handle to the memory manager.                         */
00431   /*                                                                       */
00432   /*    generic :: A generic structure for user-level extensibility (?).   */
00433   /*                                                                       */
00434   typedef struct  FT_ModuleRec_
00435   {
00436     FT_Module_Class*  clazz;
00437     FT_Library        library;
00438     FT_Memory         memory;
00439     FT_Generic        generic;
00440 
00441   } FT_ModuleRec;
00442 
00443 
00444   /* typecast an object to a FT_Module */
00445 #define FT_MODULE( x )          ((FT_Module)( x ))
00446 #define FT_MODULE_CLASS( x )    FT_MODULE( x )->clazz
00447 #define FT_MODULE_LIBRARY( x )  FT_MODULE( x )->library
00448 #define FT_MODULE_MEMORY( x )   FT_MODULE( x )->memory
00449 
00450 
00451 #define FT_MODULE_IS_DRIVER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00452                                     FT_MODULE_FONT_DRIVER )
00453 
00454 #define FT_MODULE_IS_RENDERER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00455                                       FT_MODULE_RENDERER )
00456 
00457 #define FT_MODULE_IS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00458                                     FT_MODULE_HINTER )
00459 
00460 #define FT_MODULE_IS_STYLER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00461                                     FT_MODULE_STYLER )
00462 
00463 #define FT_DRIVER_IS_SCALABLE( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00464                                       FT_MODULE_DRIVER_SCALABLE )
00465 
00466 #define FT_DRIVER_USES_OUTLINES( x )  !( FT_MODULE_CLASS( x )->module_flags & \
00467                                          FT_MODULE_DRIVER_NO_OUTLINES )
00468 
00469 #define FT_DRIVER_HAS_HINTER( x )  ( FT_MODULE_CLASS( x )->module_flags & \
00470                                      FT_MODULE_DRIVER_HAS_HINTER )
00471 
00472 
00473   /*************************************************************************/
00474   /*                                                                       */
00475   /* <Function>                                                            */
00476   /*    FT_Get_Module_Interface                                            */
00477   /*                                                                       */
00478   /* <Description>                                                         */
00479   /*    Finds a module and returns its specific interface as a typeless    */
00480   /*    pointer.                                                           */
00481   /*                                                                       */
00482   /* <Input>                                                               */
00483   /*    library     :: A handle to the library object.                     */
00484   /*                                                                       */
00485   /*    module_name :: The module's name (as an ASCII string).             */
00486   /*                                                                       */
00487   /* <Return>                                                              */
00488   /*    A module-specific interface if available, 0 otherwise.             */
00489   /*                                                                       */
00490   /* <Note>                                                                */
00491   /*    You should better be familiar with FreeType internals to know      */
00492   /*    which module to look for, and what its interface is :-)            */
00493   /*                                                                       */
00494   FT_BASE( const void* )
00495   FT_Get_Module_Interface( FT_Library   library,
00496                            const char*  mod_name );
00497 
00498   FT_BASE( FT_Pointer )
00499   ft_module_get_service( FT_Module    module,
00500                          const char*  service_id );
00501 
00502  /* */
00503 
00504 
00505   /*************************************************************************/
00506   /*************************************************************************/
00507   /*************************************************************************/
00508   /****                                                                 ****/
00509   /****                                                                 ****/
00510   /****               FACE, SIZE & GLYPH SLOT OBJECTS                   ****/
00511   /****                                                                 ****/
00512   /****                                                                 ****/
00513   /*************************************************************************/
00514   /*************************************************************************/
00515   /*************************************************************************/
00516 
00517   /* a few macros used to perform easy typecasts with minimal brain damage */
00518 
00519 #define FT_FACE( x )          ((FT_Face)(x))
00520 #define FT_SIZE( x )          ((FT_Size)(x))
00521 #define FT_SLOT( x )          ((FT_GlyphSlot)(x))
00522 
00523 #define FT_FACE_DRIVER( x )   FT_FACE( x )->driver
00524 #define FT_FACE_LIBRARY( x )  FT_FACE_DRIVER( x )->root.library
00525 #define FT_FACE_MEMORY( x )   FT_FACE( x )->memory
00526 #define FT_FACE_STREAM( x )   FT_FACE( x )->stream
00527 
00528 #define FT_SIZE_FACE( x )     FT_SIZE( x )->face
00529 #define FT_SLOT_FACE( x )     FT_SLOT( x )->face
00530 
00531 #define FT_FACE_SLOT( x )     FT_FACE( x )->glyph
00532 #define FT_FACE_SIZE( x )     FT_FACE( x )->size
00533 
00534 
00535   /*************************************************************************/
00536   /*                                                                       */
00537   /* <Function>                                                            */
00538   /*    FT_New_GlyphSlot                                                   */
00539   /*                                                                       */
00540   /* <Description>                                                         */
00541   /*    It is sometimes useful to have more than one glyph slot for a      */
00542   /*    given face object.  This function is used to create additional     */
00543   /*    slots.  All of them are automatically discarded when the face is   */
00544   /*    destroyed.                                                         */
00545   /*                                                                       */
00546   /* <Input>                                                               */
00547   /*    face  :: A handle to a parent face object.                         */
00548   /*                                                                       */
00549   /* <Output>                                                              */
00550   /*    aslot :: A handle to a new glyph slot object.                      */
00551   /*                                                                       */
00552   /* <Return>                                                              */
00553   /*    FreeType error code.  0 means success.                             */
00554   /*                                                                       */
00555   FT_BASE( FT_Error )
00556   FT_New_GlyphSlot( FT_Face        face,
00557                     FT_GlyphSlot  *aslot );
00558 
00559 
00560   /*************************************************************************/
00561   /*                                                                       */
00562   /* <Function>                                                            */
00563   /*    FT_Done_GlyphSlot                                                  */
00564   /*                                                                       */
00565   /* <Description>                                                         */
00566   /*    Destroys a given glyph slot.  Remember however that all slots are  */
00567   /*    automatically destroyed with its parent.  Using this function is   */
00568   /*    not always mandatory.                                              */
00569   /*                                                                       */
00570   /* <Input>                                                               */
00571   /*    slot :: A handle to a target glyph slot.                           */
00572   /*                                                                       */
00573   FT_BASE( void )
00574   FT_Done_GlyphSlot( FT_GlyphSlot  slot );
00575 
00576  /* */
00577 
00578 #define FT_REQUEST_WIDTH( req )                                            \
00579           ( (req)->horiResolution                                          \
00580               ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \
00581               : (req)->width )
00582 
00583 #define FT_REQUEST_HEIGHT( req )                                            \
00584           ( (req)->vertResolution                                           \
00585               ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \
00586               : (req)->height )
00587 
00588 
00589   /* Set the metrics according to a bitmap strike. */
00590   FT_BASE( void )
00591   FT_Select_Metrics( FT_Face   face,
00592                      FT_ULong  strike_index );
00593 
00594 
00595   /* Set the metrics according to a size request. */
00596   FT_BASE( void )
00597   FT_Request_Metrics( FT_Face          face,
00598                       FT_Size_Request  req );
00599 
00600 
00601   /* Match a size request against `available_sizes'. */
00602   FT_BASE( FT_Error )
00603   FT_Match_Size( FT_Face          face,
00604                  FT_Size_Request  req,
00605                  FT_Bool          ignore_width,
00606                  FT_ULong*        size_index );
00607 
00608 
00609   /* Use the horizontal metrics to synthesize the vertical metrics. */
00610   /* If `advance' is zero, it is also synthesized.                  */
00611   FT_BASE( void )
00612   ft_synthesize_vertical_metrics( FT_Glyph_Metrics*  metrics,
00613                                   FT_Pos             advance );
00614 
00615 
00616   /* Free the bitmap of a given glyphslot when needed (i.e., only when it */
00617   /* was allocated with ft_glyphslot_alloc_bitmap).                       */
00618   FT_BASE( void )
00619   ft_glyphslot_free_bitmap( FT_GlyphSlot  slot );
00620 
00621 
00622   /* Allocate a new bitmap buffer in a glyph slot. */
00623   FT_BASE( FT_Error )
00624   ft_glyphslot_alloc_bitmap( FT_GlyphSlot  slot,
00625                              FT_ULong      size );
00626 
00627 
00628   /* Set the bitmap buffer in a glyph slot to a given pointer.  The buffer */
00629   /* will not be freed by a later call to ft_glyphslot_free_bitmap.        */
00630   FT_BASE( void )
00631   ft_glyphslot_set_bitmap( FT_GlyphSlot  slot,
00632                            FT_Byte*      buffer );
00633 
00634 
00635   /*************************************************************************/
00636   /*************************************************************************/
00637   /*************************************************************************/
00638   /****                                                                 ****/
00639   /****                                                                 ****/
00640   /****                        R E N D E R E R S                        ****/
00641   /****                                                                 ****/
00642   /****                                                                 ****/
00643   /*************************************************************************/
00644   /*************************************************************************/
00645   /*************************************************************************/
00646 
00647 
00648 #define FT_RENDERER( x )      ((FT_Renderer)( x ))
00649 #define FT_GLYPH( x )         ((FT_Glyph)( x ))
00650 #define FT_BITMAP_GLYPH( x )  ((FT_BitmapGlyph)( x ))
00651 #define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x ))
00652 
00653 
00654   typedef struct  FT_RendererRec_
00655   {
00656     FT_ModuleRec            root;
00657     FT_Renderer_Class*      clazz;
00658     FT_Glyph_Format         glyph_format;
00659     FT_Glyph_Class          glyph_class;
00660 
00661     FT_Raster               raster;
00662     FT_Raster_Render_Func   raster_render;
00663     FT_Renderer_RenderFunc  render;
00664 
00665   } FT_RendererRec;
00666 
00667 
00668   /*************************************************************************/
00669   /*************************************************************************/
00670   /*************************************************************************/
00671   /****                                                                 ****/
00672   /****                                                                 ****/
00673   /****                    F O N T   D R I V E R S                      ****/
00674   /****                                                                 ****/
00675   /****                                                                 ****/
00676   /*************************************************************************/
00677   /*************************************************************************/
00678   /*************************************************************************/
00679 
00680 
00681   /* typecast a module into a driver easily */
00682 #define FT_DRIVER( x )        ((FT_Driver)(x))
00683 
00684   /* typecast a module as a driver, and get its driver class */
00685 #define FT_DRIVER_CLASS( x )  FT_DRIVER( x )->clazz
00686 
00687 
00688   /*************************************************************************/
00689   /*                                                                       */
00690   /* <Struct>                                                              */
00691   /*    FT_DriverRec                                                       */
00692   /*                                                                       */
00693   /* <Description>                                                         */
00694   /*    The root font driver class.  A font driver is responsible for      */
00695   /*    managing and loading font files of a given format.                 */
00696   /*                                                                       */
00697   /*  <Fields>                                                             */
00698   /*     root         :: Contains the fields of the root module class.     */
00699   /*                                                                       */
00700   /*     clazz        :: A pointer to the font driver's class.  Note that  */
00701   /*                     this is NOT root.clazz.  `class' wasn't used      */
00702   /*                     as it is a reserved word in C++.                  */
00703   /*                                                                       */
00704   /*     faces_list   :: The list of faces currently opened by this        */
00705   /*                     driver.                                           */
00706   /*                                                                       */
00707   /*     extensions   :: A typeless pointer to the driver's extensions     */
00708   /*                     registry, if they are supported through the       */
00709   /*                     configuration macro FT_CONFIG_OPTION_EXTENSIONS.  */
00710   /*                                                                       */
00711   /*     glyph_loader :: The glyph loader for all faces managed by this    */
00712   /*                     driver.  This object isn't defined for unscalable */
00713   /*                     formats.                                          */
00714   /*                                                                       */
00715   typedef struct  FT_DriverRec_
00716   {
00717     FT_ModuleRec     root;
00718     FT_Driver_Class  clazz;
00719 
00720     FT_ListRec       faces_list;
00721     void*            extensions;
00722 
00723     FT_GlyphLoader   glyph_loader;
00724 
00725   } FT_DriverRec;
00726 
00727 
00728   /*************************************************************************/
00729   /*************************************************************************/
00730   /*************************************************************************/
00731   /****                                                                 ****/
00732   /****                                                                 ****/
00733   /****                       L I B R A R I E S                         ****/
00734   /****                                                                 ****/
00735   /****                                                                 ****/
00736   /*************************************************************************/
00737   /*************************************************************************/
00738   /*************************************************************************/
00739 
00740 
00741   /* This hook is used by the TrueType debugger.  It must be set to an */
00742   /* alternate truetype bytecode interpreter function.                 */
00743 #define FT_DEBUG_HOOK_TRUETYPE            0
00744 
00745 
00746   /* Set this debug hook to a non-null pointer to force unpatented hinting */
00747   /* for all faces when both TT_USE_BYTECODE_INTERPRETER and               */
00748   /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined.  This is only used   */
00749   /* during debugging.                                                     */
00750 #define FT_DEBUG_HOOK_UNPATENTED_HINTING  1
00751 
00752 
00753   typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
00754                                             FT_Render_Mode  render_mode,
00755                                             FT_Library      library );
00756 
00757 
00758   /*************************************************************************/
00759   /*                                                                       */
00760   /* <Struct>                                                              */
00761   /*    FT_LibraryRec                                                      */
00762   /*                                                                       */
00763   /* <Description>                                                         */
00764   /*    The FreeType library class.  This is the root of all FreeType      */
00765   /*    data.  Use FT_New_Library() to create a library object, and        */
00766   /*    FT_Done_Library() to discard it and all child objects.             */
00767   /*                                                                       */
00768   /* <Fields>                                                              */
00769   /*    memory           :: The library's memory object.  Manages memory   */
00770   /*                        allocation.                                    */
00771   /*                                                                       */
00772   /*    generic          :: Client data variable.  Used to extend the      */
00773   /*                        Library class by higher levels and clients.    */
00774   /*                                                                       */
00775   /*    version_major    :: The major version number of the library.       */
00776   /*                                                                       */
00777   /*    version_minor    :: The minor version number of the library.       */
00778   /*                                                                       */
00779   /*    version_patch    :: The current patch level of the library.        */
00780   /*                                                                       */
00781   /*    num_modules      :: The number of modules currently registered     */
00782   /*                        within this library.  This is set to 0 for new */
00783   /*                        libraries.  New modules are added through the  */
00784   /*                        FT_Add_Module() API function.                  */
00785   /*                                                                       */
00786   /*    modules          :: A table used to store handles to the currently */
00787   /*                        registered modules. Note that each font driver */
00788   /*                        contains a list of its opened faces.           */
00789   /*                                                                       */
00790   /*    renderers        :: The list of renderers currently registered     */
00791   /*                        within the library.                            */
00792   /*                                                                       */
00793   /*    cur_renderer     :: The current outline renderer.  This is a       */
00794   /*                        shortcut used to avoid parsing the list on     */
00795   /*                        each call to FT_Outline_Render().  It is a     */
00796   /*                        handle to the current renderer for the         */
00797   /*                        FT_GLYPH_FORMAT_OUTLINE format.                */
00798   /*                                                                       */
00799   /*    auto_hinter      :: XXX                                            */
00800   /*                                                                       */
00801   /*    raster_pool      :: The raster object's render pool.  This can     */
00802   /*                        ideally be changed dynamically at run-time.    */
00803   /*                                                                       */
00804   /*    raster_pool_size :: The size of the render pool in bytes.          */
00805   /*                                                                       */
00806   /*    debug_hooks      :: XXX                                            */
00807   /*                                                                       */
00808   /*    pic_container    :: Contains global structs and tables, instead    */
00809   /*                        of defining them globallly.                    */
00810   /*                                                                       */
00811 
00812   typedef struct  FT_LibraryRec_
00813   {
00814     FT_Memory          memory;           /* library's memory manager */
00815 
00816     FT_Generic         generic;
00817 
00818     FT_Int             version_major;
00819     FT_Int             version_minor;
00820     FT_Int             version_patch;
00821 
00822     FT_UInt            num_modules;
00823     FT_Module          modules[FT_MAX_MODULES];  /* module objects  */
00824 
00825     FT_ListRec         renderers;        /* list of renderers        */
00826     FT_Renderer        cur_renderer;     /* current outline renderer */
00827     FT_Module          auto_hinter;
00828 
00829     FT_Byte*           raster_pool;      /* scan-line conversion */
00830                                          /* render pool          */
00831     FT_ULong           raster_pool_size; /* size of render pool in bytes */
00832 
00833     FT_DebugHook_Func  debug_hooks[4];
00834 
00835 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
00836     FT_LcdFilter             lcd_filter;
00837     FT_Int                   lcd_extra;        /* number of extra pixels */
00838     FT_Byte                  lcd_weights[7];   /* filter weights, if any */
00839     FT_Bitmap_LcdFilterFunc  lcd_filter_func;  /* filtering callback     */
00840 #endif
00841 
00842 #ifdef FT_CONFIG_OPTION_PIC
00843     FT_PIC_Container   pic_container;
00844 #endif
00845 
00846   } FT_LibraryRec;
00847 
00848 
00849   FT_BASE( FT_Renderer )
00850   FT_Lookup_Renderer( FT_Library       library,
00851                       FT_Glyph_Format  format,
00852                       FT_ListNode*     node );
00853 
00854   FT_BASE( FT_Error )
00855   FT_Render_Glyph_Internal( FT_Library      library,
00856                             FT_GlyphSlot    slot,
00857                             FT_Render_Mode  render_mode );
00858 
00859   typedef const char*
00860   (*FT_Face_GetPostscriptNameFunc)( FT_Face  face );
00861 
00862   typedef FT_Error
00863   (*FT_Face_GetGlyphNameFunc)( FT_Face     face,
00864                                FT_UInt     glyph_index,
00865                                FT_Pointer  buffer,
00866                                FT_UInt     buffer_max );
00867 
00868   typedef FT_UInt
00869   (*FT_Face_GetGlyphNameIndexFunc)( FT_Face     face,
00870                                     FT_String*  glyph_name );
00871 
00872 
00873 #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
00874 
00875   /*************************************************************************/
00876   /*                                                                       */
00877   /* <Function>                                                            */
00878   /*    FT_New_Memory                                                      */
00879   /*                                                                       */
00880   /* <Description>                                                         */
00881   /*    Creates a new memory object.                                       */
00882   /*                                                                       */
00883   /* <Return>                                                              */
00884   /*    A pointer to the new memory object.  0 in case of error.           */
00885   /*                                                                       */
00886   FT_BASE( FT_Memory )
00887   FT_New_Memory( void );
00888 
00889 
00890   /*************************************************************************/
00891   /*                                                                       */
00892   /* <Function>                                                            */
00893   /*    FT_Done_Memory                                                     */
00894   /*                                                                       */
00895   /* <Description>                                                         */
00896   /*    Discards memory manager.                                           */
00897   /*                                                                       */
00898   /* <Input>                                                               */
00899   /*    memory :: A handle to the memory manager.                          */
00900   /*                                                                       */
00901   FT_BASE( void )
00902   FT_Done_Memory( FT_Memory  memory );
00903 
00904 #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */
00905 
00906 
00907   /* Define default raster's interface.  The default raster is located in  */
00908   /* `src/base/ftraster.c'.                                                */
00909   /*                                                                       */
00910   /* Client applications can register new rasters through the              */
00911   /* FT_Set_Raster() API.                                                  */
00912 
00913 #ifndef FT_NO_DEFAULT_RASTER
00914   FT_EXPORT_VAR( FT_Raster_Funcs )  ft_default_raster;
00915 #endif
00916 
00917   /*************************************************************************/
00918   /*************************************************************************/
00919   /*************************************************************************/
00920   /****                                                                 ****/
00921   /****                                                                 ****/
00922   /****              PIC-Support Macros for ftimage.h                   ****/
00923   /****                                                                 ****/
00924   /****                                                                 ****/
00925   /*************************************************************************/
00926   /*************************************************************************/
00927   /*************************************************************************/
00928 
00929 
00930   /*************************************************************************/
00931   /*                                                                       */
00932   /* <Macro>                                                               */
00933   /*    FT_DEFINE_OUTLINE_FUNCS                                            */
00934   /*                                                                       */
00935   /* <Description>                                                         */
00936   /*    Used to initialize an instance of FT_Outline_Funcs struct.         */
00937   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
00938   /*    called with a pre-allocated stracture to be filled.                */
00939   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
00940   /*    allocated in the global scope (or the scope where the macro        */
00941   /*    is used).                                                          */
00942   /*                                                                       */
00943 #ifndef FT_CONFIG_OPTION_PIC
00944 
00945 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_,       \
00946                                 cubic_to_, shift_, delta_)                   \
00947   static const FT_Outline_Funcs class_ =                                     \
00948   {                                                                          \
00949     move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_                 \
00950   };
00951 
00952 #else /* FT_CONFIG_OPTION_PIC */ 
00953 
00954 #define FT_DEFINE_OUTLINE_FUNCS(class_, move_to_, line_to_, conic_to_,       \
00955                                 cubic_to_, shift_, delta_)                   \
00956   static FT_Error                                                            \
00957   Init_Class_##class_( FT_Outline_Funcs*  clazz )                            \
00958   {                                                                          \
00959     clazz->move_to = move_to_;                                               \
00960     clazz->line_to = line_to_;                                               \
00961     clazz->conic_to = conic_to_;                                             \
00962     clazz->cubic_to = cubic_to_;                                             \
00963     clazz->shift = shift_;                                                   \
00964     clazz->delta = delta_;                                                   \
00965     return FT_Err_Ok;                                                        \
00966   } 
00967 
00968 #endif /* FT_CONFIG_OPTION_PIC */ 
00969 
00970   /*************************************************************************/
00971   /*                                                                       */
00972   /* <Macro>                                                               */
00973   /*    FT_DEFINE_RASTER_FUNCS                                             */
00974   /*                                                                       */
00975   /* <Description>                                                         */
00976   /*    Used to initialize an instance of FT_Raster_Funcs struct.          */
00977   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
00978   /*    called with a pre-allocated stracture to be filled.                */
00979   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
00980   /*    allocated in the global scope (or the scope where the macro        */
00981   /*    is used).                                                          */
00982   /*                                                                       */
00983 #ifndef FT_CONFIG_OPTION_PIC
00984 
00985 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_,           \
00986                                raster_reset_, raster_set_mode_,              \
00987                                raster_render_, raster_done_)                 \
00988   const FT_Raster_Funcs class_ =                                      \
00989   {                                                                          \
00990     glyph_format_, raster_new_, raster_reset_,                               \
00991     raster_set_mode_, raster_render_, raster_done_                           \
00992   };
00993 
00994 #else /* FT_CONFIG_OPTION_PIC */ 
00995 
00996 #define FT_DEFINE_RASTER_FUNCS(class_, glyph_format_, raster_new_,           \
00997     raster_reset_, raster_set_mode_, raster_render_, raster_done_)           \
00998   void                                                                       \
00999   FT_Init_Class_##class_( FT_Raster_Funcs*  clazz )                          \
01000   {                                                                          \
01001     clazz->glyph_format = glyph_format_;                                     \
01002     clazz->raster_new = raster_new_;                                         \
01003     clazz->raster_reset = raster_reset_;                                     \
01004     clazz->raster_set_mode = raster_set_mode_;                               \
01005     clazz->raster_render = raster_render_;                                   \
01006     clazz->raster_done = raster_done_;                                       \
01007   } 
01008 
01009 #endif /* FT_CONFIG_OPTION_PIC */ 
01010 
01011   /*************************************************************************/
01012   /*************************************************************************/
01013   /*************************************************************************/
01014   /****                                                                 ****/
01015   /****                                                                 ****/
01016   /****              PIC-Support Macros for ftrender.h                  ****/
01017   /****                                                                 ****/
01018   /****                                                                 ****/
01019   /*************************************************************************/
01020   /*************************************************************************/
01021   /*************************************************************************/
01022 
01023 
01024 
01025   /*************************************************************************/
01026   /*                                                                       */
01027   /* <Macro>                                                               */
01028   /*    FT_DEFINE_GLYPH                                                    */
01029   /*                                                                       */
01030   /* <Description>                                                         */
01031   /*    Used to initialize an instance of FT_Glyph_Class struct.           */
01032   /*    When FT_CONFIG_OPTION_PIC is defined an init funtion will need to  */
01033   /*    called with a pre-allocated stracture to be filled.                */
01034   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
01035   /*    allocated in the global scope (or the scope where the macro        */
01036   /*    is used).                                                          */
01037   /*                                                                       */
01038 #ifndef FT_CONFIG_OPTION_PIC
01039 
01040 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_,         \
01041                         transform_, bbox_, prepare_)                         \
01042   FT_CALLBACK_TABLE_DEF                                                      \
01043   const FT_Glyph_Class class_ =                                              \
01044   {                                                                          \
01045     size_, format_, init_, done_, copy_, transform_, bbox_, prepare_         \
01046   };
01047 
01048 #else /* FT_CONFIG_OPTION_PIC */ 
01049 
01050 #define FT_DEFINE_GLYPH(class_, size_, format_, init_, done_, copy_,         \
01051                         transform_, bbox_, prepare_)                         \
01052   void                                                                       \
01053   FT_Init_Class_##class_( FT_Glyph_Class*  clazz )                           \
01054   {                                                                          \
01055     clazz->glyph_size = size_;                                               \
01056     clazz->glyph_format = format_;                                           \
01057     clazz->glyph_init = init_;                                               \
01058     clazz->glyph_done = done_;                                               \
01059     clazz->glyph_copy = copy_;                                               \
01060     clazz->glyph_transform = transform_;                                     \
01061     clazz->glyph_bbox = bbox_;                                               \
01062     clazz->glyph_prepare = prepare_;                                         \
01063   } 
01064 
01065 #endif /* FT_CONFIG_OPTION_PIC */ 
01066 
01067   /*************************************************************************/
01068   /*                                                                       */
01069   /* <Macro>                                                               */
01070   /*    FT_DECLARE_RENDERER                                                */
01071   /*                                                                       */
01072   /* <Description>                                                         */
01073   /*    Used to create a forward declaration of a                          */
01074   /*    FT_Renderer_Class stract instance.                                 */
01075   /*                                                                       */
01076   /* <Macro>                                                               */
01077   /*    FT_DEFINE_RENDERER                                                 */
01078   /*                                                                       */
01079   /* <Description>                                                         */
01080   /*    Used to initialize an instance of FT_Renderer_Class struct.        */
01081   /*                                                                       */
01082   /*    When FT_CONFIG_OPTION_PIC is defined a Create funtion will need    */
01083   /*    to called with a pointer where the allocated stracture is returned.*/
01084   /*    And when it is no longer needed a Destroy function needs           */
01085   /*    to be called to release that allocation.                           */
01086   /*    fcinit.c (ft_create_default_module_classes) already contains       */
01087   /*    a mechanism to call these functions for the default modules        */
01088   /*    described in ftmodule.h                                            */
01089   /*                                                                       */
01090   /*    Notice that the created Create and Destroy functions call          */
01091   /*    pic_init and pic_free function to allow you to manually allocate   */
01092   /*    and initialize any additional global data, like module specific    */
01093   /*    interface, and put them in the global pic container defined in     */
01094   /*    ftpic.h. if you don't need them just implement the functions as    */
01095   /*    empty to resolve the link error.                                   */
01096   /*                                                                       */
01097   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
01098   /*    allocated in the global scope (or the scope where the macro        */
01099   /*    is used).                                                          */
01100   /*                                                                       */
01101 #ifndef FT_CONFIG_OPTION_PIC
01102 
01103 #define FT_DECLARE_RENDERER(class_)                                          \
01104     FT_EXPORT_VAR( const FT_Renderer_Class ) class_;
01105 
01106 #define FT_DEFINE_RENDERER(class_,                                           \
01107                            flags_, size_, name_, version_, requires_,        \
01108                            interface_, init_, done_, get_interface_,         \
01109                            glyph_format_, render_glyph_, transform_glyph_,   \
01110                            get_glyph_cbox_, set_mode_, raster_class_ )       \
01111   FT_CALLBACK_TABLE_DEF                                                      \
01112   const FT_Renderer_Class  class_ =                                          \
01113   {                                                                          \
01114     FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,             \
01115                           interface_,init_,done_,get_interface_)             \
01116     glyph_format_,                                                           \
01117                                                                              \
01118     render_glyph_,                                                           \
01119     transform_glyph_,                                                        \
01120     get_glyph_cbox_,                                                         \
01121     set_mode_,                                                               \
01122                                                                              \
01123     raster_class_                                                            \
01124   };
01125 
01126 #else /* FT_CONFIG_OPTION_PIC */ 
01127 
01128 #define FT_DECLARE_RENDERER(class_)  FT_DECLARE_MODULE(class_)
01129 
01130 #define FT_DEFINE_RENDERER(class_, \
01131                            flags_, size_, name_, version_, requires_,        \
01132                            interface_, init_, done_, get_interface_,         \
01133                            glyph_format_, render_glyph_, transform_glyph_,   \
01134                            get_glyph_cbox_, set_mode_, raster_class_ )       \
01135   void class_##_pic_free( FT_Library library );                              \
01136   FT_Error class_##_pic_init( FT_Library library );                          \
01137                                                                              \
01138   void                                                                       \
01139   FT_Destroy_Class_##class_( FT_Library        library,                      \
01140                         FT_Module_Class*  clazz )                            \
01141   {                                                                          \
01142     FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz;                   \
01143     FT_Memory         memory = library->memory;                              \
01144     class_##_pic_free( library );                                            \
01145     if ( rclazz )                                                            \
01146       FT_FREE( rclazz );                                                     \
01147   }                                                                          \
01148                                                                              \
01149   FT_Error                                                                   \
01150   FT_Create_Class_##class_( FT_Library         library,                      \
01151                             FT_Module_Class**  output_class )                \
01152   {                                                                          \
01153     FT_Renderer_Class*  clazz;                                               \
01154     FT_Error            error;                                               \
01155     FT_Memory           memory = library->memory;                            \
01156                                                                              \
01157     if ( FT_ALLOC( clazz, sizeof(*clazz) ) )                                 \
01158       return error;                                                          \
01159                                                                              \
01160     error = class_##_pic_init( library );                                    \
01161     if(error)                                                                \
01162     {                                                                        \
01163       FT_FREE( clazz );                                                      \
01164       return error;                                                          \
01165     }                                                                        \
01166                                                                              \
01167     FT_DEFINE_ROOT_MODULE(flags_,size_,name_,version_,requires_,             \
01168                           interface_,init_,done_,get_interface_)             \
01169                                                                              \
01170     clazz->glyph_format       = glyph_format_;                               \
01171                                                                              \
01172     clazz->render_glyph       = render_glyph_;                               \
01173     clazz->transform_glyph    = transform_glyph_;                            \
01174     clazz->get_glyph_cbox     = get_glyph_cbox_;                             \
01175     clazz->set_mode           = set_mode_;                                   \
01176                                                                              \
01177     clazz->raster_class       = raster_class_;                               \
01178                                                                              \
01179     *output_class = (FT_Module_Class*)clazz;                                 \
01180     return FT_Err_Ok;                                                        \
01181   } 
01182 
01183 
01184 
01185 #endif /* FT_CONFIG_OPTION_PIC */ 
01186 
01187   /*************************************************************************/
01188   /*************************************************************************/
01189   /*************************************************************************/
01190   /****                                                                 ****/
01191   /****                                                                 ****/
01192   /****              PIC-Support Macros for ftmodapi.h                  ****/
01193   /****                                                                 ****/
01194   /****                                                                 ****/
01195   /*************************************************************************/
01196   /*************************************************************************/
01197   /*************************************************************************/
01198 
01199 
01200 #ifdef FT_CONFIG_OPTION_PIC
01201 
01202   /*************************************************************************/
01203   /*                                                                       */
01204   /* <FuncType>                                                            */
01205   /*    FT_Module_Creator                                                  */
01206   /*                                                                       */
01207   /* <Description>                                                         */
01208   /*    A function used to create (allocate) a new module class object.    */
01209   /*    The object's members are initialized, but the module itself is     */
01210   /*    not.                                                               */
01211   /*                                                                       */
01212   /* <Input>                                                               */
01213   /*    memory       :: A handle to the memory manager.                    */
01214   /*    output_class :: Initialized with the newly allocated class.        */
01215   /*                                                                       */
01216   typedef FT_Error
01217   (*FT_Module_Creator)( FT_Memory          memory,
01218                         FT_Module_Class**  output_class );
01219 
01220   /*************************************************************************/
01221   /*                                                                       */
01222   /* <FuncType>                                                            */
01223   /*    FT_Module_Destroyer                                                */
01224   /*                                                                       */
01225   /* <Description>                                                         */
01226   /*    A function used to destroy (deallocate) a module class object.     */
01227   /*                                                                       */
01228   /* <Input>                                                               */
01229   /*    memory :: A handle to the memory manager.                          */
01230   /*    clazz  :: Module class to destroy.                                 */
01231   /*                                                                       */
01232   typedef void
01233   (*FT_Module_Destroyer)( FT_Memory         memory,
01234                           FT_Module_Class*  clazz );
01235 
01236 #endif
01237 
01238   /*************************************************************************/
01239   /*                                                                       */
01240   /* <Macro>                                                               */
01241   /*    FT_DECLARE_MODULE                                                  */
01242   /*                                                                       */
01243   /* <Description>                                                         */
01244   /*    Used to create a forward declaration of a                          */
01245   /*    FT_Module_Class stract instance.                                   */
01246   /*                                                                       */
01247   /* <Macro>                                                               */
01248   /*    FT_DEFINE_MODULE                                                   */
01249   /*                                                                       */
01250   /* <Description>                                                         */
01251   /*    Used to initialize an instance of FT_Module_Class struct.          */
01252   /*                                                                       */
01253   /*    When FT_CONFIG_OPTION_PIC is defined a Create funtion will need    */
01254   /*    to called with a pointer where the allocated stracture is returned.*/
01255   /*    And when it is no longer needed a Destroy function needs           */
01256   /*    to be called to release that allocation.                           */
01257   /*    fcinit.c (ft_create_default_module_classes) already contains       */
01258   /*    a mechanism to call these functions for the default modules        */
01259   /*    described in ftmodule.h                                            */
01260   /*                                                                       */
01261   /*    Notice that the created Create and Destroy functions call          */
01262   /*    pic_init and pic_free function to allow you to manually allocate   */
01263   /*    and initialize any additional global data, like module specific    */
01264   /*    interface, and put them in the global pic container defined in     */
01265   /*    ftpic.h. if you don't need them just implement the functions as    */
01266   /*    empty to resolve the link error.                                   */
01267   /*                                                                       */
01268   /*    When FT_CONFIG_OPTION_PIC is not defined the struct will be        */
01269   /*    allocated in the global scope (or the scope where the macro        */
01270   /*    is used).                                                          */
01271   /*                                                                       */
01272   /* <Macro>                                                               */
01273   /*    FT_DEFINE_ROOT_MODULE                                              */
01274   /*                                                                       */
01275   /* <Description>                                                         */
01276   /*    Used to initialize an instance of FT_Module_Class struct inside    */
01277   /*    another stract that contains it or in a function that initializes  */
01278   /*    that containing stract                                             */
01279   /*                                                                       */
01280 #ifndef FT_CONFIG_OPTION_PIC
01281 
01282 #define FT_DECLARE_MODULE(class_)                                            \
01283   FT_CALLBACK_TABLE                                                          \
01284   const FT_Module_Class  class_;                                             \
01285 
01286 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_,     \
01287                               interface_, init_, done_, get_interface_)      \
01288   {                                                                          \
01289     flags_,                                                                  \
01290     size_,                                                                   \
01291                                                                              \
01292     name_,                                                                   \
01293     version_,                                                                \
01294     requires_,                                                               \
01295                                                                              \
01296     interface_,                                                              \
01297                                                                              \
01298     init_,                                                                   \
01299     done_,                                                                   \
01300     get_interface_,                                                          \
01301   },
01302 
01303 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_,  \
01304                          interface_, init_, done_, get_interface_)           \
01305   FT_CALLBACK_TABLE_DEF                                                      \
01306   const FT_Module_Class class_ =                                             \
01307   {                                                                          \
01308     flags_,                                                                  \
01309     size_,                                                                   \
01310                                                                              \
01311     name_,                                                                   \
01312     version_,                                                                \
01313     requires_,                                                               \
01314                                                                              \
01315     interface_,                                                              \
01316                                                                              \
01317     init_,                                                                   \
01318     done_,                                                                   \
01319     get_interface_,                                                          \
01320   };
01321 
01322 
01323 #else /* FT_CONFIG_OPTION_PIC */
01324 
01325 #define FT_DECLARE_MODULE(class_)                                            \
01326   FT_Error FT_Create_Class_##class_( FT_Library library,                     \
01327                                      FT_Module_Class** output_class );       \
01328   void     FT_Destroy_Class_##class_( FT_Library library,                    \
01329                                       FT_Module_Class*  clazz );
01330 
01331 #define FT_DEFINE_ROOT_MODULE(flags_, size_, name_, version_, requires_,     \
01332                               interface_, init_, done_, get_interface_)      \
01333     clazz->root.module_flags       = flags_;                                 \
01334     clazz->root.module_size        = size_;                                  \
01335     clazz->root.module_name        = name_;                                  \
01336     clazz->root.module_version     = version_;                               \
01337     clazz->root.module_requires    = requires_;                              \
01338                                                                              \
01339     clazz->root.module_interface   = interface_;                             \
01340                                                                              \
01341     clazz->root.module_init        = init_;                                  \
01342     clazz->root.module_done        = done_;                                  \
01343     clazz->root.get_interface      = get_interface_;               
01344 
01345 #define FT_DEFINE_MODULE(class_, flags_, size_, name_, version_, requires_,  \
01346                          interface_, init_, done_, get_interface_)           \
01347   void class_##_pic_free( FT_Library library );                              \
01348   FT_Error class_##_pic_init( FT_Library library );                          \
01349                                                                              \
01350   void                                                                       \
01351   FT_Destroy_Class_##class_( FT_Library library,                             \
01352                              FT_Module_Class*  clazz )                       \
01353   {                                                                          \
01354     FT_Memory memory = library->memory;                                      \
01355     class_##_pic_free( library );                                            \
01356     if ( clazz )                                                             \
01357       FT_FREE( clazz );                                                      \
01358   }                                                                          \
01359                                                                              \
01360   FT_Error                                                                   \
01361   FT_Create_Class_##class_( FT_Library library,                              \
01362                             FT_Module_Class**  output_class )                \
01363   {                                                                          \
01364     FT_Memory memory = library->memory;                                      \
01365     FT_Module_Class*  clazz;                                                 \
01366     FT_Error          error;                                                 \
01367                                                                              \
01368     if ( FT_ALLOC( clazz, sizeof(*clazz) ) )                                 \
01369       return error;                                                          \
01370     error = class_##_pic_init( library );                                    \
01371     if(error)                                                                \
01372     {                                                                        \
01373       FT_FREE( clazz );                                                      \
01374       return error;                                                          \
01375     }                                                                        \
01376                                                                              \
01377     clazz->module_flags       = flags_;                                      \
01378     clazz->module_size        = size_;                                       \
01379     clazz->module_name        = name_;                                       \
01380     clazz->module_version     = version_;                                    \
01381     clazz->module_requires    = requires_;                                   \
01382                                                                              \
01383     clazz->module_interface   = interface_;                                  \
01384                                                                              \
01385     clazz->module_init        = init_;                                       \
01386     clazz->module_done        = done_;                                       \
01387     clazz->get_interface      = get_interface_;                              \
01388                                                                              \
01389     *output_class = clazz;                                                   \
01390     return FT_Err_Ok;                                                        \
01391   } 
01392 
01393 #endif /* FT_CONFIG_OPTION_PIC */
01394 
01395 
01396 FT_END_HEADER
01397 
01398 #endif /* __FTOBJS_H__ */
01399 
01400 
01401 /* END */

Generated on Tue Jul 5 14:13:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1