Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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