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

« back to all changes in this revision

Viewing changes to src/3rdparty/freetype/include/freetype/ftcache.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-10-12 23:14:14 UTC
  • mto: (15.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20061012231414-y2oqbom5dy389os0
Tags: upstream-4.2.0
ImportĀ upstreamĀ versionĀ 4.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
/*                                                                         */
5
5
/*    FreeType Cache subsystem (specification).                            */
6
6
/*                                                                         */
7
 
/*  Copyright 1996-2001, 2002, 2003, 2004 by                               */
 
7
/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by                   */
8
8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9
9
/*                                                                         */
10
10
/*  This file is part of the FreeType project, and may only be used,       */
16
16
/***************************************************************************/
17
17
 
18
18
 
19
 
  /*************************************************************************/
20
 
  /*************************************************************************/
21
 
  /*************************************************************************/
22
 
  /*************************************************************************/
23
 
  /*************************************************************************/
24
 
  /*********                                                       *********/
25
 
  /*********             WARNING, THIS IS BETA CODE.               *********/
26
 
  /*********                                                       *********/
27
 
  /*************************************************************************/
28
 
  /*************************************************************************/
29
 
  /*************************************************************************/
30
 
  /*************************************************************************/
31
 
  /*************************************************************************/
32
 
 
33
 
 
34
19
#ifndef __FTCACHE_H__
35
20
#define __FTCACHE_H__
36
21
 
42
27
FT_BEGIN_HEADER
43
28
 
44
29
 
45
 
  /*************************************************************************/
46
 
  /*                                                                       */
47
 
  /* <Section>                                                             */
48
 
  /*    cache_subsystem                                                    */
49
 
  /*                                                                       */
50
 
  /* <Title>                                                               */
51
 
  /*    Cache Sub-System                                                   */
52
 
  /*                                                                       */
53
 
  /* <Abstract>                                                            */
54
 
  /*    How to cache face, size, and glyph data with FreeType 2.           */
55
 
  /*                                                                       */
56
 
  /* <Description>                                                         */
57
 
  /*   This section describes the FreeType 2 cache sub-system which is     */
58
 
  /*   still in beta.                                                      */
59
 
  /*                                                                       */
60
 
  /* <Order>                                                               */
61
 
  /*   FTC_Manager                                                         */
62
 
  /*   FTC_FaceID                                                          */
63
 
  /*   FTC_Face_Requester                                                  */
64
 
  /*                                                                       */
65
 
  /*   FTC_Manager_New                                                     */
66
 
  /*   FTC_Manager_Reset                                                   */
67
 
  /*   FTC_Manager_Done                                                    */
68
 
  /*   FTC_Manager_LookupFace                                              */
69
 
  /*   FTC_Manager_LookupSize                                              */
70
 
  /*   FTC_Manager_RemoveFaceID                                            */
71
 
  /*                                                                       */
72
 
  /*   FTC_Node                                                            */
73
 
  /*   FTC_Node_Unref                                                      */
74
 
  /*                                                                       */
75
 
  /*   FTC_Font                                                            */
76
 
  /*   FTC_ImageCache                                                      */
77
 
  /*   FTC_ImageCache_New                                                  */
78
 
  /*   FTC_ImageCache_Lookup                                               */
79
 
  /*                                                                       */
80
 
  /*   FTC_SBit                                                            */
81
 
  /*   FTC_SBitCache                                                       */
82
 
  /*   FTC_SBitCache_New                                                   */
83
 
  /*   FTC_SBitCache_Lookup                                                */
84
 
  /*                                                                       */
85
 
  /*   FTC_CMapCache                                                       */
86
 
  /*   FTC_CMapCache_New                                                   */
87
 
  /*   FTC_CMapCache_Lookup                                                */
88
 
  /*                                                                       */
89
 
  /*************************************************************************/
 
30
  /*************************************************************************
 
31
   *
 
32
   * <Section>
 
33
   *    cache_subsystem
 
34
   *
 
35
   * <Title>
 
36
   *    Cache Sub-System
 
37
   *
 
38
   * <Abstract>
 
39
   *    How to cache face, size, and glyph data with FreeType 2.
 
40
   *
 
41
   * <Description>
 
42
   *   This section describes the FreeType 2 cache sub-system, which is used
 
43
   *   to limit the number of concurrently opened @FT_Face and @FT_Size
 
44
   *   objects, as well as caching information like character maps and glyph
 
45
   *   images while limiting their maximum memory usage.
 
46
   *
 
47
   *   Note that all types and functions begin with the `FTC_' prefix.
 
48
   *
 
49
   *   The cache is highly portable and thus doesn't know anything about the
 
50
   *   fonts installed on your system, or how to access them.  This implies
 
51
   *   the following scheme:
 
52
   *
 
53
   *   First, available or installed font faces are uniquely identified by
 
54
   *   @FTC_FaceID values, provided to the cache by the client.  Note that
 
55
   *   the cache only stores and compares these values, and doesn't try to
 
56
   *   interpret them in any way.
 
57
   *
 
58
   *   Second, the cache calls, only when needed, a client-provided function
 
59
   *   to convert a @FTC_FaceID into a new @FT_Face object.  The latter is
 
60
   *   then completely managed by the cache, including its termination
 
61
   *   through @FT_Done_Face.
 
62
   *
 
63
   *   Clients are free to map face IDs to anything else.  The most simple
 
64
   *   usage is to associate them to a (pathname,face_index) pair that is
 
65
   *   used to call @FT_New_Face.  However, more complex schemes are also
 
66
   *   possible.
 
67
   *
 
68
   *   Note that for the cache to work correctly, the face ID values must be
 
69
   *   *persistent*, which means that the contents they point to should not
 
70
   *   change at runtime, or that their value should not become invalid.
 
71
   *
 
72
   *   If this is unavoidable (e.g., when a font is uninstalled at runtime),
 
73
   *   you should call @FTC_Manager_RemoveFaceID as soon as possible, to let
 
74
   *   the cache get rid of any references to the old @FTC_FaceID it may
 
75
   *   keep internally.  Failure to do so will lead to incorrect behaviour
 
76
   *   or even crashes.
 
77
   *
 
78
   *   To use the cache, start with calling @FTC_Manager_New to create a new
 
79
   *   @FTC_Manager object, which models a single cache instance.  You can
 
80
   *   then look up @FT_Face and @FT_Size objects with
 
81
   *   @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively.
 
82
   *
 
83
   *   If you want to use the charmap caching, call @FTC_CMapCache_New, then
 
84
   *   later use @FTC_CMapCache_Lookup to perform the equivalent of
 
85
   *   @FT_Get_Char_Index, only much faster.
 
86
   *
 
87
   *   If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then
 
88
   *   later use @FTC_ImageCache_Lookup to retrieve the corresponding
 
89
   *   @FT_Glyph objects from the cache.
 
90
   *
 
91
   *   If you need lots of small bitmaps, it is much more memory efficient
 
92
   *   to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup.  This
 
93
   *   returns @FTC_SBitRec structures, which are used to store small
 
94
   *   bitmaps directly.  (A small bitmap is one whose metrics and
 
95
   *   dimensions all fit into 8-bit integers).
 
96
   *
 
97
   *   We hope to also provide a kerning cache in the near future.
 
98
   *
 
99
   *
 
100
   * <Order>
 
101
   *   FTC_Manager
 
102
   *   FTC_FaceID
 
103
   *   FTC_Face_Requester
 
104
   *
 
105
   *   FTC_Manager_New
 
106
   *   FTC_Manager_Reset
 
107
   *   FTC_Manager_Done
 
108
   *   FTC_Manager_LookupFace
 
109
   *   FTC_Manager_LookupSize
 
110
   *   FTC_Manager_RemoveFaceID
 
111
   *
 
112
   *   FTC_Node
 
113
   *   FTC_Node_Unref
 
114
   *
 
115
   *   FTC_ImageCache
 
116
   *   FTC_ImageCache_New
 
117
   *   FTC_ImageCache_Lookup
 
118
   *
 
119
   *   FTC_SBit
 
120
   *   FTC_SBitCache
 
121
   *   FTC_SBitCache_New
 
122
   *   FTC_SBitCache_Lookup
 
123
   *
 
124
   *   FTC_CMapCache
 
125
   *   FTC_CMapCache_New
 
126
   *   FTC_CMapCache_Lookup
 
127
   *
 
128
   *************************************************************************/
90
129
 
91
130
 
92
131
  /*************************************************************************/
100
139
  /*************************************************************************/
101
140
 
102
141
 
103
 
  /*************************************************************************/
104
 
  /*                                                                       */
105
 
  /* <Type>                                                                */
106
 
  /*    FTC_FaceID                                                         */
107
 
  /*                                                                       */
108
 
  /* <Description>                                                         */
109
 
  /*    An opaque pointer type that is used to identity face objects.  The */
110
 
  /*    contents of such objects is application-dependent.                 */
111
 
  /*                                                                       */
 
142
  /*************************************************************************
 
143
   *
 
144
   * @type: FTC_FaceID
 
145
   *
 
146
   * @description:
 
147
   *   An opaque pointer type that is used to identity face objects.  The
 
148
   *   contents of such objects is application-dependent.
 
149
   *
 
150
   *   These pointers are typically used to point to a user-defined
 
151
   *   structure containing a font file path, and face index.
 
152
   *
 
153
   * @note:
 
154
   *   Never use NULL as a valid @FTC_FaceID.
 
155
   *
 
156
   *   Face IDs are passed by the client to the cache manager, which calls,
 
157
   *   when needed, the @FTC_Face_Requester to translate them into new
 
158
   *   @FT_Face objects.
 
159
   *
 
160
   *   If the content of a given face ID changes at runtime, or if the value
 
161
   *   becomes invalid (e.g., when uninstalling a font), you should
 
162
   *   immediately call @FTC_Manager_RemoveFaceID before any other cache
 
163
   *   function.
 
164
   *
 
165
   *   Failure to do so will result in incorrect behaviour or even
 
166
   *   memory leaks and crashes.
 
167
   */
112
168
  typedef struct FTC_FaceIDRec_*  FTC_FaceID;
113
169
 
114
170
 
115
 
  /*************************************************************************/
116
 
  /*                                                                       */
117
 
  /* <FuncType>                                                            */
118
 
  /*    FTC_Face_Requester                                                 */
119
 
  /*                                                                       */
120
 
  /* <Description>                                                         */
121
 
  /*    A callback function provided by client applications.  It is used   */
122
 
  /*    to translate a given @FTC_FaceID into a new valid @FT_Face object. */
123
 
  /*                                                                       */
124
 
  /* <Input>                                                               */
125
 
  /*    face_id :: The face ID to resolve.                                 */
126
 
  /*                                                                       */
127
 
  /*    library :: A handle to a FreeType library object.                  */
128
 
  /*                                                                       */
129
 
  /*    data    :: Application-provided request data.                      */
130
 
  /*                                                                       */
131
 
  /* <Output>                                                              */
132
 
  /*    aface   :: A new @FT_Face handle.                                  */
133
 
  /*                                                                       */
134
 
  /* <Return>                                                              */
135
 
  /*    FreeType error code.  0 means success.                             */
136
 
  /*                                                                       */
137
 
  /* <Note>                                                                */
138
 
  /*    The face requester should not perform funny things on the returned */
139
 
  /*    face object, like creating a new @FT_Size for it, or setting a     */
140
 
  /*    transformation through @FT_Set_Transform!                          */
141
 
  /*                                                                       */
 
171
  /************************************************************************
 
172
   *
 
173
   * @functype:
 
174
   *   FTC_Face_Requester
 
175
   *
 
176
   * @description:
 
177
   *   A callback function provided by client applications.  It is used by
 
178
   *   the cache manager to translate a given @FTC_FaceID into a new valid
 
179
   *   @FT_Face object, on demand.
 
180
   *
 
181
   * <Input>
 
182
   *   face_id ::
 
183
   *     The face ID to resolve.
 
184
   *
 
185
   *   library ::
 
186
   *     A handle to a FreeType library object.
 
187
   *
 
188
   *   req_data ::
 
189
   *     Application-provided request data (see note below).
 
190
   *
 
191
   * <Output>
 
192
   *   aface ::
 
193
   *     A new @FT_Face handle.
 
194
   *
 
195
   * <Return>
 
196
   *   FreeType error code.  0 means success.
 
197
   *
 
198
   * <Note>
 
199
   *   The third parameter `req_data' is the same as the one passed by the
 
200
   *   client when @FTC_Manager_New is called.
 
201
   *
 
202
   *   The face requester should not perform funny things on the returned
 
203
   *   face object, like creating a new @FT_Size for it, or setting a
 
204
   *   transformation through @FT_Set_Transform!
 
205
   */
142
206
  typedef FT_Error
143
207
  (*FTC_Face_Requester)( FTC_FaceID  face_id,
144
208
                         FT_Library  library,
145
209
                         FT_Pointer  request_data,
146
210
                         FT_Face*    aface );
147
211
 
148
 
 
149
 
  /*************************************************************************/
150
 
  /*                                                                       */
151
 
  /* <Struct>                                                              */
152
 
  /*    FTC_FontRec                                                        */
153
 
  /*                                                                       */
154
 
  /* <Description>                                                         */
155
 
  /*    A simple structure used to describe a given `font' to the cache    */
156
 
  /*    manager.  Note that a `font' is the combination of a given face    */
157
 
  /*    with a given character size.                                       */
158
 
  /*                                                                       */
159
 
  /* <Fields>                                                              */
160
 
  /*    face_id    :: The ID of the face to use.                           */
161
 
  /*                                                                       */
162
 
  /*    pix_width  :: The character width in integer pixels.               */
163
 
  /*                                                                       */
164
 
  /*    pix_height :: The character height in integer pixels.              */
165
 
  /*                                                                       */
166
 
  typedef struct  FTC_FontRec_
167
 
  {
168
 
    FTC_FaceID  face_id;
169
 
    FT_UShort   pix_width;
170
 
    FT_UShort   pix_height;
171
 
 
172
 
  } FTC_FontRec;
173
 
 
174
 
 
175
 
  /* */
176
 
 
177
 
 
178
 
#define FTC_FONT_COMPARE( f1, f2 )                  \
179
 
          ( (f1)->face_id    == (f2)->face_id    && \
180
 
            (f1)->pix_width  == (f2)->pix_width  && \
181
 
            (f1)->pix_height == (f2)->pix_height )
182
 
 
183
 
#define FT_POINTER_TO_ULONG( p )  ((FT_ULong)(FT_Pointer)(p))
184
 
 
185
 
#define FTC_FACE_ID_HASH( i )                              \
186
 
          ((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \
 
212
 /* */
 
213
 
 
214
#define FT_POINTER_TO_ULONG( p )  ( (FT_ULong)(FT_Pointer)(p) )
 
215
 
 
216
#define FTC_FACE_ID_HASH( i )                                \
 
217
          ((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^   \
187
218
                       ( FT_POINTER_TO_ULONG( i ) << 7 ) ) )
188
219
 
189
 
#define FTC_FONT_HASH( f )                              \
190
 
          (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
191
 
                       ((f)->pix_width << 8)          ^ \
192
 
                       ((f)->pix_height)              )
193
 
 
194
 
 
195
 
  /*************************************************************************/
196
 
  /*                                                                       */
197
 
  /* <Type>                                                                */
198
 
  /*    FTC_Font                                                           */
199
 
  /*                                                                       */
200
 
  /* <Description>                                                         */
201
 
  /*    A simple handle to an @FTC_FontRec structure.                      */
202
 
  /*                                                                       */
203
 
  typedef FTC_FontRec*  FTC_Font;
204
 
 
205
220
 
206
221
  /*************************************************************************/
207
222
  /*************************************************************************/
220
235
  /*    FTC_Manager                                                        */
221
236
  /*                                                                       */
222
237
  /* <Description>                                                         */
223
 
  /*    This object is used to cache one or more @FT_Face objects, along   */
224
 
  /*    with corresponding @FT_Size objects.                               */
 
238
  /*    This object corresponds to one instance of the cache-subsystem.    */
 
239
  /*    It is used to cache one or more @FT_Face objects, along with       */
 
240
  /*    corresponding @FT_Size objects.                                    */
 
241
  /*                                                                       */
 
242
  /*    The manager intentionally limits the total number of opened        */
 
243
  /*    @FT_Face and @FT_Size objects to control memory usage.  See the    */
 
244
  /*    `max_faces' and `max_sizes' parameters of @FTC_Manager_New.        */
 
245
  /*                                                                       */
 
246
  /*    The manager is also used to cache `nodes' of various types while   */
 
247
  /*    limiting their total memory usage.                                 */
 
248
  /*                                                                       */
 
249
  /*    All limitations are enforced by keeping lists of managed objects   */
 
250
  /*    in most-recently-used order, and flushing old nodes to make room   */
 
251
  /*    for new ones.                                                      */
225
252
  /*                                                                       */
226
253
  typedef struct FTC_ManagerRec_*  FTC_Manager;
227
254
 
236
263
  /*    reference-counted.  A node with a count of 0 might be flushed      */
237
264
  /*    out of a full cache whenever a lookup request is performed.        */
238
265
  /*                                                                       */
239
 
  /*    If you lookup nodes, you have the ability to "acquire" them, i.e., */
 
266
  /*    If you lookup nodes, you have the ability to `acquire' them, i.e., */
240
267
  /*    to increment their reference count.  This will prevent the node    */
241
 
  /*    from being flushed out of the cache until you explicitly "release" */
 
268
  /*    from being flushed out of the cache until you explicitly `release' */
242
269
  /*    it (see @FTC_Node_Unref).                                          */
243
270
  /*                                                                       */
244
271
  /*    See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup.         */
255
282
  /*    Creates a new cache manager.                                       */
256
283
  /*                                                                       */
257
284
  /* <Input>                                                               */
258
 
  /*    library     :: The parent FreeType library handle to use.          */
259
 
  /*                                                                       */
260
 
  /*    max_bytes   :: Maximum number of bytes to use for cached data.     */
261
 
  /*                   Use 0 for defaults.                                 */
262
 
  /*                                                                       */
263
 
  /*    requester   :: An application-provided callback used to translate  */
264
 
  /*                   face IDs into real @FT_Face objects.                */
265
 
  /*                                                                       */
266
 
  /*    req_data    :: A generic pointer that is passed to the requester   */
267
 
  /*                   each time it is called (see @FTC_Face_Requester).   */
 
285
  /*    library   :: The parent FreeType library handle to use.            */
 
286
  /*                                                                       */
 
287
  /*    max_faces :: Maximum number of opened @FT_Face objects managed by  */
 
288
  /*                 this cache instance.  Use 0 for defaults.             */
 
289
  /*                                                                       */
 
290
  /*    max_sizes :: Maximum number of opened @FT_Size objects managed by  */
 
291
  /*                 this cache instance.  Use 0 for defaults.             */
 
292
  /*                                                                       */
 
293
  /*    max_bytes :: Maximum number of bytes to use for cached data nodes. */
 
294
  /*                 Use 0 for defaults.  Note that this value does not    */
 
295
  /*                 account for managed @FT_Face and @FT_Size objects.    */
 
296
  /*                                                                       */
 
297
  /*    requester :: An application-provided callback used to translate    */
 
298
  /*                 face IDs into real @FT_Face objects.                  */
 
299
  /*                                                                       */
 
300
  /*    req_data  :: A generic pointer that is passed to the requester     */
 
301
  /*                 each time it is called (see @FTC_Face_Requester).     */
268
302
  /*                                                                       */
269
303
  /* <Output>                                                              */
270
304
  /*    amanager  :: A handle to a new manager object.  0 in case of       */
346
380
  /*    the @FT_Set_Transform function) on a returned face!  If you need   */
347
381
  /*    to transform glyphs, do it yourself after glyph loading.           */
348
382
  /*                                                                       */
 
383
  /*    When you perform a lookup, out-of-memory errors are detected       */
 
384
  /*    _within_ the lookup and force incremental flushes of the cache     */
 
385
  /*    until enough memory is released for the lookup to succeed.         */
 
386
  /*                                                                       */
 
387
  /*    If a lookup fails with `FT_Err_Out_Of_Memory' the cache has        */
 
388
  /*    already been completely flushed, and still no memory was available */
 
389
  /*    for the operation.                                                 */
 
390
  /*                                                                       */
349
391
  FT_EXPORT( FT_Error )
350
392
  FTC_Manager_LookupFace( FTC_Manager  manager,
351
393
                          FTC_FaceID   face_id,
402
444
  /*                                                                       */
403
445
  /* <Description>                                                         */
404
446
  /*    Retrieve the @FT_Size object that corresponds to a given           */
405
 
  /*    @FTC_Scaler through a cache manager.                               */
 
447
  /*    @FTC_ScalerRec pointer through a cache manager.                    */
406
448
  /*                                                                       */
407
449
  /* <Input>                                                               */
408
450
  /*    manager :: A handle to the cache manager.                          */
423
465
  /*    if you need it.  Note that this object is also owned by the        */
424
466
  /*    manager.                                                           */
425
467
  /*                                                                       */
 
468
  /* <Note>                                                                */
 
469
  /*    When you perform a lookup, out-of-memory errors are detected       */
 
470
  /*    _within_ the lookup and force incremental flushes of the cache     */
 
471
  /*    until enough memory is released for the lookup to succeed.         */
 
472
  /*                                                                       */
 
473
  /*    If a lookup fails with `FT_Err_Out_Of_Memory' the cache has        */
 
474
  /*    already been completely flushed, and still no memory is available  */
 
475
  /*    for the operation.                                                 */
 
476
  /*                                                                       */
426
477
  FT_EXPORT( FT_Error )
427
478
  FTC_Manager_LookupSize( FTC_Manager  manager,
428
479
                          FTC_Scaler   scaler,
449
500
                  FTC_Manager  manager );
450
501
 
451
502
 
452
 
  /* remove all nodes belonging to a given face_id */
 
503
  /*************************************************************************
 
504
   *
 
505
   * @function:
 
506
   *   FTC_Manager_RemoveFaceID
 
507
   *
 
508
   * @description:
 
509
   *   A special function used to indicate to the cache manager that
 
510
   *   a given @FTC_FaceID is no longer valid, either because its
 
511
   *   content changed, or because it was deallocated or uninstalled.
 
512
   *
 
513
   * @input:
 
514
   *   manager ::
 
515
   *     The cache manager handle.
 
516
   *
 
517
   *   face_id ::
 
518
   *     The @FTC_FaceID to be removed.
 
519
   *
 
520
   * @note:
 
521
   *   This function flushes all nodes from the cache corresponding to this
 
522
   *   `face_id', with the exception of nodes with a non-null reference
 
523
   *   count.
 
524
   *
 
525
   *   Such nodes are however modified internally so as to never appear
 
526
   *   in later lookups with the same `face_id' value, and to be immediately
 
527
   *   destroyed when released by all their users.
 
528
   *
 
529
   */
453
530
  FT_EXPORT( void )
454
531
  FTC_Manager_RemoveFaceID( FTC_Manager  manager,
455
532
                            FTC_FaceID   face_id );
462
539
  /*                                                                       */
463
540
  /*************************************************************************/
464
541
 
465
 
  /************************************************************************
 
542
  /*************************************************************************
466
543
   *
467
544
   * @type:
468
 
   *    FTC_CMapCache
 
545
   *   FTC_CMapCache
469
546
   *
470
547
   * @description:
471
 
   *    An opaque handle used to manager a charmap cache.  This cache is
472
 
   *    to hold character codes -> glyph indices mappings.
 
548
   *   An opaque handle used to model a charmap cache.  This cache is to
 
549
   *   hold character codes -> glyph indices mappings.
 
550
   *
473
551
   */
474
552
  typedef struct FTC_CMapCacheRec_*  FTC_CMapCache;
475
553
 
476
554
 
477
 
  /*************************************************************************/
478
 
  /*                                                                       */
479
 
  /* @function:                                                            */
480
 
  /*    FTC_CMapCache_New                                                  */
481
 
  /*                                                                       */
482
 
  /* @description:                                                         */
483
 
  /*    Create a new charmap cache.                                        */
484
 
  /*                                                                       */
485
 
  /* @input:                                                               */
486
 
  /*    manager :: A handle to the cache manager.                          */
487
 
  /*                                                                       */
488
 
  /* @output:                                                              */
489
 
  /*    acache  :: A new cache handle.  NULL in case of error.             */
490
 
  /*                                                                       */
491
 
  /* @return:                                                              */
492
 
  /*    FreeType error code.  0 means success.                             */
493
 
  /*                                                                       */
494
 
  /* @note:                                                                */
495
 
  /*    Like all other caches, this one will be destroyed with the cache   */
496
 
  /*    manager.                                                           */
497
 
  /*                                                                       */
 
555
  /*************************************************************************
 
556
   *
 
557
   * @function:
 
558
   *   FTC_CMapCache_New
 
559
   *
 
560
   * @description:
 
561
   *   Create a new charmap cache.
 
562
   *
 
563
   * @input:
 
564
   *   manager ::
 
565
   *     A handle to the cache manager.
 
566
   *
 
567
   * @output:
 
568
   *   acache ::
 
569
   *     A new cache handle.  NULL in case of error.
 
570
   *
 
571
   * @return:
 
572
   *   FreeType error code.  0 means success.
 
573
   *
 
574
   * @note:
 
575
   *   Like all other caches, this one will be destroyed with the cache
 
576
   *   manager.
 
577
   *
 
578
   */
498
579
  FT_EXPORT( FT_Error )
499
580
  FTC_CMapCache_New( FTC_Manager     manager,
500
581
                     FTC_CMapCache  *acache );
501
582
 
502
583
 
503
 
  /*************************************************************************/
504
 
  /*                                                                       */
505
 
  /* @function:                                                            */
506
 
  /*    FTC_CMapCache_Lookup                                               */
507
 
  /*                                                                       */
508
 
  /* @description:                                                         */
509
 
  /*    Translate a character code into a glyph index, using the charmap   */
510
 
  /*    cache.                                                             */
511
 
  /*                                                                       */
512
 
  /* @input:                                                               */
513
 
  /*    cache      :: A charmap cache handle.                              */
514
 
  /*                                                                       */
515
 
  /*    face_id    :: The source face ID.                                  */
516
 
  /*                                                                       */
517
 
  /*    cmap_index :: The index of the charmap in the source face.         */
518
 
  /*                                                                       */
519
 
  /*    char_code  :: The character code (in the corresponding charmap).   */
520
 
  /*                                                                       */
521
 
  /* @return:                                                              */
522
 
  /*    Glyph index.  0 means `no glyph'.                                  */
523
 
  /*                                                                       */
 
584
  /************************************************************************
 
585
   *
 
586
   * @function:
 
587
   *   FTC_CMapCache_Lookup
 
588
   *
 
589
   * @description:
 
590
   *   Translate a character code into a glyph index, using the charmap
 
591
   *   cache.
 
592
   *
 
593
   * @input:
 
594
   *   cache ::
 
595
   *     A charmap cache handle.
 
596
   *
 
597
   *   face_id ::
 
598
   *     The source face ID.
 
599
   *
 
600
   *   cmap_index ::
 
601
   *     The index of the charmap in the source face.
 
602
   *
 
603
   *   char_code ::
 
604
   *     The character code (in the corresponding charmap).
 
605
   *
 
606
   * @return:
 
607
   *    Glyph index.  0 means `no glyph'.
 
608
   *
 
609
   */
524
610
  FT_EXPORT( FT_UInt )
525
611
  FTC_CMapCache_Lookup( FTC_CMapCache  cache,
526
612
                        FTC_FaceID     face_id,
546
632
  /*************************************************************************/
547
633
  /*************************************************************************/
548
634
 
 
635
 
 
636
  /*************************************************************************
 
637
   *
 
638
   * @struct:
 
639
   *   FTC_ImageTypeRec
 
640
   *
 
641
   * @description:
 
642
   *   A structure used to model the type of images in a glyph cache.
 
643
   *
 
644
   * @fields:
 
645
   *   face_id ::
 
646
   *     The face ID.
 
647
   *
 
648
   *   width ::
 
649
   *     The width in pixels.
 
650
   *
 
651
   *   height ::
 
652
   *     The height in pixels.
 
653
   *
 
654
   *   flags ::
 
655
   *     The load flags, as in @FT_Load_Glyph.
 
656
   *
 
657
   */
549
658
  typedef struct  FTC_ImageTypeRec_
550
659
  {
551
 
    FTC_FaceID   face_id;
552
 
    FT_Int       width;
553
 
    FT_Int       height;
554
 
    FT_Int32     flags;
 
660
    FTC_FaceID  face_id;
 
661
    FT_Int      width;
 
662
    FT_Int      height;
 
663
    FT_Int32    flags;
555
664
 
556
665
  } FTC_ImageTypeRec;
557
666
 
558
 
  typedef struct FTC_ImageTypeRec_*   FTC_ImageType;
559
 
 
560
 
 /* */
561
 
 
562
 
#define FTC_IMAGE_TYPE_COMPARE( d1, d2 )                    \
563
 
          ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
564
 
            (d1)->flags == (d2)->flags                   )
565
 
 
566
 
#define FTC_IMAGE_TYPE_HASH( d )                    \
567
 
          (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
568
 
                      ( (d)->flags << 4 )         )
 
667
 
 
668
  /*************************************************************************
 
669
   *
 
670
   * @type:
 
671
   *   FTC_ImageType
 
672
   *
 
673
   * @description:
 
674
   *   A handle to an @FTC_ImageTypeRec structure.
 
675
   *
 
676
   */
 
677
  typedef struct FTC_ImageTypeRec_*  FTC_ImageType;
 
678
 
 
679
 
 
680
  /* */
 
681
 
 
682
 
 
683
#define FTC_IMAGE_TYPE_COMPARE( d1, d2 )      \
 
684
          ( (d1)->face_id == (d2)->face_id && \
 
685
            (d1)->width   == (d2)->width   && \
 
686
            (d1)->flags   == (d2)->flags   )
 
687
 
 
688
#define FTC_IMAGE_TYPE_HASH( d )                          \
 
689
          (FT_UFast)( FTC_FACE_ID_HASH( (d)->face_id )  ^ \
 
690
                      ( (d)->width << 8 ) ^ (d)->height ^ \
 
691
                      ( (d)->flags << 4 )               )
569
692
 
570
693
 
571
694
  /*************************************************************************/
636
759
  /*                                                                       */
637
760
  /*    If `anode' is _not_ NULL, it receives the address of the cache     */
638
761
  /*    node containing the glyph image, after increasing its reference    */
639
 
  /*    count.  This ensures that the node (as well as the FT_Glyph) will  */
 
762
  /*    count.  This ensures that the node (as well as the @FT_Glyph) will */
640
763
  /*    always be kept in the cache until you call @FTC_Node_Unref to      */
641
764
  /*    `release' it.                                                      */
642
765
  /*                                                                       */
643
766
  /*    If `anode' is NULL, the cache node is left unchanged, which means  */
644
 
  /*    that the FT_Glyph could be flushed out of the cache on the next    */
 
767
  /*    that the @FT_Glyph could be flushed out of the cache on the next   */
645
768
  /*    call to one of the caching sub-system APIs.  Don't assume that it  */
646
769
  /*    is persistent!                                                     */
647
770
  /*                                                                       */
809
932
 
810
933
 /* */
811
934
 
 
935
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
 
936
 
 
937
  /*@***********************************************************************/
 
938
  /*                                                                       */
 
939
  /* <Struct>                                                              */
 
940
  /*    FTC_FontRec                                                        */
 
941
  /*                                                                       */
 
942
  /* <Description>                                                         */
 
943
  /*    A simple structure used to describe a given `font' to the cache    */
 
944
  /*    manager.  Note that a `font' is the combination of a given face    */
 
945
  /*    with a given character size.                                       */
 
946
  /*                                                                       */
 
947
  /* <Fields>                                                              */
 
948
  /*    face_id    :: The ID of the face to use.                           */
 
949
  /*                                                                       */
 
950
  /*    pix_width  :: The character width in integer pixels.               */
 
951
  /*                                                                       */
 
952
  /*    pix_height :: The character height in integer pixels.              */
 
953
  /*                                                                       */
 
954
  typedef struct  FTC_FontRec_
 
955
  {
 
956
    FTC_FaceID  face_id;
 
957
    FT_UShort   pix_width;
 
958
    FT_UShort   pix_height;
 
959
 
 
960
  } FTC_FontRec;
 
961
 
 
962
 
 
963
  /* */
 
964
 
 
965
 
 
966
#define FTC_FONT_COMPARE( f1, f2 )                  \
 
967
          ( (f1)->face_id    == (f2)->face_id    && \
 
968
            (f1)->pix_width  == (f2)->pix_width  && \
 
969
            (f1)->pix_height == (f2)->pix_height )
 
970
 
 
971
#define FTC_FONT_HASH( f )                              \
 
972
          (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
 
973
                       ((f)->pix_width << 8)          ^ \
 
974
                       ((f)->pix_height)              )
 
975
 
 
976
  typedef FTC_FontRec*  FTC_Font;
 
977
 
 
978
 
 
979
  FT_EXPORT( FT_Error )
 
980
  FTC_Manager_Lookup_Face( FTC_Manager  manager,
 
981
                           FTC_FaceID   face_id,
 
982
                           FT_Face     *aface );
 
983
 
 
984
  FT_EXPORT( FT_Error )
 
985
  FTC_Manager_Lookup_Size( FTC_Manager  manager,
 
986
                           FTC_Font     font,
 
987
                           FT_Face     *aface,
 
988
                           FT_Size     *asize );
 
989
 
 
990
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
 
991
 
 
992
 
 
993
 /* */
 
994
 
812
995
FT_END_HEADER
813
996
 
814
997
#endif /* __FTCACHE_H__ */