ReactOS 0.4.15-dev-7953-g1f49173
pshints.h
Go to the documentation of this file.
1/***************************************************************************/
2/* */
3/* pshints.h */
4/* */
5/* Adobe's code for handling CFF hints (body). */
6/* */
7/* Copyright 2007-2013 Adobe Systems Incorporated. */
8/* */
9/* This software, and all works of authorship, whether in source or */
10/* object code form as indicated by the copyright notice(s) included */
11/* herein (collectively, the "Work") is made available, and may only be */
12/* used, modified, and distributed under the FreeType Project License, */
13/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
14/* FreeType Project License, each contributor to the Work hereby grants */
15/* to any individual or legal entity exercising permissions granted by */
16/* the FreeType Project License and this section (hereafter, "You" or */
17/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
18/* royalty-free, irrevocable (except as stated in this section) patent */
19/* license to make, have made, use, offer to sell, sell, import, and */
20/* otherwise transfer the Work, where such license applies only to those */
21/* patent claims licensable by such contributor that are necessarily */
22/* infringed by their contribution(s) alone or by combination of their */
23/* contribution(s) with the Work to which such contribution(s) was */
24/* submitted. If You institute patent litigation against any entity */
25/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
26/* the Work or a contribution incorporated within the Work constitutes */
27/* direct or contributory patent infringement, then any patent licenses */
28/* granted to You under this License for that Work shall terminate as of */
29/* the date such litigation is filed. */
30/* */
31/* By using, modifying, or distributing the Work you indicate that you */
32/* have read and understood the terms and conditions of the */
33/* FreeType Project License as well as those provided in this section, */
34/* and you accept them fully. */
35/* */
36/***************************************************************************/
37
38
39#ifndef PSHINT_H_
40#define PSHINT_H_
41
43
44
45 enum
46 {
47 CF2_MAX_HINTS = 96 /* maximum # of hints */
48 };
49
50
51 /*
52 * A HintMask object stores a bit mask that specifies which hints in the
53 * charstring are active at a given time. Hints in CFF must be declared
54 * at the start, before any drawing operators, with horizontal hints
55 * preceding vertical hints. The HintMask is ordered the same way, with
56 * horizontal hints immediately followed by vertical hints. Clients are
57 * responsible for knowing how many of each type are present.
58 *
59 * The maximum total number of hints is 96, as specified by the CFF
60 * specification.
61 *
62 * A HintMask is built 0 or more times while interpreting a charstring, by
63 * the HintMask operator. There is only one HintMask, but it is built or
64 * rebuilt each time there is a hint substitution (HintMask operator) in
65 * the charstring. A default HintMask with all bits set is built if there
66 * has been no HintMask operator prior to the first drawing operator.
67 *
68 */
69
70 typedef struct CF2_HintMaskRec_
71 {
73
76
77 size_t bitCount;
78 size_t byteCount;
79
81
83
84
85 typedef struct CF2_StemHintRec_
86 {
87 FT_Bool used; /* DS positions are valid */
88
89 CF2_Fixed min; /* original character space value */
91
92 CF2_Fixed minDS; /* DS position after first use */
94
96
97
98 /*
99 * A HintMap object stores a piecewise linear function for mapping
100 * y-coordinates from character space to device space, providing
101 * appropriate pixel alignment to stem edges.
102 *
103 * The map is implemented as an array of `CF2_Hint' elements, each
104 * representing an edge. When edges are paired, as from stem hints, the
105 * bottom edge must immediately precede the top edge in the array.
106 * Element character space AND device space positions must both increase
107 * monotonically in the array. `CF2_Hint' elements are also used as
108 * parameters to `cf2_blues_capture'.
109 *
110 * The `cf2_hintmap_build' method must be called before any drawing
111 * operation (beginning with a Move operator) and at each hint
112 * substitution (HintMask operator).
113 *
114 * The `cf2_hintmap_map' method is called to transform y-coordinates at
115 * each drawing operation (move, line, curve).
116 *
117 */
118
119 /* TODO: make this a CF2_ArrStack and add a deep copy method */
120 enum
121 {
123 };
124
125
126 typedef struct CF2_HintMapRec_
127 {
129
130 /* initial map based on blue zones */
132
133 /* working storage for 2nd pass adjustHints */
135
138
141
142 /* start search from this index */
144
146
148
149
156 FT_LOCAL( void )
158
159
160 FT_LOCAL( void )
163 CF2_HintMap initialMap,
166 FT_LOCAL( void )
168 CF2_ArrStack hStemHintArray,
169 CF2_ArrStack vStemHintArray,
170 CF2_HintMask hintMask,
171 CF2_Fixed hintOrigin,
172 FT_Bool initialMap );
173
174
175 /*
176 * GlyphPath is a wrapper for drawing operations that scales the
177 * coordinates according to the render matrix and HintMap. It also tracks
178 * open paths to control ClosePath and to insert MoveTo for broken fonts.
179 *
180 */
181 typedef struct CF2_GlyphPathRec_
182 {
183 /* TODO: gather some of these into a hinting context */
184
185 CF2_Font font; /* font instance */
186 CF2_OutlineCallbacks callbacks; /* outline consumer */
187
188
189 CF2_HintMapRec hintMap; /* current hint map */
190 CF2_HintMapRec firstHintMap; /* saved copy */
191 CF2_HintMapRec initialHintMap; /* based on all captured hints */
192
193 CF2_ArrStackRec hintMoves; /* list of hint moves for 2nd pass */
194
195 CF2_Fixed scaleX; /* matrix a */
196 CF2_Fixed scaleC; /* matrix c */
197 CF2_Fixed scaleY; /* matrix d */
198
199 FT_Vector fractionalTranslation; /* including deviceXScale */
200#if 0
201 CF2_Fixed hShift; /* character space horizontal shift */
202 /* (for fauxing) */
203#endif
204
205 FT_Bool pathIsOpen; /* true after MoveTo */
206 FT_Bool pathIsClosing; /* true when synthesizing closepath line */
207 FT_Bool darken; /* true if stem darkening */
208 FT_Bool moveIsPending; /* true between MoveTo and offset MoveTo */
209
210 /* references used to call `cf2_hintmap_build', if necessary */
213 CF2_HintMask hintMask; /* ptr to the current mask */
214 CF2_Fixed hintOriginY; /* copy of current origin */
216
217 CF2_Fixed xOffset; /* character space offsets */
219
220 /* character space miter limit threshold */
222 /* vertical/horizontal snap distance in character space */
224
225 FT_Vector offsetStart0; /* first and second points of first */
226 FT_Vector offsetStart1; /* element with offset applied */
227
228 /* current point, character space, before offset */
230 /* current point, device space */
232 /* start point of subpath, character space */
234
235 /* the following members constitute the `queue' of one element */
238
243
245
246
247 FT_LOCAL( void )
251 CF2_Fixed scaleY,
252 /* CF2_Fixed hShift, */
253 CF2_ArrStack hStemHintArray,
254 CF2_ArrStack vStemHintArray,
255 CF2_HintMask hintMask,
256 CF2_Fixed hintOrigin,
257 const CF2_Blues blues,
258 const FT_Vector* fractionalTranslation );
259 FT_LOCAL( void )
261
262 FT_LOCAL( void )
264 CF2_Fixed x,
265 CF2_Fixed y );
266 FT_LOCAL( void )
268 CF2_Fixed x,
269 CF2_Fixed y );
270 FT_LOCAL( void )
276 CF2_Fixed x3,
277 CF2_Fixed y3 );
278 FT_LOCAL( void )
280
281
283
284
285#endif /* PSHINT_H_ */
286
287
288/* END */
#define FT_LOCAL(x)
Definition: ftconfig.h:387
#define FT_END_HEADER
Definition: ftheader.h:54
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:300
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLenum GLint GLuint mask
Definition: glext.h:6028
#define CF2_UInt
Definition: pstypes.h:64
#define CF2_Int
Definition: pstypes.h:65
Definition: mk_font.cpp:20
FT_BEGIN_HEADER struct CF2_ArrStackRec_ * CF2_ArrStack
FT_BEGIN_HEADER struct CF2_ArrStackRec_ CF2_ArrStackRec
#define CF2_Fixed
Definition: psfixed.h:48
cf2_hint_isBottom(const CF2_Hint hint)
Definition: pshints.c:248
cf2_glyphpath_moveTo(CF2_GlyphPath glyphpath, CF2_Fixed x, CF2_Fixed y)
Definition: pshints.c:1681
struct CF2_StemHintRec_ CF2_StemHintRec
struct CF2_StemHintRec_ * CF2_StemHint
cf2_hint_isTop(const CF2_Hint hint)
Definition: pshints.c:240
cf2_glyphpath_finalize(CF2_GlyphPath glyphpath)
Definition: pshints.c:1154
cf2_hintmap_build(CF2_HintMap hintmap, CF2_ArrStack hStemHintArray, CF2_ArrStack vStemHintArray, CF2_HintMask hintMask, CF2_Fixed hintOrigin, FT_Bool initialMap)
Definition: pshints.c:808
cf2_glyphpath_curveTo(CF2_GlyphPath glyphpath, CF2_Fixed x1, CF2_Fixed y1, CF2_Fixed x2, CF2_Fixed y2, CF2_Fixed x3, CF2_Fixed y3)
Definition: pshints.c:1817
struct CF2_HintMapRec_ * CF2_HintMap
cf2_glyphpath_closeOpenPath(CF2_GlyphPath glyphpath)
Definition: pshints.c:1907
struct CF2_GlyphPathRec_ CF2_GlyphPathRec
struct CF2_GlyphPathRec_ * CF2_GlyphPath
@ CF2_MAX_HINTS
Definition: pshints.h:47
cf2_glyphpath_init(CF2_GlyphPath glyphpath, CF2_Font font, CF2_OutlineCallbacks callbacks, CF2_Fixed scaleY, CF2_ArrStack hStemHintArray, CF2_ArrStack vStemHintArray, CF2_HintMask hintMask, CF2_Fixed hintOrigin, const CF2_Blues blues, const FT_Vector *fractionalTranslation)
Definition: pshints.c:1083
cf2_glyphpath_lineTo(CF2_GlyphPath glyphpath, CF2_Fixed x, CF2_Fixed y)
Definition: pshints.c:1711
cf2_hint_lock(CF2_Hint hint)
Definition: pshints.c:270
cf2_hint_isValid(const CF2_Hint hint)
Definition: pshints.c:218
cf2_hintmap_init(CF2_HintMap hintmap, CF2_Font font, CF2_HintMap initialMap, CF2_ArrStack hintMoves, CF2_Fixed scale)
Definition: pshints.c:277
struct CF2_HintMaskRec_ * CF2_HintMask
struct CF2_HintMapRec_ CF2_HintMapRec
@ CF2_MAX_HINT_EDGES
Definition: pshints.h:122
struct CF2_HintMaskRec_ CF2_HintMaskRec
FT_Vector prevElemP1
Definition: pshints.h:240
CF2_Fixed yOffset
Definition: pshints.h:218
CF2_Font font
Definition: pshints.h:185
CF2_ArrStackRec hintMoves
Definition: pshints.h:193
FT_Vector currentCS
Definition: pshints.h:229
CF2_Fixed xOffset
Definition: pshints.h:217
CF2_Fixed scaleY
Definition: pshints.h:197
CF2_HintMapRec firstHintMap
Definition: pshints.h:190
CF2_OutlineCallbacks callbacks
Definition: pshints.h:186
CF2_HintMapRec hintMap
Definition: pshints.h:189
FT_Vector offsetStart1
Definition: pshints.h:226
CF2_HintMask hintMask
Definition: pshints.h:213
FT_Vector fractionalTranslation
Definition: pshints.h:199
CF2_ArrStack vStemHintArray
Definition: pshints.h:212
FT_Bool pathIsClosing
Definition: pshints.h:206
CF2_Fixed scaleC
Definition: pshints.h:196
CF2_Fixed hintOriginY
Definition: pshints.h:214
CF2_Int prevElemOp
Definition: pshints.h:237
CF2_Fixed scaleX
Definition: pshints.h:195
CF2_HintMapRec initialHintMap
Definition: pshints.h:191
FT_Vector currentDS
Definition: pshints.h:231
const CF2_BluesRec * blues
Definition: pshints.h:215
FT_Bool darken
Definition: pshints.h:207
FT_Vector prevElemP2
Definition: pshints.h:241
FT_Vector start
Definition: pshints.h:233
FT_Vector offsetStart0
Definition: pshints.h:225
CF2_Fixed miterLimit
Definition: pshints.h:221
FT_Bool moveIsPending
Definition: pshints.h:208
FT_Vector prevElemP0
Definition: pshints.h:239
FT_Bool elemIsQueued
Definition: pshints.h:236
CF2_ArrStack hStemHintArray
Definition: pshints.h:211
FT_Bool pathIsOpen
Definition: pshints.h:205
FT_Vector prevElemP3
Definition: pshints.h:242
CF2_Fixed snapThreshold
Definition: pshints.h:223
CF2_UInt count
Definition: pshints.h:140
FT_Bool isValid
Definition: pshints.h:136
CF2_ArrStack hintMoves
Definition: pshints.h:134
CF2_UInt lastIndex
Definition: pshints.h:143
struct CF2_HintMapRec_ * initialHintMap
Definition: pshints.h:131
FT_Bool hinted
Definition: pshints.h:137
CF2_Fixed scale
Definition: pshints.h:139
CF2_Font font
Definition: pshints.h:128
CF2_HintRec edge[CF2_MAX_HINT_EDGES]
Definition: pshints.h:145
FT_Bool isNew
Definition: pshints.h:75
size_t byteCount
Definition: pshints.h:78
FT_Error * error
Definition: pshints.h:72
FT_Bool isValid
Definition: pshints.h:74
size_t bitCount
Definition: pshints.h:77
CF2_Fixed maxDS
Definition: pshints.h:93
CF2_Fixed min
Definition: pshints.h:89
CF2_Fixed max
Definition: pshints.h:90
FT_Bool used
Definition: pshints.h:87
CF2_Fixed minDS
Definition: pshints.h:92
DWORD hint
Definition: vfdcmd.c:88
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711
static int callbacks
Definition: xmllint.c:838