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