aa21228a79b9b7ac1387d7aed802600b03aa3988
[reactos.git] / lib / freetype / src / cache / ftcglyph.c
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftcglyph.c                                                             */
4 /*                                                                         */
5 /*    FreeType Glyph Image (FT_Glyph) cache (body).                        */
6 /*                                                                         */
7 /*  Copyright 2000-2001 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 #include <ft2build.h>
20 #include FT_CACHE_H
21 #include FT_CACHE_INTERNAL_GLYPH_H
22 #include FT_ERRORS_H
23 #include FT_LIST_H
24 #include FT_INTERNAL_OBJECTS_H
25 #include FT_INTERNAL_DEBUG_H
26
27 #include "ftcerror.h"
28
29
30   /* create a new chunk node, setting its cache index and ref count */
31   FT_EXPORT_DEF( void )
32   ftc_glyph_node_init( FTC_GlyphNode     gnode,
33                        FT_UInt           gindex,
34                        FTC_GlyphFamily   gfam )
35   {
36     FT_UInt  len;
37     FT_UInt  start = FTC_GLYPH_FAMILY_START( gfam, gindex );
38
39
40     gnode->item_start = (FT_UShort)start;
41
42     len = gfam->item_total - start;
43     if ( len > gfam->item_count )
44       len = gfam->item_count;
45
46     gnode->item_count = (FT_UShort)len;
47     gfam->family.num_nodes++;
48   }
49
50
51   FT_EXPORT_DEF( void )
52   ftc_glyph_node_done( FTC_GlyphNode  gnode,
53                        FTC_Cache      cache )
54   {
55     /* finalize the node */
56     gnode->item_count = 0;
57     gnode->item_start = 0;
58
59     ftc_node_done( FTC_NODE( gnode ), cache );
60   }
61
62
63   FT_EXPORT_DEF( FT_Bool )
64   ftc_glyph_node_compare( FTC_GlyphNode   gnode,
65                           FTC_GlyphQuery  gquery )
66   {
67     FT_UInt  start = (FT_UInt)gnode->item_start;
68     FT_UInt  count = (FT_UInt)gnode->item_count;
69
70     return FT_BOOL( (FT_UInt)( gquery->gindex - start ) < count );
71   }
72
73
74   /*************************************************************************/
75   /*************************************************************************/
76   /*****                                                               *****/
77   /*****                      CHUNK SETS                               *****/
78   /*****                                                               *****/
79   /*************************************************************************/
80   /*************************************************************************/
81
82
83   FT_EXPORT_DEF( FT_Error )
84   ftc_glyph_family_init( FTC_GlyphFamily  gfam,
85                          FT_UInt32        hash,
86                          FT_UInt          item_count,
87                          FT_UInt          item_total,
88                          FTC_GlyphQuery   gquery,
89                          FTC_Cache        cache )
90   {
91     FT_Error  error;
92
93
94     error = ftc_family_init( FTC_FAMILY( gfam ), FTC_QUERY( gquery ), cache );
95     if ( !error )
96     {
97       gfam->hash       = hash;
98       gfam->item_total = item_total;
99       gfam->item_count = item_count;
100       
101       FTC_GLYPH_FAMILY_FOUND( gfam, gquery );
102     }
103
104     return error;
105   }
106
107
108   FT_EXPORT_DEF( void )
109   ftc_glyph_family_done( FTC_GlyphFamily  gfam )
110   {
111     ftc_family_done( FTC_FAMILY( gfam ) );
112   }
113
114
115 /* END */