1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/***************************************************************************/
/* */
/* ftcglyph.h */
/* */
/* FreeType abstract glyph cache (specification). */
/* */
/* Copyright 2000-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* Important: The functions defined in this file are only used to */
/* implement an abstract glyph cache class. You need to */
/* provide additional logic to implement a complete cache. */
/* For example, see `ftcimage.h' and `ftcimage.c' which */
/* implement a FT_Glyph cache based on this code. */
/* */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********* *********/
/********* WARNING, THIS IS BETA CODE. *********/
/********* *********/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifndef __FTCGLYPH_H__
#define __FTCGLYPH_H__
#include <ft2build.h>
#include FT_CACHE_H
#include FT_CACHE_MANAGER_H
#include <stddef.h>
FT_BEGIN_HEADER
/* each glyph set is characterized by a "glyph set type" which must be */
/* defined by sub-classes */
typedef struct FTC_GlyphFamilyRec_* FTC_GlyphFamily;
/* handle to a glyph cache node */
typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
/* size should be 24 + chunk size on 32-bit machines; */
/* note that the node's hash is ((gfam->hash << 16) | glyph_index) -- */
/* this _must_ be set properly by the glyph node initializer */
/* */
typedef struct FTC_GlyphNodeRec_
{
FTC_NodeRec node;
FT_UShort item_count;
FT_UShort item_start;
} FTC_GlyphNodeRec;
#define FTC_GLYPH_NODE( x ) ( (FTC_GlyphNode)(x) )
#define FTC_GLYPH_NODE_P( x ) ( (FTC_GlyphNode*)(x) )
typedef struct FTC_GlyphQueryRec_
{
FTC_QueryRec query;
FT_UInt gindex;
} FTC_GlyphQueryRec, *FTC_GlyphQuery;
#define FTC_GLYPH_QUERY( x ) ( (FTC_GlyphQuery)(x) )
/* a glyph set is used to categorize glyphs of a given type */
typedef struct FTC_GlyphFamilyRec_
{
FTC_FamilyRec family;
FT_UInt32 hash;
FT_UInt item_total; /* total number of glyphs in family */
FT_UInt item_count; /* number of glyph items per node */
} FTC_GlyphFamilyRec;
#define FTC_GLYPH_FAMILY( x ) ( (FTC_GlyphFamily)(x) )
#define FTC_GLYPH_FAMILY_P( x ) ( (FTC_GlyphFamily*)(x) )
#define FTC_GLYPH_FAMILY_MEMORY( x ) FTC_FAMILY(x)->cache->memory
/* each glyph node contains a 'chunk' of glyph items; */
/* translate a glyph index into a chunk index */
#define FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) \
( ( gindex ) / FTC_GLYPH_FAMILY( gfam )->item_count )
/* find a glyph index's chunk, and return its start index */
#define FTC_GLYPH_FAMILY_START( gfam, gindex ) \
( FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) * \
FTC_GLYPH_FAMILY( gfam )->item_count )
/* compute a glyph request's hash value */
#define FTC_GLYPH_FAMILY_HASH( gfam, gindex ) \
( (FT_UFast)( \
( FTC_GLYPH_FAMILY( gfam )->hash << 16 ) | \
( FTC_GLYPH_FAMILY_CHUNK( gfam, gindex ) & 0xFFFF ) ) )
/* must be called in an FTC_Family_CompareFunc to update the query */
/* whenever a glyph set is matched in the lookup, or when it */
/* is created */
#define FTC_GLYPH_FAMILY_FOUND( gfam, gquery ) \
do \
{ \
FTC_QUERY( gquery )->family = FTC_FAMILY( gfam ); \
FTC_QUERY( gquery )->hash = \
FTC_GLYPH_FAMILY_HASH( gfam, \
FTC_GLYPH_QUERY( gquery )->gindex ); \
} while ( 0 )
/* retrieve glyph index of glyph node */
#define FTC_GLYPH_NODE_GINDEX( x ) \
( (FT_UInt)( FTC_GLYPH_NODE( x )->node.hash & 0xFFFF ) )
/*************************************************************************/
/* */
/* These functions are exported so that they can be called from */
/* user-provided cache classes; otherwise, they are really part of the */
/* cache sub-system internals. */
/* */
/* must be called by derived FTC_Node_InitFunc routines */
FT_EXPORT( void )
ftc_glyph_node_init( FTC_GlyphNode node,
FT_UInt gindex, /* glyph index for node */
FTC_GlyphFamily gfam );
/* returns TRUE iff the query's glyph index correspond to the node; */
/* this assumes that the "family" and "hash" fields of the query are */
/* already correctly set */
FT_EXPORT( FT_Bool )
ftc_glyph_node_compare( FTC_GlyphNode gnode,
FTC_GlyphQuery gquery );
/* must be called by derived FTC_Node_DoneFunc routines */
FT_EXPORT( void )
ftc_glyph_node_done( FTC_GlyphNode node,
FTC_Cache cache );
/* must be called by derived FTC_Family_InitFunc; */
/* calls "ftc_family_init" */
FT_EXPORT( FT_Error )
ftc_glyph_family_init( FTC_GlyphFamily gfam,
FT_UInt32 hash,
FT_UInt item_count,
FT_UInt item_total,
FTC_GlyphQuery gquery,
FTC_Cache cache );
FT_EXPORT( void )
ftc_glyph_family_done( FTC_GlyphFamily gfam );
/* */
FT_END_HEADER
#endif /* __FTCGLYPH_H__ */
/* END */
|