~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/freetype/include/freetype/internal/ftserv.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

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