text:
/***************************************************************************/
/*                                                                         */
/*  ftserv.h                                                               */
/*                                                                         */
/*    The FreeType services (specification only).                          */
/*                                                                         */
/*  Copyright 2003-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /*  Each module can export one or more `services'.  Each service is      */
  /*  identified by a constant string and modeled by a pointer; the latter */
  /*  generally corresponds to a structure containing function pointers.   */
  /*                                                                       */
  /*  Note that a service's data cannot be a mere function pointer because */
  /*  in C it is possible that function pointers might be implemented      */
  /*  differently than data pointers (e.g. 48 bits instead of 32).         */
  /*                                                                       */
  /*************************************************************************/

#ifndef FTSERV_H_
#define FTSERV_H_

FT_BEGIN_HEADER

  /*
   * @macro:
   *   FT_FACE_FIND_SERVICE
   *
   * @description:
   *   This macro is used to look up a service from a face's driver module.
   *
   * @input:
   *   face ::
   *     The source face handle.
   *
   *   id ::
   *     A string describing the service as defined in the service's
   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
   *     `multi-masters').  It is automatically prefixed with
   *     `FT_SERVICE_ID_'.
   *
   * @output:
   *   ptr ::
   *     A variable that receives the service pointer.  Will be NULL
   *     if not found.
   */
#ifdef __cplusplus

#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
  FT_BEGIN_STMNT                                                            \
    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );             \
    FT_Pointer   _tmp_  = NULL;                                             \
    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                              \
                                                                            \
                                                                            \
    if ( module->clazz->get_interface )                                     \
      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
    *_pptr_ = _tmp_;                                                        \
  FT_END_STMNT

#else /* !C++ */

#define FT_FACE_FIND_SERVICE( face, ptr, id )                               \
  FT_BEGIN_STMNT                                                            \
    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );              \
    FT_Pointer  _tmp_  = NULL;                                              \
                                                                            \
    if ( module->clazz->get_interface )                                     \
      _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
    ptr = _tmp_;                                                            \
  FT_END_STMNT

#endif /* !C++ */

  /*
   * @macro:
   *   FT_FACE_FIND_GLOBAL_SERVICE
   *
   * @description:
   *   This macro is used to look up a service from all modules.
   *
   * @input:
   *   face ::
   *     The source face handle.
   *
   *   id ::
   *     A string describing the service as defined in the service's
   *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
   *     `multi-masters').  It is automatically prefixed with
   *     `FT_SERVICE_ID_'.
   *
   * @output:
   *   ptr ::
   *     A variable that receives the service pointer.  Will be NULL
   *     if not found.
   */
#ifdef __cplusplus

#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )                  \
  FT_BEGIN_STMNT                                                      \
    FT_Module    module = FT_MODULE( FT_FACE( face )->driver );       \
    FT_Pointer   _tmp_;                                               \
    FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                        \
                                                                      \
                                                                      \
    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
    *_pptr_ = _tmp_;                                                  \
  FT_END_STMNT

#else /* !C++ */

#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )                  \
  FT_BEGIN_STMNT                                                      \
    FT_Module   module = FT_MODULE( FT_FACE( face )->driver );        \
    FT_Pointer  _tmp_;                                                \
                                                                      \
                                                                      \
    _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
    ptr   = _tmp_;                                                    \
  FT_END_STMNT

#endif /* !C++ */

  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****         S E R V I C E   D E S C R I P T O R S                 *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   *  The following structure is used to _describe_ a given service
   *  to the library.  This is useful to build simple static service lists.
   */
  typedef struct  FT_ServiceDescRec_
  {
    const char*  serv_id;     /* service name         */
    const void*  serv_data;   /* service pointer/data */

  } FT_ServiceDescRec;

  typedef const FT_ServiceDescRec*  FT_ServiceDesc;

  /*************************************************************************/
  /*                                                                       */
  /* <Macro>                                                               */
  /*    FT_DEFINE_SERVICEDESCREC1                                          */
  /*    FT_DEFINE_SERVICEDESCREC2                                          */
  /*    FT_DEFINE_SERVICEDESCREC3                                          */
  /*    FT_DEFINE_SERVICEDESCREC4                                          */
  /*    FT_DEFINE_SERVICEDESCREC5                                          */
  /*    FT_DEFINE_SERVICEDESCREC6                                          */
  /*    FT_DEFINE_SERVICEDESCREC7                                          */
  /*    FT_DEFINE_SERVICEDESCREC8                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Used to initialize an array of FT_ServiceDescRec structures.       */
  /*                                                                       */
  /*    When FT_CONFIG_OPTION_PIC is defined a `create' function needs to  */
  /*    be called with a pointer to return an allocated array.  As soon as */
  /*    it is no longer needed, a `destroy' function needs to be called to */
  /*    release that allocation.                                           */
  /*                                                                       */
  /*    These functions should be manually called from the `pic_init' and  */
  /*    `pic_free' functions of your module (see FT_DEFINE_MODULE).        */
  /*                                                                       */
  /*    When FT_CONFIG_OPTION_PIC is not defined the array will be         */
  /*    allocated in the global scope (or the scope where the macro is     */
  /*    used).                                                             */
  /*                                                                       */
#ifndef FT_CONFIG_OPTION_PIC

#define FT_DEFINE_SERVICEDESCREC1( class_,                                  \
                                   serv_id_1, serv_data_1 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC2( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC3( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC4( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC5( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { serv_id_5, serv_data_5 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC6( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { serv_id_5, serv_data_5 },                                             \
    { serv_id_6, serv_data_6 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC7( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { serv_id_5, serv_data_5 },                                             \
    { serv_id_6, serv_data_6 },                                             \
    { serv_id_7, serv_data_7 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC8( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7,                  \
                                   serv_id_8, serv_data_8 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { serv_id_5, serv_data_5 },                                             \
    { serv_id_6, serv_data_6 },                                             \
    { serv_id_7, serv_data_7 },                                             \
    { serv_id_8, serv_data_8 },                                             \
    { NULL, NULL }                                                          \
  };

#define FT_DEFINE_SERVICEDESCREC9( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7,                  \
                                   serv_id_8, serv_data_8,                  \
                                   serv_id_9, serv_data_9 )                 \
  static const FT_ServiceDescRec  class_[] =                                \
  {                                                                         \
    { serv_id_1, serv_data_1 },                                             \
    { serv_id_2, serv_data_2 },                                             \
    { serv_id_3, serv_data_3 },                                             \
    { serv_id_4, serv_data_4 },                                             \
    { serv_id_5, serv_data_5 },                                             \
    { serv_id_6, serv_data_6 },                                             \
    { serv_id_7, serv_data_7 },                                             \
    { serv_id_8, serv_data_8 },                                             \
    { serv_id_9, serv_data_9 },                                             \
    { NULL, NULL }                                                          \
  };

#else /* FT_CONFIG_OPTION_PIC */

#define FT_DEFINE_SERVICEDESCREC1( class_,                                  \
                                   serv_id_1, serv_data_1 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class )           \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 2 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = NULL;                                              \
    clazz[1].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC2( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class )           \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 3 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = NULL;                                              \
    clazz[2].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC3( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class )           \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 4 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = NULL;                                              \
    clazz[3].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC4( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class )           \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 5 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = NULL;                                              \
    clazz[4].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC5( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class )           \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 6 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = serv_id_5;                                         \
    clazz[4].serv_data = serv_data_5;                                       \
    clazz[5].serv_id   = NULL;                                              \
    clazz[5].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC6( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class)            \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 7 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = serv_id_5;                                         \
    clazz[4].serv_data = serv_data_5;                                       \
    clazz[5].serv_id   = serv_id_6;                                         \
    clazz[5].serv_data = serv_data_6;                                       \
    clazz[6].serv_id   = NULL;                                              \
    clazz[6].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC7( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class)            \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 8 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = serv_id_5;                                         \
    clazz[4].serv_data = serv_data_5;                                       \
    clazz[5].serv_id   = serv_id_6;                                         \
    clazz[5].serv_data = serv_data_6;                                       \
    clazz[6].serv_id   = serv_id_7;                                         \
    clazz[6].serv_data = serv_data_7;                                       \
    clazz[7].serv_id   = NULL;                                              \
    clazz[7].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC8( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7,                  \
                                   serv_id_8, serv_data_8 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class)            \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) )                         \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = serv_id_5;                                         \
    clazz[4].serv_data = serv_data_5;                                       \
    clazz[5].serv_id   = serv_id_6;                                         \
    clazz[5].serv_data = serv_data_6;                                       \
    clazz[6].serv_id   = serv_id_7;                                         \
    clazz[6].serv_data = serv_data_7;                                       \
    clazz[7].serv_id   = serv_id_8;                                         \
    clazz[7].serv_data = serv_data_8;                                       \
    clazz[8].serv_id   = NULL;                                              \
    clazz[8].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#define FT_DEFINE_SERVICEDESCREC9( class_,                                  \
                                   serv_id_1, serv_data_1,                  \
                                   serv_id_2, serv_data_2,                  \
                                   serv_id_3, serv_data_3,                  \
                                   serv_id_4, serv_data_4,                  \
                                   serv_id_5, serv_data_5,                  \
                                   serv_id_6, serv_data_6,                  \
                                   serv_id_7, serv_data_7,                  \
                                   serv_id_8, serv_data_8,                  \
                                   serv_id_9, serv_data_9 )                 \
  void                                                                      \
  FT_Destroy_Class_ ## class_( FT_Library          library,                 \
                               FT_ServiceDescRec*  clazz )                  \
  {                                                                         \
    FT_Memory  memory = library->memory;                                    \
                                                                            \
                                                                            \
    if ( clazz )                                                            \
      FT_FREE( clazz );                                                     \
  }                                                                         \
                                                                            \
  FT_Error                                                                  \
  FT_Create_Class_ ## class_( FT_Library           library,                 \
                              FT_ServiceDescRec**  output_class)            \
  {                                                                         \
    FT_ServiceDescRec*  clazz  = NULL;                                      \
    FT_Error            error;                                              \
    FT_Memory           memory = library->memory;                           \
                                                                            \
                                                                            \
    if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 10 ) )                        \
      return error;                                                         \
                                                                            \
    clazz[0].serv_id   = serv_id_1;                                         \
    clazz[0].serv_data = serv_data_1;                                       \
    clazz[1].serv_id   = serv_id_2;                                         \
    clazz[1].serv_data = serv_data_2;                                       \
    clazz[2].serv_id   = serv_id_3;                                         \
    clazz[2].serv_data = serv_data_3;                                       \
    clazz[3].serv_id   = serv_id_4;                                         \
    clazz[3].serv_data = serv_data_4;                                       \
    clazz[4].serv_id   = serv_id_5;                                         \
    clazz[4].serv_data = serv_data_5;                                       \
    clazz[5].serv_id   = serv_id_6;                                         \
    clazz[5].serv_data = serv_data_6;                                       \
    clazz[6].serv_id   = serv_id_7;                                         \
    clazz[6].serv_data = serv_data_7;                                       \
    clazz[7].serv_id   = serv_id_8;                                         \
    clazz[7].serv_data = serv_data_8;                                       \
    clazz[8].serv_id   = serv_id_9;                                         \
    clazz[8].serv_data = serv_data_9;                                       \
    clazz[9].serv_id   = NULL;                                              \
    clazz[9].serv_data = NULL;                                              \
                                                                            \
    *output_class = clazz;                                                  \
                                                                            \
    return FT_Err_Ok;                                                       \
  }

#endif /* FT_CONFIG_OPTION_PIC */

  /*
   *  Parse a list of FT_ServiceDescRec descriptors and look for
   *  a specific service by ID.  Note that the last element in the
   *  array must be { NULL, NULL }, and that the function should
   *  return NULL if the service isn't available.
   *
   *  This function can be used by modules to implement their
   *  `get_service' method.
   */
  FT_BASE( FT_Pointer )
  ft_service_list_lookup( FT_ServiceDesc  service_descriptors,
                          const char*     service_id );

  /*************************************************************************/
  /*************************************************************************/
  /*****                                                               *****/
  /*****             S E R V I C E S   C A C H E                       *****/
  /*****                                                               *****/
  /*************************************************************************/
  /*************************************************************************/

  /*
   *  This structure is used to store a cache for several frequently used
   *  services.  It is the type of `face->internal->services'.  You
   *  should only use FT_FACE_LOOKUP_SERVICE to access it.
   *
   *  All fields should have the type FT_Pointer to relax compilation
   *  dependencies.  We assume the developer isn't completely stupid.
   *
   *  Each field must be named `service_XXXX' where `XXX' corresponds to
   *  the correct FT_SERVICE_ID_XXXX macro.  See the definition of
   *  FT_FACE_LOOKUP_SERVICE below how this is implemented.
   *
   */
  typedef struct  FT_ServiceCacheRec_
  {
    FT_Pointer  service_POSTSCRIPT_FONT_NAME;
    FT_Pointer  service_MULTI_MASTERS;
    FT_Pointer  service_METRICS_VARIATIONS;
    FT_Pointer  service_GLYPH_DICT;
    FT_Pointer  service_PFR_METRICS;
    FT_Pointer  service_WINFNT;

  } FT_ServiceCacheRec, *FT_ServiceCache;

  /*
   *  A magic number used within the services cache.
   */

  /* ensure that value `1' has the same width as a pointer */
#define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)~(FT_PtrDist)1)

  /*
   * @macro:
   *   FT_FACE_LOOKUP_SERVICE
   *
   * @description:
   *   This macro is used to look up a service from a face's driver module
   *   using its cache.
   *
   * @input:
   *   face::
   *     The source face handle containing the cache.
   *
   *   field ::
   *     The field name in the cache.
   *
   *   id ::
   *     The service ID.
   *
   * @output:
   *   ptr ::
   *     A variable receiving the service data.  NULL if not available.
   */
#ifdef __cplusplus

#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
  FT_BEGIN_STMNT                                               \
    FT_Pointer   svc;                                          \
    FT_Pointer*  Pptr = (FT_Pointer*)&(ptr);                   \
                                                               \
                                                               \
    svc = FT_FACE( face )->internal->services. service_ ## id; \
    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
      svc = NULL;                                              \
    else if ( svc == NULL )                                    \
    {                                                          \
      FT_FACE_FIND_SERVICE( face, svc, id );                   \
                                                               \
      FT_FACE( face )->internal->services. service_ ## id =    \
        (FT_Pointer)( svc != NULL ? svc                        \
                                  : FT_SERVICE_UNAVAILABLE );  \
    }                                                          \
    *Pptr = svc;                                               \
  FT_END_STMNT

#else /* !C++ */

#define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                \
  FT_BEGIN_STMNT                                               \
    FT_Pointer  svc;                                           \
                                                               \
                                                               \
    svc = FT_FACE( face )->internal->services. service_ ## id; \
    if ( svc == FT_SERVICE_UNAVAILABLE )                       \
      svc = NULL;                                              \
    else if ( svc == NULL )                                    \
    {                                                          \
      FT_FACE_FIND_SERVICE( face, svc, id );                   \
                                                               \
      FT_FACE( face )->internal->services. service_ ## id =    \
        (FT_Pointer)( svc != NULL ? svc                        \
                                  : FT_SERVICE_UNAVAILABLE );  \
    }                                                          \
    ptr = svc;                                                 \
  FT_END_STMNT

#endif /* !C++ */

  /*
   *  A macro used to define new service structure types.
   */

#define FT_DEFINE_SERVICE( name )            \
  typedef struct FT_Service_ ## name ## Rec_ \
    FT_Service_ ## name ## Rec ;             \
  typedef struct FT_Service_ ## name ## Rec_ \
    const * FT_Service_ ## name ;            \
  struct FT_Service_ ## name ## Rec_

  /* */

  /*
   *  The header files containing the services.
   */

#define FT_SERVICE_BDF_H                <freetype/internal/services/svbdf.h>
#define FT_SERVICE_CID_H                <freetype/internal/services/svcid.h>
#define FT_SERVICE_GLYPH_DICT_H         <freetype/internal/services/svgldict.h>
#define FT_SERVICE_GX_VALIDATE_H        <freetype/internal/services/svgxval.h>
#define FT_SERVICE_KERNING_H            <freetype/internal/services/svkern.h>
#define FT_SERVICE_METRICS_VARIATIONS_H <freetype/internal/services/svmetric.h>
#define FT_SERVICE_MULTIPLE_MASTERS_H   <freetype/internal/services/svmm.h>
#define FT_SERVICE_OPENTYPE_VALIDATE_H  <freetype/internal/services/svotval.h>
#define FT_SERVICE_PFR_H                <freetype/internal/services/svpfr.h>
#define FT_SERVICE_POSTSCRIPT_CMAPS_H   <freetype/internal/services/svpscmap.h>
#define FT_SERVICE_POSTSCRIPT_INFO_H    <freetype/internal/services/svpsinfo.h>
#define FT_SERVICE_POSTSCRIPT_NAME_H    <freetype/internal/services/svpostnm.h>
#define FT_SERVICE_PROPERTIES_H         <freetype/internal/services/svprop.h>
#define FT_SERVICE_SFNT_H               <freetype/internal/services/svsfnt.h>
#define FT_SERVICE_TRUETYPE_ENGINE_H    <freetype/internal/services/svtteng.h>
#define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
#define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_FONT_FORMAT_H        <freetype/internal/services/svfntfmt.h>
#define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>

 /* */

FT_END_HEADER

#endif /* FTSERV_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  ftdebug.h                                                              */
/*                                                                         */
/*    Debugging and logging component (specification).                     */
/*                                                                         */
/*  Copyright 1996-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/*                                                                         */
/*  IMPORTANT: A description of FreeType's debugging support can be        */
/*             found in `docs/DEBUG.TXT'.  Read it if you need to use or   */
/*             understand this code.                                       */
/*                                                                         */
/***************************************************************************/

#ifndef FTDEBUG_H_
#define FTDEBUG_H_

#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_FREETYPE_H

FT_BEGIN_HEADER

  /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */
  /* is already defined; this simplifies the following #ifdefs            */
  /*                                                                      */
#ifdef FT_DEBUG_LEVEL_TRACE
#undef  FT_DEBUG_LEVEL_ERROR
#define FT_DEBUG_LEVEL_ERROR
#endif

  /*************************************************************************/
  /*                                                                       */
  /* Define the trace enums as well as the trace levels array when they    */
  /* are needed.                                                           */
  /*                                                                       */
  /*************************************************************************/

#ifdef FT_DEBUG_LEVEL_TRACE

#define FT_TRACE_DEF( x )  trace_ ## x ,

  /* defining the enumeration */
  typedef enum  FT_Trace_
  {
#include FT_INTERNAL_TRACE_H
    trace_count

  } FT_Trace;

  /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
  extern int  ft_trace_levels[trace_count];

#undef FT_TRACE_DEF

#endif /* FT_DEBUG_LEVEL_TRACE */

  /*************************************************************************/
  /*                                                                       */
  /* Define the FT_TRACE macro                                             */
  /*                                                                       */
  /* IMPORTANT!                                                            */
  /*                                                                       */
  /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
  /* value before using any TRACE macro.                                   */
  /*                                                                       */
  /*************************************************************************/

#ifdef FT_DEBUG_LEVEL_TRACE

#define FT_TRACE( level, varformat )                      \
          do                                              \
          {                                               \
            if ( ft_trace_levels[FT_COMPONENT] >= level ) \
              FT_Message varformat;                       \
          } while ( 0 )

#else /* !FT_DEBUG_LEVEL_TRACE */

#define FT_TRACE( level, varformat )  do { } while ( 0 )      /* nothing */

#endif /* !FT_DEBUG_LEVEL_TRACE */

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Trace_Get_Count                                                 */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Return the number of available trace components.                   */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The number of trace components.  0 if FreeType 2 is not built with */
  /*    FT_DEBUG_LEVEL_TRACE definition.                                   */
  /*                                                                       */
  /* <Note>                                                                */
  /*    This function may be useful if you want to access elements of      */
  /*    the internal `ft_trace_levels' array by an index.                  */
  /*                                                                       */
  FT_BASE( FT_Int )
  FT_Trace_Get_Count( void );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Trace_Get_Name                                                  */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Return the name of a trace component.                              */
  /*                                                                       */
  /* <Input>                                                               */
  /*    The index of the trace component.                                  */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The name of the trace component.  This is a statically allocated   */
  /*    C string, so do not free it after use.  NULL if FreeType 2 is not  */
  /*    built with FT_DEBUG_LEVEL_TRACE definition.                        */
  /*                                                                       */
  /* <Note>                                                                */
  /*    Use @FT_Trace_Get_Count to get the number of available trace       */
  /*    components.                                                        */
  /*                                                                       */
  /*    This function may be useful if you want to control FreeType 2's    */
  /*    debug level in your application.                                   */
  /*                                                                       */
  FT_BASE( const char* )
  FT_Trace_Get_Name( FT_Int  idx );

  /*************************************************************************/
  /*                                                                       */
  /* You need two opening and closing parentheses!                         */
  /*                                                                       */
  /* Example: FT_TRACE0(( "Value is %i", foo ))                            */
  /*                                                                       */
  /* Output of the FT_TRACEX macros is sent to stderr.                     */
  /*                                                                       */
  /*************************************************************************/

#define FT_TRACE0( varformat )  FT_TRACE( 0, varformat )
#define FT_TRACE1( varformat )  FT_TRACE( 1, varformat )
#define FT_TRACE2( varformat )  FT_TRACE( 2, varformat )
#define FT_TRACE3( varformat )  FT_TRACE( 3, varformat )
#define FT_TRACE4( varformat )  FT_TRACE( 4, varformat )
#define FT_TRACE5( varformat )  FT_TRACE( 5, varformat )
#define FT_TRACE6( varformat )  FT_TRACE( 6, varformat )
#define FT_TRACE7( varformat )  FT_TRACE( 7, varformat )

  /*************************************************************************/
  /*                                                                       */
  /* Define the FT_ERROR macro.                                            */
  /*                                                                       */
  /* Output of this macro is sent to stderr.                               */
  /*                                                                       */
  /*************************************************************************/

#ifdef FT_DEBUG_LEVEL_ERROR

#define FT_ERROR( varformat )  FT_Message  varformat

#else  /* !FT_DEBUG_LEVEL_ERROR */

#define FT_ERROR( varformat )  do { } while ( 0 )      /* nothing */

#endif /* !FT_DEBUG_LEVEL_ERROR */

  /*************************************************************************/
  /*                                                                       */
  /* Define the FT_ASSERT and FT_THROW macros.  The call to `FT_Throw'     */
  /* makes it possible to easily set a breakpoint at this function.        */
  /*                                                                       */
  /*************************************************************************/

#ifdef FT_DEBUG_LEVEL_ERROR

#define FT_ASSERT( condition )                                      \
          do                                                        \
          {                                                         \
            if ( !( condition ) )                                   \
              FT_Panic( "assertion failed on line %d of file %s\n", \
                        __LINE__, __FILE__ );                       \
          } while ( 0 )

#define FT_THROW( e )                                   \
          ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ),   \
                      __LINE__,                         \
                      __FILE__ )                      | \
            FT_ERR_CAT( FT_ERR_PREFIX, e )            )

#else /* !FT_DEBUG_LEVEL_ERROR */

#define FT_ASSERT( condition )  do { } while ( 0 )

#define FT_THROW( e )  FT_ERR_CAT( FT_ERR_PREFIX, e )

#endif /* !FT_DEBUG_LEVEL_ERROR */

  /*************************************************************************/
  /*                                                                       */
  /* Define `FT_Message' and `FT_Panic' when needed.                       */
  /*                                                                       */
  /*************************************************************************/

#ifdef FT_DEBUG_LEVEL_ERROR

#include "stdio.h"  /* for vfprintf() */

  /* print a message */
  FT_BASE( void )
  FT_Message( const char*  fmt,
              ... );

  /* print a message and exit */
  FT_BASE( void )
  FT_Panic( const char*  fmt,
            ... );

  /* report file name and line number of an error */
  FT_BASE( int )
  FT_Throw( FT_Error     error,
            int          line,
            const char*  file );

#endif /* FT_DEBUG_LEVEL_ERROR */

  FT_BASE( void )
  ft_debug_init( void );

FT_END_HEADER

#endif /* FTDEBUG_H_ */

/* END */

repo_name: JoshParnell/libphx

repo_language: C

mime_type: text/x-c++


text:
/***************************************************************************/
/*                                                                         */
/*  fthash.h                                                               */
/*                                                                         */
/*    Hashing functions (specification).                                   */
/*                                                                         */
/***************************************************************************/

/*
 * Copyright 2000 Computing Research Labs, New Mexico State University
 * Copyright 2001-2015
 *   Francesco Zappa Nardelli
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

  /*************************************************************************/
  /*                                                                       */
  /*  This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50     */
  /*                                                                       */
  /*  taken from Mark Leisher's xmbdfed package                            */
  /*                                                                       */
  /*************************************************************************/

#ifndef FTHASH_H_
#define FTHASH_H_

#include <ft2build.h>
#include FT_FREETYPE_H

FT_BEGIN_HEADER

  typedef union  FT_Hashkey_
  {
    FT_Int       num;
    const char*  str;

  } FT_Hashkey;

  typedef struct  FT_HashnodeRec_
  {
    FT_Hashkey  key;
    size_t      data;

  } FT_HashnodeRec;

  typedef struct FT_HashnodeRec_  *FT_Hashnode;

  typedef FT_ULong
  (*FT_Hash_LookupFunc)( FT_Hashkey*  key );

  typedef FT_Bool
  (*FT_Hash_CompareFunc)( FT_Hashkey*  a,
                          FT_Hashkey*  b );

  typedef struct  FT_HashRec_
  {
    FT_UInt  limit;
    FT_UInt  size;
    FT_UInt  used;

    FT_Hash_LookupFunc   lookup;
    FT_Hash_CompareFunc  compare;

    FT_Hashnode*  table;

  } FT_HashRec;

  typedef struct FT_HashRec_  *FT_Hash;

  FT_Error
  ft_hash_str_init( FT_Hash    hash,
                    FT_Memory  memory );

  FT_Error
  ft_hash_num_init( FT_Hash    hash,
                    FT_Memory  memory );

  void
  ft_hash_str_free( FT_Hash    hash,
                    FT_Memory  memory );

#define ft_hash_num_free  ft_hash_str_free

  FT_Error
  ft_hash_str_insert( const char*  key,
                      size_t       data,
                      FT_Hash      hash,
                      FT_Memory    memory );

  FT_Error
  ft_hash_num_insert( FT_Int     num,
                      size_t     data,
                      FT_Hash    hash,
                      FT_Memory  memory );

  size_t*
  ft_hash_str_lookup( const char*  key,
                      FT_Hash      hash );

  size_t*
  ft_hash_num_lookup( FT_Int   num,
                      FT_Hash  hash );

FT_END_HEADER

#endif /* FTHASH_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svbdf.h                                                                */
/*                                                                         */
/*    The FreeType BDF services (specification).                           */
/*                                                                         */
/*  Copyright 2003-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVBDF_H_
#define SVBDF_H_

#include FT_BDF_H
#include FT_INTERNAL_SERVICE_H

FT_BEGIN_HEADER

#define FT_SERVICE_ID_BDF  "bdf"

  typedef FT_Error
  (*FT_BDF_GetCharsetIdFunc)( FT_Face       face,
                              const char*  *acharset_encoding,
                              const char*  *acharset_registry );

  typedef FT_Error
  (*FT_BDF_GetPropertyFunc)( FT_Face           face,
                             const char*       prop_name,
                             BDF_PropertyRec  *aproperty );

  FT_DEFINE_SERVICE( BDF )
  {
    FT_BDF_GetCharsetIdFunc  get_charset_id;
    FT_BDF_GetPropertyFunc   get_property;
  };

#ifndef FT_CONFIG_OPTION_PIC

#define FT_DEFINE_SERVICE_BDFRec( class_,                                \
                                  get_charset_id_,                       \
                                  get_property_ )                        \
  static const FT_Service_BDFRec  class_ =                               \
  {                                                                      \
    get_charset_id_, get_property_                                       \
  };

#else /* FT_CONFIG_OPTION_PIC */

#define FT_DEFINE_SERVICE_BDFRec( class_,                                \
                                  get_charset_id_,                       \
                                  get_property_ )                        \
  void                                                                   \
  FT_Init_Class_ ## class_( FT_Service_BDFRec*  clazz )                  \
  {                                                                      \
    clazz->get_charset_id = get_charset_id_;                             \
    clazz->get_property   = get_property_;                               \
  }

#endif /* FT_CONFIG_OPTION_PIC */

  /* */

FT_END_HEADER

#endif /* SVBDF_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svpscmap.h                                                             */
/*                                                                         */
/*    The FreeType PostScript charmap service (specification).             */
/*                                                                         */
/*  Copyright 2003-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVPSCMAP_H_
#define SVPSCMAP_H_

#include FT_INTERNAL_OBJECTS_H

FT_BEGIN_HEADER

#define FT_SERVICE_ID_POSTSCRIPT_CMAPS  "postscript-cmaps"

  /*
   *  Adobe glyph name to unicode value.
   */
  typedef FT_UInt32
  (*PS_Unicode_ValueFunc)( const char*  glyph_name );

  /*
   *  Macintosh name id to glyph name.  NULL if invalid index.
   */
  typedef const char*
  (*PS_Macintosh_NameFunc)( FT_UInt  name_index );

  /*
   *  Adobe standard string ID to glyph name.  NULL if invalid index.
   */
  typedef const char*
  (*PS_Adobe_Std_StringsFunc)( FT_UInt  string_index );

  /*
   *  Simple unicode -> glyph index charmap built from font glyph names
   *  table.
   */
  typedef struct  PS_UniMap_
  {
    FT_UInt32  unicode;      /* bit 31 set: is glyph variant */
    FT_UInt    glyph_index;

  } PS_UniMap;

  typedef struct PS_UnicodesRec_*  PS_Unicodes;

  typedef struct  PS_UnicodesRec_
  {
    FT_CMapRec  cmap;
    FT_UInt     num_maps;
    PS_UniMap*  maps;

  } PS_UnicodesRec;

  /*
   *  A function which returns a glyph name for a given index.  Returns
   *  NULL if invalid index.
   */
  typedef const char*
  (*PS_GetGlyphNameFunc)( FT_Pointer  data,
                          FT_UInt     string_index );

  /*
   *  A function used to release the glyph name returned by
   *  PS_GetGlyphNameFunc, when needed
   */
  typedef void
  (*PS_FreeGlyphNameFunc)( FT_Pointer  data,
                           const char*  name );

  typedef FT_Error
  (*PS_Unicodes_InitFunc)( FT_Memory             memory,
                           PS_Unicodes           unicodes,
                           FT_UInt               num_glyphs,
                           PS_GetGlyphNameFunc   get_glyph_name,
                           PS_FreeGlyphNameFunc  free_glyph_name,
                           FT_Pointer            glyph_data );

  typedef FT_UInt
  (*PS_Unicodes_CharIndexFunc)( PS_Unicodes  unicodes,
                                FT_UInt32    unicode );

  typedef FT_UInt32
  (*PS_Unicodes_CharNextFunc)( PS_Unicodes  unicodes,
                               FT_UInt32   *unicode );

  FT_DEFINE_SERVICE( PsCMaps )
  {
    PS_Unicode_ValueFunc       unicode_value;

    PS_Unicodes_InitFunc       unicodes_init;
    PS_Unicodes_CharIndexFunc  unicodes_char_index;
    PS_Unicodes_CharNextFunc   unicodes_char_next;

    PS_Macintosh_NameFunc      macintosh_name;
    PS_Adobe_Std_StringsFunc   adobe_std_strings;
    const unsigned short*      adobe_std_encoding;
    const unsigned short*      adobe_expert_encoding;
  };

#ifndef FT_CONFIG_OPTION_PIC

#define FT_DEFINE_SERVICE_PSCMAPSREC( class_,                               \
                                      unicode_value_,                       \
                                      unicodes_init_,                       \
                                      unicodes_char_index_,                 \
                                      unicodes_char_next_,                  \
                                      macintosh_name_,                      \
                                      adobe_std_strings_,                   \
                                      adobe_std_encoding_,                  \
                                      adobe_expert_encoding_ )              \
  static const FT_Service_PsCMapsRec  class_ =                              \
  {                                                                         \
    unicode_value_, unicodes_init_,                                         \
    unicodes_char_index_, unicodes_char_next_, macintosh_name_,             \
    adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_         \
  };

#else /* FT_CONFIG_OPTION_PIC */

#define FT_DEFINE_SERVICE_PSCMAPSREC( class_,                               \
                                      unicode_value_,                       \
                                      unicodes_init_,                       \
                                      unicodes_char_index_,                 \
                                      unicodes_char_next_,                  \
                                      macintosh_name_,                      \
                                      adobe_std_strings_,                   \
                                      adobe_std_encoding_,                  \
                                      adobe_expert_encoding_ )              \
  void                                                                      \
  FT_Init_Class_ ## class_( FT_Library              library,                \
                            FT_Service_PsCMapsRec*  clazz )                 \
  {                                                                         \
    FT_UNUSED( library );                                                   \
                                                                            \
    clazz->unicode_value         = unicode_value_;                          \
    clazz->unicodes_init         = unicodes_init_;                          \
    clazz->unicodes_char_index   = unicodes_char_index_;                    \
    clazz->unicodes_char_next    = unicodes_char_next_;                     \
    clazz->macintosh_name        = macintosh_name_;                         \
    clazz->adobe_std_strings     = adobe_std_strings_;                      \
    clazz->adobe_std_encoding    = adobe_std_encoding_;                     \
    clazz->adobe_expert_encoding = adobe_expert_encoding_;                  \
  }

#endif /* FT_CONFIG_OPTION_PIC */

  /* */

FT_END_HEADER

#endif /* SVPSCMAP_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svtteng.h                                                              */
/*                                                                         */
/*    The FreeType TrueType engine query service (specification).          */
/*                                                                         */
/*  Copyright 2006-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVTTENG_H_
#define SVTTENG_H_

#include FT_INTERNAL_SERVICE_H
#include FT_MODULE_H

FT_BEGIN_HEADER

  /*
   *  SFNT table loading service.
   */

#define FT_SERVICE_ID_TRUETYPE_ENGINE  "truetype-engine"

  /*
   * Used to implement FT_Get_TrueType_Engine_Type
   */

  FT_DEFINE_SERVICE( TrueTypeEngine )
  {
    FT_TrueTypeEngineType  engine_type;
  };

  /* */

FT_END_HEADER

#endif /* SVTTENG_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svprop.h                                                               */
/*                                                                         */
/*    The FreeType property service (specification).                       */
/*                                                                         */
/*  Copyright 2012-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVPROP_H_
#define SVPROP_H_

FT_BEGIN_HEADER

#define FT_SERVICE_ID_PROPERTIES  "properties"

  typedef FT_Error
  (*FT_Properties_SetFunc)( FT_Module    module,
                            const char*  property_name,
                            const void*  value,
                            FT_Bool      value_is_string );

  typedef FT_Error
  (*FT_Properties_GetFunc)( FT_Module    module,
                            const char*  property_name,
                            void*        value );

  FT_DEFINE_SERVICE( Properties )
  {
    FT_Properties_SetFunc  set_property;
    FT_Properties_GetFunc  get_property;
  };

#ifndef FT_CONFIG_OPTION_PIC

#define FT_DEFINE_SERVICE_PROPERTIESREC( class_,          \
                                         set_property_,   \
                                         get_property_ )  \
  static const FT_Service_PropertiesRec  class_ =         \
  {                                                       \
    set_property_,                                        \
    get_property_                                         \
  };

#else /* FT_CONFIG_OPTION_PIC */

#define FT_DEFINE_SERVICE_PROPERTIESREC( class_,                \
                                         set_property_,         \
                                         get_property_ )        \
  void                                                          \
  FT_Init_Class_ ## class_( FT_Service_PropertiesRec*  clazz )  \
  {                                                             \
    clazz->set_property = set_property_;                        \
    clazz->get_property = get_property_;                        \
  }

#endif /* FT_CONFIG_OPTION_PIC */

  /* */

FT_END_HEADER

#endif /* SVPROP_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svkern.h                                                               */
/*                                                                         */
/*    The FreeType Kerning service (specification).                        */
/*                                                                         */
/*  Copyright 2006-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVKERN_H_
#define SVKERN_H_

#include FT_INTERNAL_SERVICE_H
#include FT_TRUETYPE_TABLES_H

FT_BEGIN_HEADER

#define FT_SERVICE_ID_KERNING  "kerning"

  typedef FT_Error
  (*FT_Kerning_TrackGetFunc)( FT_Face    face,
                              FT_Fixed   point_size,
                              FT_Int     degree,
                              FT_Fixed*  akerning );

  FT_DEFINE_SERVICE( Kerning )
  {
    FT_Kerning_TrackGetFunc  get_track;
  };

  /* */

FT_END_HEADER

#endif /* SVKERN_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svmetric.h                                                             */
/*                                                                         */
/*    The FreeType services for metrics variations (specification).        */
/*                                                                         */
/*  Copyright 2016-2017 by                                                 */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

#ifndef SVMETRIC_H_
#define SVMETRIC_H_

#include FT_INTERNAL_SERVICE_H

FT_BEGIN_HEADER

  /*
   *  A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables.
   *
   */

#define FT_SERVICE_ID_METRICS_VARIATIONS  "metrics-variations"

  /* HVAR */

  typedef FT_Error
  (*FT_HAdvance_Adjust_Func)( FT_Face  face,
                              FT_UInt  gindex,
                              FT_Int  *avalue );

  typedef FT_Error
  (*FT_LSB_Adjust_Func)( FT_Face  face,
                         FT_UInt  gindex,
                         FT_Int  *avalue );

  typedef FT_Error
  (*FT_RSB_Adjust_Func)( FT_Face  face,
                         FT_UInt  gindex,
                         FT_Int  *avalue );

  /* VVAR */

  typedef FT_Error
  (*FT_VAdvance_Adjust_Func)( FT_Face  face,
                              FT_UInt  gindex,
                              FT_Int  *avalue );

  typedef FT_Error
  (*FT_TSB_Adjust_Func)( FT_Face  face,
                         FT_UInt  gindex,
                         FT_Int  *avalue );

  typedef FT_Error
  (*FT_BSB_Adjust_Func)( FT_Face  face,
                         FT_UInt  gindex,
                         FT_Int  *avalue );

  typedef FT_Error
  (*FT_VOrg_Adjust_Func)( FT_Face  face,
                          FT_UInt  gindex,
                          FT_Int  *avalue );

  /* MVAR */

  typedef void
  (*FT_Metrics_Adjust_Func)( FT_Face  face );

  FT_DEFINE_SERVICE( MetricsVariations )
  {
    FT_HAdvance_Adjust_Func  hadvance_adjust;
    FT_LSB_Adjust_Func       lsb_adjust;
    FT_RSB_Adjust_Func       rsb_adjust;

    FT_VAdvance_Adjust_Func  vadvance_adjust;
    FT_TSB_Adjust_Func       tsb_adjust;
    FT_BSB_Adjust_Func       bsb_adjust;
    FT_VOrg_Adjust_Func      vorg_adjust;

    FT_Metrics_Adjust_Func   metrics_adjust;
  };

#ifndef FT_CONFIG_OPTION_PIC

#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_,            \
                                                hadvance_adjust_,  \
                                                lsb_adjust_,       \
                                                rsb_adjust_,       \
                                                vadvance_adjust_,  \
                                                tsb_adjust_,       \
                                                bsb_adjust_,       \
                                                vorg_adjust_,      \
                                                metrics_adjust_  ) \
  static const FT_Service_MetricsVariationsRec  class_ =           \
  {                                                                \
    hadvance_adjust_,                                              \
    lsb_adjust_,                                                   \
    rsb_adjust_,                                                   \
    vadvance_adjust_,                                              \
    tsb_adjust_,                                                   \
    bsb_adjust_,                                                   \
    vorg_adjust_,                                                  \
    metrics_adjust_                                                \
  };

#else /* FT_CONFIG_OPTION_PIC */

#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_,               \
                                                hadvance_adjust_,     \
                                                lsb_adjust_,          \
                                                rsb_adjust_,          \
                                                vadvance_adjust_,     \
                                                tsb_adjust_,          \
                                                bsb_adjust_,          \
                                                vorg_adjust_,         \
                                                metrics_adjust_  )    \
  void                                                                \
  FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec*  clazz ) \
  {                                                                   \
    clazz->hadvance_adjust = hadvance_adjust_;                        \
    clazz->lsb_adjust      = lsb_adjust_;                             \
    clazz->rsb_adjust      = rsb_adjust_;                             \
    clazz->vadvance_adjust = vadvance_adjust_;                        \
    clazz->tsb_adjust      = tsb_adjust_;                             \
    clazz->bsb_adjust      = bsb_adjust_;                             \
    clazz->vorg_adjust     = vorg_adjust_;                            \
    clazz->metrics_adjust  = metrics_adjust_;                         \
  }

#endif /* FT_CONFIG_OPTION_PIC */

  /* */

FT_END_HEADER

#endif /* SVMETRIC_H_ */

/* END */


text:
/***************************************************************************/
/*                                                                         */
/*  svgxval.h                                                              */
/*                                                                         */
/*    FreeType API for validating TrueTypeGX/AAT tables (specification).   */
/*                                                                         */
/*  Copyright 2004-2017 by                                                 */
/*  Masatake YAMATO, Red Hat K.K.,                                         */
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
/*                                                                         */
/*  This file is part of the FreeType project, and may only be used,       */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

/***************************************************************************/
/*                                                                         */
/* gxvalid is derived from both gxlayout module and otvalid module.        */
/* Development of gxlayout is supported by the Information-technology      */
/* Promotion Agency(IPA), Japan.                                           */
/*                                                                         */
/***************************************************************************/

#ifndef SVGXVAL_H_
#define SVGXVAL_H_

#include FT_GX_VALIDATE_H
#include FT_INTERNAL_VALIDATE_H

FT_BEGIN_HEADER

#define FT_SERVICE_ID_GX_VALIDATE           "truetypegx-validate"
#define FT_SERVICE_ID_CLASSICKERN_VALIDATE  "classickern-validate"

  typedef FT_Error
  (*gxv_validate_func)( FT_Face   face,
                        FT_UInt   gx_flags,
                        FT_Bytes  tables[FT_VALIDATE_GX_LENGTH],
                        FT_UInt   table_length );

  typedef FT_Error
  (*ckern_validate_func)( FT_Face   face,
                          FT_UInt   ckern_flags,
                          FT_Bytes  *ckern_table );

  FT_DEFINE_SERVICE( GXvalidate )
  {
    gxv_validate_func  validate;
  };

  FT_DEFINE_SERVICE( CKERNvalidate )
  {
    ckern_validate_func  validate;
  };

  /* */

FT_END_HEADER

#endif /* SVGXVAL_H_ */

/* END */