ftserv.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:14k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  ftserv.h                                                               */
  4. /*                                                                         */
  5. /*    The FreeType services (specification only).                          */
  6. /*                                                                         */
  7. /*  Copyright 2003, 2004, 2005, 2006, 2007 by                              */
  8. /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
  9. /*                                                                         */
  10. /*  This file is part of the FreeType project, and may only be used,       */
  11. /*  modified, and distributed under the terms of the FreeType project      */
  12. /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  13. /*  this file you indicate that you have read the license and              */
  14. /*  understand and accept it fully.                                        */
  15. /*                                                                         */
  16. /***************************************************************************/
  17.   /*************************************************************************/
  18.   /*                                                                       */
  19.   /*  Each module can export one or more `services'.  Each service is      */
  20.   /*  identified by a constant string and modeled by a pointer; the latter */
  21.   /*  generally corresponds to a structure containing function pointers.   */
  22.   /*                                                                       */
  23.   /*  Note that a service's data cannot be a mere function pointer because */
  24.   /*  in C it is possible that function pointers might be implemented      */
  25.   /*  differently than data pointers (e.g. 48 bits instead of 32).         */
  26.   /*                                                                       */
  27.   /*************************************************************************/
  28. #ifndef __FTSERV_H__
  29. #define __FTSERV_H__
  30. FT_BEGIN_HEADER
  31. #if defined( _MSC_VER )      /* Visual C++ (and Intel C++) */
  32.   /* we disable the warning `conditional expression is constant' here */
  33.   /* in order to compile cleanly with the maximum level of warnings   */
  34. #pragma warning( disable : 4127 )
  35. #endif /* _MSC_VER */
  36.   /*
  37.    * @macro:
  38.    *   FT_FACE_FIND_SERVICE
  39.    *
  40.    * @description:
  41.    *   This macro is used to look up a service from a face's driver module.
  42.    *
  43.    * @input:
  44.    *   face ::
  45.    *     The source face handle.
  46.    *
  47.    *   id ::
  48.    *     A string describing the service as defined in the service's
  49.    *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
  50.    *     `multi-masters').  It is automatically prefixed with
  51.    *     `FT_SERVICE_ID_'.
  52.    *
  53.    * @output:
  54.    *   ptr ::
  55.    *     A variable that receives the service pointer.  Will be NULL
  56.    *     if not found.
  57.    */
  58. #ifdef __cplusplus
  59. #define FT_FACE_FIND_SERVICE( face, ptr, id )                               
  60.   FT_BEGIN_STMNT                                                            
  61.     FT_Module    module = FT_MODULE( FT_FACE( face )->driver );             
  62.     FT_Pointer   _tmp_  = NULL;                                             
  63.     FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                              
  64.                                                                             
  65.                                                                             
  66.     if ( module->clazz->get_interface )                                     
  67.       _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); 
  68.     *_pptr_ = _tmp_;                                                        
  69.   FT_END_STMNT
  70. #else /* !C++ */
  71. #define FT_FACE_FIND_SERVICE( face, ptr, id )                               
  72.   FT_BEGIN_STMNT                                                            
  73.     FT_Module   module = FT_MODULE( FT_FACE( face )->driver );              
  74.     FT_Pointer  _tmp_  = NULL;                                              
  75.                                                                             
  76.     if ( module->clazz->get_interface )                                     
  77.       _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); 
  78.     ptr = _tmp_;                                                            
  79.   FT_END_STMNT
  80. #endif /* !C++ */
  81.   /*
  82.    * @macro:
  83.    *   FT_FACE_FIND_GLOBAL_SERVICE
  84.    *
  85.    * @description:
  86.    *   This macro is used to look up a service from all modules.
  87.    *
  88.    * @input:
  89.    *   face ::
  90.    *     The source face handle.
  91.    *
  92.    *   id ::
  93.    *     A string describing the service as defined in the service's
  94.    *     header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to
  95.    *     `multi-masters').  It is automatically prefixed with
  96.    *     `FT_SERVICE_ID_'.
  97.    *
  98.    * @output:
  99.    *   ptr ::
  100.    *     A variable that receives the service pointer.  Will be NULL
  101.    *     if not found.
  102.    */
  103. #ifdef __cplusplus
  104. #define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               
  105.   FT_BEGIN_STMNT                                                   
  106.     FT_Module    module = FT_MODULE( FT_FACE( face )->driver );    
  107.     FT_Pointer   _tmp_;                                            
  108.     FT_Pointer*  _pptr_ = (FT_Pointer*)&(ptr);                     
  109.                                                                    
  110.                                                                    
  111.     _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); 
  112.     *_pptr_ = _tmp_;                                               
  113.   FT_END_STMNT
  114. #else /* !C++ */
  115. #define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id )               
  116.   FT_BEGIN_STMNT                                                   
  117.     FT_Module   module = FT_MODULE( FT_FACE( face )->driver );     
  118.     FT_Pointer  _tmp_;                                             
  119.                                                                    
  120.                                                                    
  121.     _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); 
  122.     ptr   = _tmp_;                                                 
  123.   FT_END_STMNT
  124. #endif /* !C++ */
  125.   /*************************************************************************/
  126.   /*************************************************************************/
  127.   /*****                                                               *****/
  128.   /*****         S E R V I C E   D E S C R I P T O R S                 *****/
  129.   /*****                                                               *****/
  130.   /*************************************************************************/
  131.   /*************************************************************************/
  132.   /*
  133.    *  The following structure is used to _describe_ a given service
  134.    *  to the library.  This is useful to build simple static service lists.
  135.    */
  136.   typedef struct  FT_ServiceDescRec_
  137.   {
  138.     const char*  serv_id;     /* service name         */
  139.     const void*  serv_data;   /* service pointer/data */
  140.   } FT_ServiceDescRec;
  141.   typedef const FT_ServiceDescRec*  FT_ServiceDesc;
  142.   /*
  143.    *  Parse a list of FT_ServiceDescRec descriptors and look for
  144.    *  a specific service by ID.  Note that the last element in the
  145.    *  array must be { NULL, NULL }, and that the function should
  146.    *  return NULL if the service isn't available.
  147.    *
  148.    *  This function can be used by modules to implement their
  149.    *  `get_service' method.
  150.    */
  151.   FT_BASE( FT_Pointer )
  152.   ft_service_list_lookup( FT_ServiceDesc  service_descriptors,
  153.                           const char*     service_id );
  154.   /*************************************************************************/
  155.   /*************************************************************************/
  156.   /*****                                                               *****/
  157.   /*****             S E R V I C E S   C A C H E                       *****/
  158.   /*****                                                               *****/
  159.   /*************************************************************************/
  160.   /*************************************************************************/
  161.   /*
  162.    *  This structure is used to store a cache for several frequently used
  163.    *  services.  It is the type of `face->internal->services'.  You
  164.    *  should only use FT_FACE_LOOKUP_SERVICE to access it.
  165.    *
  166.    *  All fields should have the type FT_Pointer to relax compilation
  167.    *  dependencies.  We assume the developer isn't completely stupid.
  168.    *
  169.    *  Each field must be named `service_XXXX' where `XXX' corresponds to
  170.    *  the correct FT_SERVICE_ID_XXXX macro.  See the definition of
  171.    *  FT_FACE_LOOKUP_SERVICE below how this is implemented.
  172.    *
  173.    */
  174.   typedef struct  FT_ServiceCacheRec_
  175.   {
  176.     FT_Pointer  service_POSTSCRIPT_FONT_NAME;
  177.     FT_Pointer  service_MULTI_MASTERS;
  178.     FT_Pointer  service_GLYPH_DICT;
  179.     FT_Pointer  service_PFR_METRICS;
  180.     FT_Pointer  service_WINFNT;
  181.   } FT_ServiceCacheRec, *FT_ServiceCache;
  182.   /*
  183.    *  A magic number used within the services cache.
  184.    */
  185. #define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)-2)  /* magic number */
  186.   /*
  187.    * @macro:
  188.    *   FT_FACE_LOOKUP_SERVICE
  189.    *
  190.    * @description:
  191.    *   This macro is used to lookup a service from a face's driver module
  192.    *   using its cache.
  193.    *
  194.    * @input:
  195.    *   face::
  196.    *     The source face handle containing the cache.
  197.    *
  198.    *   field ::
  199.    *     The field name in the cache.
  200.    *
  201.    *   id ::
  202.    *     The service ID.
  203.    *
  204.    * @output:
  205.    *   ptr ::
  206.    *     A variable receiving the service data.  NULL if not available.
  207.    */
  208. #ifdef __cplusplus
  209. #define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                
  210.   FT_BEGIN_STMNT                                               
  211.     FT_Pointer   svc;                                          
  212.     FT_Pointer*  Pptr = (FT_Pointer*)&(ptr);                   
  213.                                                                
  214.                                                                
  215.     svc = FT_FACE( face )->internal->services. service_ ## id; 
  216.     if ( svc == FT_SERVICE_UNAVAILABLE )                       
  217.       svc = NULL;                                              
  218.     else if ( svc == NULL )                                    
  219.     {                                                          
  220.       FT_FACE_FIND_SERVICE( face, svc, id );                   
  221.                                                                
  222.       FT_FACE( face )->internal->services. service_ ## id =    
  223.         (FT_Pointer)( svc != NULL ? svc                        
  224.                                   : FT_SERVICE_UNAVAILABLE );  
  225.     }                                                          
  226.     *Pptr = svc;                                               
  227.   FT_END_STMNT
  228. #else /* !C++ */
  229. #define FT_FACE_LOOKUP_SERVICE( face, ptr, id )                
  230.   FT_BEGIN_STMNT                                               
  231.     FT_Pointer  svc;                                           
  232.                                                                
  233.                                                                
  234.     svc = FT_FACE( face )->internal->services. service_ ## id; 
  235.     if ( svc == FT_SERVICE_UNAVAILABLE )                       
  236.       svc = NULL;                                              
  237.     else if ( svc == NULL )                                    
  238.     {                                                          
  239.       FT_FACE_FIND_SERVICE( face, svc, id );                   
  240.                                                                
  241.       FT_FACE( face )->internal->services. service_ ## id =    
  242.         (FT_Pointer)( svc != NULL ? svc                        
  243.                                   : FT_SERVICE_UNAVAILABLE );  
  244.     }                                                          
  245.     ptr = svc;                                                 
  246.   FT_END_STMNT
  247. #endif /* !C++ */
  248.   /*
  249.    *  A macro used to define new service structure types.
  250.    */
  251. #define FT_DEFINE_SERVICE( name )            
  252.   typedef struct FT_Service_ ## name ## Rec_ 
  253.     FT_Service_ ## name ## Rec ;             
  254.   typedef struct FT_Service_ ## name ## Rec_ 
  255.     const * FT_Service_ ## name ;            
  256.   struct FT_Service_ ## name ## Rec_
  257.   /* */
  258.   /*
  259.    *  The header files containing the services.
  260.    */
  261. #define FT_SERVICE_BDF_H                <freetype/internal/services/svbdf.h>
  262. #define FT_SERVICE_GLYPH_DICT_H         <freetype/internal/services/svgldict.h>
  263. #define FT_SERVICE_GX_VALIDATE_H        <freetype/internal/services/svgxval.h>
  264. #define FT_SERVICE_KERNING_H            <freetype/internal/services/svkern.h>
  265. #define FT_SERVICE_MULTIPLE_MASTERS_H   <freetype/internal/services/svmm.h>
  266. #define FT_SERVICE_OPENTYPE_VALIDATE_H  <freetype/internal/services/svotval.h>
  267. #define FT_SERVICE_PFR_H                <freetype/internal/services/svpfr.h>
  268. #define FT_SERVICE_POSTSCRIPT_CMAPS_H   <freetype/internal/services/svpscmap.h>
  269. #define FT_SERVICE_POSTSCRIPT_INFO_H    <freetype/internal/services/svpsinfo.h>
  270. #define FT_SERVICE_POSTSCRIPT_NAME_H    <freetype/internal/services/svpostnm.h>
  271. #define FT_SERVICE_SFNT_H               <freetype/internal/services/svsfnt.h>
  272. #define FT_SERVICE_TRUETYPE_ENGINE_H    <freetype/internal/services/svtteng.h>
  273. #define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
  274. #define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
  275. #define FT_SERVICE_XFREE86_NAME_H       <freetype/internal/services/svxf86nm.h>
  276. #define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>
  277.  /* */
  278. FT_END_HEADER
  279. #endif /* __FTSERV_H__ */
  280. /* END */