source: OGRE/trunk/ogrenew/Dependencies/include/freetype/ftcache.h @ 657

Revision 657, 51.2 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/***************************************************************************/
2/*                                                                         */
3/*  ftcache.h                                                              */
4/*                                                                         */
5/*    FreeType Cache subsystem (specification).                            */
6/*                                                                         */
7/*  Copyright 1996-2001, 2002, 2003, 2004, 2005 by                         */
8/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9/*                                                                         */
10/*  This file is part of the FreeType project, and may only be used,       */
11/*  modified, and distributed under the terms of the FreeType project      */
12/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13/*  this file you indicate that you have read the license and              */
14/*  understand and accept it fully.                                        */
15/*                                                                         */
16/***************************************************************************/
17
18
19  /*************************************************************************/
20  /*************************************************************************/
21  /*************************************************************************/
22  /*************************************************************************/
23  /*************************************************************************/
24  /*********                                                       *********/
25  /*********             WARNING, THIS IS BETA CODE.               *********/
26  /*********                                                       *********/
27  /*************************************************************************/
28  /*************************************************************************/
29  /*************************************************************************/
30  /*************************************************************************/
31  /*************************************************************************/
32
33
34#ifndef __FTCACHE_H__
35#define __FTCACHE_H__
36
37
38#include <ft2build.h>
39#include FT_GLYPH_H
40
41
42FT_BEGIN_HEADER
43
44
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  /*************************************************************************/
90
91
92  /*************************************************************************/
93  /*************************************************************************/
94  /*************************************************************************/
95  /*****                                                               *****/
96  /*****                    BASIC TYPE DEFINITIONS                     *****/
97  /*****                                                               *****/
98  /*************************************************************************/
99  /*************************************************************************/
100  /*************************************************************************/
101
102
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  /*                                                                       */
112  typedef struct FTC_FaceIDRec_*  FTC_FaceID;
113
114
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  /*                                                                       */
142  typedef FT_Error
143  (*FTC_Face_Requester)( FTC_FaceID  face_id,
144                         FT_Library  library,
145                         FT_Pointer  request_data,
146                         FT_Face*    aface );
147
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 ) ^ \
187                       ( FT_POINTER_TO_ULONG( i ) << 7 ) ) )
188
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
206  /*************************************************************************/
207  /*************************************************************************/
208  /*************************************************************************/
209  /*****                                                               *****/
210  /*****                      CACHE MANAGER OBJECT                     *****/
211  /*****                                                               *****/
212  /*************************************************************************/
213  /*************************************************************************/
214  /*************************************************************************/
215
216
217  /*************************************************************************/
218  /*                                                                       */
219  /* <Type>                                                                */
220  /*    FTC_Manager                                                        */
221  /*                                                                       */
222  /* <Description>                                                         */
223  /*    This object is used to cache one or more @FT_Face objects, along   */
224  /*    with corresponding @FT_Size objects.                               */
225  /*                                                                       */
226  typedef struct FTC_ManagerRec_*  FTC_Manager;
227
228
229  /*************************************************************************/
230  /*                                                                       */
231  /* <Type>                                                                */
232  /*    FTC_Node                                                           */
233  /*                                                                       */
234  /* <Description>                                                         */
235  /*    An opaque handle to a cache node object.  Each cache node is       */
236  /*    reference-counted.  A node with a count of 0 might be flushed      */
237  /*    out of a full cache whenever a lookup request is performed.        */
238  /*                                                                       */
239  /*    If you lookup nodes, you have the ability to "acquire" them, i.e., */
240  /*    to increment their reference count.  This will prevent the node    */
241  /*    from being flushed out of the cache until you explicitly "release" */
242  /*    it (see @FTC_Node_Unref).                                          */
243  /*                                                                       */
244  /*    See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup.         */
245  /*                                                                       */
246  typedef struct FTC_NodeRec_*  FTC_Node;
247
248
249  /*************************************************************************/
250  /*                                                                       */
251  /* <Function>                                                            */
252  /*    FTC_Manager_New                                                    */
253  /*                                                                       */
254  /* <Description>                                                         */
255  /*    Creates a new cache manager.                                       */
256  /*                                                                       */
257  /* <Input>                                                               */
258  /*    library     :: The parent FreeType library handle to use.          */
259  /*                                                                       */
260  /*    max_bytes   :: Maximum number of bytes to use for cached data      */
261  /*                   nodes.  Use 0 for defaults.  Note that this value   */
262  /*                   does not account for managed FT_Face and FT_Size    */
263  /*                   objects.                                            */
264  /*                                                                       */
265  /*    requester   :: An application-provided callback used to translate  */
266  /*                   face IDs into real @FT_Face objects.                */
267  /*                                                                       */
268  /*    req_data    :: A generic pointer that is passed to the requester   */
269  /*                   each time it is called (see @FTC_Face_Requester).   */
270  /*                                                                       */
271  /* <Output>                                                              */
272  /*    amanager  :: A handle to a new manager object.  0 in case of       */
273  /*                 failure.                                              */
274  /*                                                                       */
275  /* <Return>                                                              */
276  /*    FreeType error code.  0 means success.                             */
277  /*                                                                       */
278  /* <Note>                                                                */
279  /*    When you perform a lookup, out-of-memory errors are detected       */
280  /*    _within_ the lookup and force incremental flushes of the cache     */
281  /*    until enough memory is released for the lookup to succeed.         */
282  /*                                                                       */
283  /*    If a lookup fails with FT_Err_Out_Of_Memory the cache has already  */
284  /*    been completely flushed, and still no memory is available for the  */
285  /*    operation.                                                         */
286  /*                                                                       */
287  FT_EXPORT( FT_Error )
288  FTC_Manager_New( FT_Library          library,
289                   FT_UInt             max_faces,
290                   FT_UInt             max_sizes,
291                   FT_ULong            max_bytes,
292                   FTC_Face_Requester  requester,
293                   FT_Pointer          req_data,
294                   FTC_Manager        *amanager );
295
296
297  /*************************************************************************/
298  /*                                                                       */
299  /* <Function>                                                            */
300  /*    FTC_Manager_Reset                                                  */
301  /*                                                                       */
302  /* <Description>                                                         */
303  /*    Empties a given cache manager.  This simply gets rid of all the    */
304  /*    currently cached @FT_Face and @FT_Size objects within the manager. */
305  /*                                                                       */
306  /* <InOut>                                                               */
307  /*    manager :: A handle to the manager.                                */
308  /*                                                                       */
309  FT_EXPORT( void )
310  FTC_Manager_Reset( FTC_Manager  manager );
311
312
313  /*************************************************************************/
314  /*                                                                       */
315  /* <Function>                                                            */
316  /*    FTC_Manager_Done                                                   */
317  /*                                                                       */
318  /* <Description>                                                         */
319  /*    Destroys a given manager after emptying it.                        */
320  /*                                                                       */
321  /* <Input>                                                               */
322  /*    manager :: A handle to the target cache manager object.            */
323  /*                                                                       */
324  FT_EXPORT( void )
325  FTC_Manager_Done( FTC_Manager  manager );
326
327
328  /*************************************************************************/
329  /*                                                                       */
330  /* <Function>                                                            */
331  /*    FTC_Manager_LookupFace                                             */
332  /*                                                                       */
333  /* <Description>                                                         */
334  /*    Retrieves the @FT_Face object that corresponds to a given face ID  */
335  /*    through a cache manager.                                           */
336  /*                                                                       */
337  /* <Input>                                                               */
338  /*    manager :: A handle to the cache manager.                          */
339  /*                                                                       */
340  /*    face_id :: The ID of the face object.                              */
341  /*                                                                       */
342  /* <Output>                                                              */
343  /*    aface   :: A handle to the face object.                            */
344  /*                                                                       */
345  /* <Return>                                                              */
346  /*    FreeType error code.  0 means success.                             */
347  /*                                                                       */
348  /* <Note>                                                                */
349  /*    The returned @FT_Face object is always owned by the manager.  You  */
350  /*    should never try to discard it yourself.                           */
351  /*                                                                       */
352  /*    The @FT_Face object doesn't necessarily have a current size object */
353  /*    (i.e., face->size can be 0).  If you need a specific `font size',  */
354  /*    use @FTC_Manager_LookupSize instead.                               */
355  /*                                                                       */
356  /*    Never change the face's transformation matrix (i.e., never call    */
357  /*    the @FT_Set_Transform function) on a returned face!  If you need   */
358  /*    to transform glyphs, do it yourself after glyph loading.           */
359  /*                                                                       */
360  FT_EXPORT( FT_Error )
361  FTC_Manager_LookupFace( FTC_Manager  manager,
362                          FTC_FaceID   face_id,
363                          FT_Face     *aface );
364
365
366  /*************************************************************************/
367  /*                                                                       */
368  /* <Struct>                                                              */
369  /*    FTC_ScalerRec                                                      */
370  /*                                                                       */
371  /* <Description>                                                         */
372  /*    A structure used to describe a given character size in either      */
373  /*    pixels or points to the cache manager.  See                        */
374  /*    @FTC_Manager_LookupSize.                                           */
375  /*                                                                       */
376  /* <Fields>                                                              */
377  /*    face_id :: The source face ID.                                     */
378  /*                                                                       */
379  /*    width   :: The character width.                                    */
380  /*                                                                       */
381  /*    height  :: The character height.                                   */
382  /*                                                                       */
383  /*    pixel   :: A Boolean.  If TRUE, the `width' and `height' fields    */
384  /*               are interpreted as integer pixel character sizes.       */
385  /*               Otherwise, they are expressed as 1/64th of points.      */
386  /*                                                                       */
387  /*    x_res   :: Only used when `pixel' is FALSE to indicate the         */
388  /*               horizontal resolution in dpi.                           */
389  /*                                                                       */
390  /*    y_res   :: Only used when `pixel' is FALSE to indicate the         */
391  /*               vertical resolution in dpi.                             */
392  /*                                                                       */
393  /* <Note>                                                                */
394  /*    This type is mainly used to retrieve @FT_Size objects through the  */
395  /*    cache manager.                                                     */
396  /*                                                                       */
397  typedef struct  FTC_ScalerRec_
398  {
399    FTC_FaceID  face_id;
400    FT_UInt     width;
401    FT_UInt     height;
402    FT_Int      pixel;
403    FT_UInt     x_res;
404    FT_UInt     y_res;
405
406  } FTC_ScalerRec, *FTC_Scaler;
407
408
409  /*************************************************************************/
410  /*                                                                       */
411  /* <Function>                                                            */
412  /*    FTC_Manager_LookupSize                                             */
413  /*                                                                       */
414  /* <Description>                                                         */
415  /*    Retrieve the @FT_Size object that corresponds to a given           */
416  /*    @FTC_Scaler through a cache manager.                               */
417  /*                                                                       */
418  /* <Input>                                                               */
419  /*    manager :: A handle to the cache manager.                          */
420  /*                                                                       */
421  /*    scaler  :: A scaler handle.                                        */
422  /*                                                                       */
423  /* <Output>                                                              */
424  /*    asize   :: A handle to the size object.                            */
425  /*                                                                       */
426  /* <Return>                                                              */
427  /*    FreeType error code.  0 means success.                             */
428  /*                                                                       */
429  /* <Note>                                                                */
430  /*    The returned @FT_Size object is always owned by the manager.  You  */
431  /*    should never try to discard it by yourself.                        */
432  /*                                                                       */
433  /*    You can access the parent @FT_Face object simply as `size->face'   */
434  /*    if you need it.  Note that this object is also owned by the        */
435  /*    manager.                                                           */
436  /*                                                                       */
437  FT_EXPORT( FT_Error )
438  FTC_Manager_LookupSize( FTC_Manager  manager,
439                          FTC_Scaler   scaler,
440                          FT_Size     *asize );
441
442
443  /*************************************************************************/
444  /*                                                                       */
445  /* <Function>                                                            */
446  /*    FTC_Node_Unref                                                     */
447  /*                                                                       */
448  /* <Description>                                                         */
449  /*    Decrement a cache node's internal reference count.  When the count */
450  /*    reaches 0, it is not destroyed but becomes eligible for subsequent */
451  /*    cache flushes.                                                     */
452  /*                                                                       */
453  /* <Input>                                                               */
454  /*    node    :: The cache node handle.                                  */
455  /*                                                                       */
456  /*    manager :: The cache manager handle.                               */
457  /*                                                                       */
458  FT_EXPORT( void )
459  FTC_Node_Unref( FTC_Node     node,
460                  FTC_Manager  manager );
461
462
463  /* remove all nodes belonging to a given face_id */
464  FT_EXPORT( void )
465  FTC_Manager_RemoveFaceID( FTC_Manager  manager,
466                            FTC_FaceID   face_id );
467
468
469  /*************************************************************************/
470  /*                                                                       */
471  /* <Section>                                                             */
472  /*    cache_subsystem                                                    */
473  /*                                                                       */
474  /*************************************************************************/
475
476  /************************************************************************
477   *
478   * @type:
479   *    FTC_CMapCache
480   *
481   * @description:
482   *    An opaque handle used to manager a charmap cache.  This cache is
483   *    to hold character codes -> glyph indices mappings.
484   */
485  typedef struct FTC_CMapCacheRec_*  FTC_CMapCache;
486
487
488  /*************************************************************************/
489  /*                                                                       */
490  /* @function:                                                            */
491  /*    FTC_CMapCache_New                                                  */
492  /*                                                                       */
493  /* @description:                                                         */
494  /*    Create a new charmap cache.                                        */
495  /*                                                                       */
496  /* @input:                                                               */
497  /*    manager :: A handle to the cache manager.                          */
498  /*                                                                       */
499  /* @output:                                                              */
500  /*    acache  :: A new cache handle.  NULL in case of error.             */
501  /*                                                                       */
502  /* @return:                                                              */
503  /*    FreeType error code.  0 means success.                             */
504  /*                                                                       */
505  /* @note:                                                                */
506  /*    Like all other caches, this one will be destroyed with the cache   */
507  /*    manager.                                                           */
508  /*                                                                       */
509  FT_EXPORT( FT_Error )
510  FTC_CMapCache_New( FTC_Manager     manager,
511                     FTC_CMapCache  *acache );
512
513
514  /*************************************************************************/
515  /*                                                                       */
516  /* @function:                                                            */
517  /*    FTC_CMapCache_Lookup                                               */
518  /*                                                                       */
519  /* @description:                                                         */
520  /*    Translate a character code into a glyph index, using the charmap   */
521  /*    cache.                                                             */
522  /*                                                                       */
523  /* @input:                                                               */
524  /*    cache      :: A charmap cache handle.                              */
525  /*                                                                       */
526  /*    face_id    :: The source face ID.                                  */
527  /*                                                                       */
528  /*    cmap_index :: The index of the charmap in the source face.         */
529  /*                                                                       */
530  /*    char_code  :: The character code (in the corresponding charmap).   */
531  /*                                                                       */
532  /* @return:                                                              */
533  /*    Glyph index.  0 means `no glyph'.                                  */
534  /*                                                                       */
535  FT_EXPORT( FT_UInt )
536  FTC_CMapCache_Lookup( FTC_CMapCache  cache,
537                        FTC_FaceID     face_id,
538                        FT_Int         cmap_index,
539                        FT_UInt32      char_code );
540
541
542  /*************************************************************************/
543  /*                                                                       */
544  /* <Section>                                                             */
545  /*    cache_subsystem                                                    */
546  /*                                                                       */
547  /*************************************************************************/
548
549
550  /*************************************************************************/
551  /*************************************************************************/
552  /*************************************************************************/
553  /*****                                                               *****/
554  /*****                       IMAGE CACHE OBJECT                      *****/
555  /*****                                                               *****/
556  /*************************************************************************/
557  /*************************************************************************/
558  /*************************************************************************/
559
560  typedef struct  FTC_ImageTypeRec_
561  {
562    FTC_FaceID   face_id;
563    FT_Int       width;
564    FT_Int       height;
565    FT_Int32     flags;
566
567  } FTC_ImageTypeRec;
568
569  typedef struct FTC_ImageTypeRec_*   FTC_ImageType;
570
571 /* */
572
573#define FTC_IMAGE_TYPE_COMPARE( d1, d2 )                    \
574          ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
575            (d1)->flags == (d2)->flags                   )
576
577#define FTC_IMAGE_TYPE_HASH( d )                    \
578          (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
579                      ( (d)->flags << 4 )         )
580
581
582  /*************************************************************************/
583  /*                                                                       */
584  /* <Type>                                                                */
585  /*    FTC_ImageCache                                                     */
586  /*                                                                       */
587  /* <Description>                                                         */
588  /*    A handle to an glyph image cache object.  They are designed to     */
589  /*    hold many distinct glyph images while not exceeding a certain      */
590  /*    memory threshold.                                                  */
591  /*                                                                       */
592  typedef struct FTC_ImageCacheRec_*  FTC_ImageCache;
593
594
595  /*************************************************************************/
596  /*                                                                       */
597  /* <Function>                                                            */
598  /*    FTC_ImageCache_New                                                 */
599  /*                                                                       */
600  /* <Description>                                                         */
601  /*    Creates a new glyph image cache.                                   */
602  /*                                                                       */
603  /* <Input>                                                               */
604  /*    manager :: The parent manager for the image cache.                 */
605  /*                                                                       */
606  /* <Output>                                                              */
607  /*    acache  :: A handle to the new glyph image cache object.           */
608  /*                                                                       */
609  /* <Return>                                                              */
610  /*    FreeType error code.  0 means success.                             */
611  /*                                                                       */
612  FT_EXPORT( FT_Error )
613  FTC_ImageCache_New( FTC_Manager      manager,
614                      FTC_ImageCache  *acache );
615
616
617  /*************************************************************************/
618  /*                                                                       */
619  /* <Function>                                                            */
620  /*    FTC_ImageCache_Lookup                                              */
621  /*                                                                       */
622  /* <Description>                                                         */
623  /*    Retrieves a given glyph image from a glyph image cache.            */
624  /*                                                                       */
625  /* <Input>                                                               */
626  /*    cache  :: A handle to the source glyph image cache.                */
627  /*                                                                       */
628  /*    type   :: A pointer to a glyph image type descriptor.              */
629  /*                                                                       */
630  /*    gindex :: The glyph index to retrieve.                             */
631  /*                                                                       */
632  /* <Output>                                                              */
633  /*    aglyph :: The corresponding @FT_Glyph object.  0 in case of        */
634  /*              failure.                                                 */
635  /*                                                                       */
636  /*    anode  :: Used to return the address of of the corresponding cache */
637  /*              node after incrementing its reference count (see note    */
638  /*              below).                                                  */
639  /*                                                                       */
640  /* <Return>                                                              */
641  /*    FreeType error code.  0 means success.                             */
642  /*                                                                       */
643  /* <Note>                                                                */
644  /*    The returned glyph is owned and managed by the glyph image cache.  */
645  /*    Never try to transform or discard it manually!  You can however    */
646  /*    create a copy with @FT_Glyph_Copy and modify the new one.          */
647  /*                                                                       */
648  /*    If `anode' is _not_ NULL, it receives the address of the cache     */
649  /*    node containing the glyph image, after increasing its reference    */
650  /*    count.  This ensures that the node (as well as the FT_Glyph) will  */
651  /*    always be kept in the cache until you call @FTC_Node_Unref to      */
652  /*    `release' it.                                                      */
653  /*                                                                       */
654  /*    If `anode' is NULL, the cache node is left unchanged, which means  */
655  /*    that the FT_Glyph could be flushed out of the cache on the next    */
656  /*    call to one of the caching sub-system APIs.  Don't assume that it  */
657  /*    is persistent!                                                     */
658  /*                                                                       */
659  FT_EXPORT( FT_Error )
660  FTC_ImageCache_Lookup( FTC_ImageCache  cache,
661                         FTC_ImageType   type,
662                         FT_UInt         gindex,
663                         FT_Glyph       *aglyph,
664                         FTC_Node       *anode );
665
666
667  /*************************************************************************/
668  /*                                                                       */
669  /* <Type>                                                                */
670  /*    FTC_SBit                                                           */
671  /*                                                                       */
672  /* <Description>                                                         */
673  /*    A handle to a small bitmap descriptor.  See the @FTC_SBitRec       */
674  /*    structure for details.                                             */
675  /*                                                                       */
676  typedef struct FTC_SBitRec_*  FTC_SBit;
677
678
679  /*************************************************************************/
680  /*                                                                       */
681  /* <Struct>                                                              */
682  /*    FTC_SBitRec                                                        */
683  /*                                                                       */
684  /* <Description>                                                         */
685  /*    A very compact structure used to describe a small glyph bitmap.    */
686  /*                                                                       */
687  /* <Fields>                                                              */
688  /*    width     :: The bitmap width in pixels.                           */
689  /*                                                                       */
690  /*    height    :: The bitmap height in pixels.                          */
691  /*                                                                       */
692  /*    left      :: The horizontal distance from the pen position to the  */
693  /*                 left bitmap border (a.k.a. `left side bearing', or    */
694  /*                 `lsb').                                               */
695  /*                                                                       */
696  /*    top       :: The vertical distance from the pen position (on the   */
697  /*                 baseline) to the upper bitmap border (a.k.a. `top     */
698  /*                 side bearing').  The distance is positive for upwards */
699  /*                 Y coordinates.                                        */
700  /*                                                                       */
701  /*    format    :: The format of the glyph bitmap (monochrome or gray).  */
702  /*                                                                       */
703  /*    max_grays :: Maximum gray level value (in the range 1 to 255).     */
704  /*                                                                       */
705  /*    pitch     :: The number of bytes per bitmap line.  May be positive */
706  /*                 or negative.                                          */
707  /*                                                                       */
708  /*    xadvance  :: The horizontal advance width in pixels.               */
709  /*                                                                       */
710  /*    yadvance  :: The vertical advance height in pixels.                */
711  /*                                                                       */
712  /*    buffer    :: A pointer to the bitmap pixels.                       */
713  /*                                                                       */
714  typedef struct  FTC_SBitRec_
715  {
716    FT_Byte   width;
717    FT_Byte   height;
718    FT_Char   left;
719    FT_Char   top;
720
721    FT_Byte   format;
722    FT_Byte   max_grays;
723    FT_Short  pitch;
724    FT_Char   xadvance;
725    FT_Char   yadvance;
726
727    FT_Byte*  buffer;
728
729  } FTC_SBitRec;
730
731
732  /*************************************************************************/
733  /*                                                                       */
734  /* <Type>                                                                */
735  /*    FTC_SBitCache                                                      */
736  /*                                                                       */
737  /* <Description>                                                         */
738  /*    A handle to a small bitmap cache.  These are special cache objects */
739  /*    used to store small glyph bitmaps (and anti-aliased pixmaps) in a  */
740  /*    much more efficient way than the traditional glyph image cache     */
741  /*    implemented by @FTC_ImageCache.                                    */
742  /*                                                                       */
743  typedef struct FTC_SBitCacheRec_*  FTC_SBitCache;
744
745
746  /*************************************************************************/
747  /*                                                                       */
748  /* <Function>                                                            */
749  /*    FTC_SBitCache_New                                                  */
750  /*                                                                       */
751  /* <Description>                                                         */
752  /*    Creates a new cache to store small glyph bitmaps.                  */
753  /*                                                                       */
754  /* <Input>                                                               */
755  /*    manager :: A handle to the source cache manager.                   */
756  /*                                                                       */
757  /* <Output>                                                              */
758  /*    acache  :: A handle to the new sbit cache.  NULL in case of error. */
759  /*                                                                       */
760  /* <Return>                                                              */
761  /*    FreeType error code.  0 means success.                             */
762  /*                                                                       */
763  FT_EXPORT( FT_Error )
764  FTC_SBitCache_New( FTC_Manager     manager,
765                     FTC_SBitCache  *acache );
766
767
768  /*************************************************************************/
769  /*                                                                       */
770  /* <Function>                                                            */
771  /*    FTC_SBitCache_Lookup                                               */
772  /*                                                                       */
773  /* <Description>                                                         */
774  /*    Looks up a given small glyph bitmap in a given sbit cache and      */
775  /*    `lock' it to prevent its flushing from the cache until needed.     */
776  /*                                                                       */
777  /* <Input>                                                               */
778  /*    cache  :: A handle to the source sbit cache.                       */
779  /*                                                                       */
780  /*    type   :: A pointer to the glyph image type descriptor.            */
781  /*                                                                       */
782  /*    gindex :: The glyph index.                                         */
783  /*                                                                       */
784  /* <Output>                                                              */
785  /*    sbit   :: A handle to a small bitmap descriptor.                   */
786  /*                                                                       */
787  /*    anode  :: Used to return the address of of the corresponding cache */
788  /*              node after incrementing its reference count (see note    */
789  /*              below).                                                  */
790  /*                                                                       */
791  /* <Return>                                                              */
792  /*    FreeType error code.  0 means success.                             */
793  /*                                                                       */
794  /* <Note>                                                                */
795  /*    The small bitmap descriptor and its bit buffer are owned by the    */
796  /*    cache and should never be freed by the application.  They might    */
797  /*    as well disappear from memory on the next cache lookup, so don't   */
798  /*    treat them as persistent data.                                     */
799  /*                                                                       */
800  /*    The descriptor's `buffer' field is set to 0 to indicate a missing  */
801  /*    glyph bitmap.                                                      */
802  /*                                                                       */
803  /*    If `anode' is _not_ NULL, it receives the address of the cache     */
804  /*    node containing the bitmap, after increasing its reference count.  */
805  /*    This ensures that the node (as well as the image) will always be   */
806  /*    kept in the cache until you call @FTC_Node_Unref to `release' it.  */
807  /*                                                                       */
808  /*    If `anode' is NULL, the cache node is left unchanged, which means  */
809  /*    that the bitmap could be flushed out of the cache on the next      */
810  /*    call to one of the caching sub-system APIs.  Don't assume that it  */
811  /*    is persistent!                                                     */
812  /*                                                                       */
813  FT_EXPORT( FT_Error )
814  FTC_SBitCache_Lookup( FTC_SBitCache    cache,
815                        FTC_ImageType    type,
816                        FT_UInt          gindex,
817                        FTC_SBit        *sbit,
818                        FTC_Node        *anode );
819
820
821 /* */
822
823FT_END_HEADER
824
825#endif /* __FTCACHE_H__ */
826
827
828/* END */
Note: See TracBrowser for help on using the repository browser.