sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ttobjs.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ttobjs.h
4 *
5 * Objects manager (specification).
6 *
7 * Copyright (C) 1996-2025 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
23#ifndef TTOBJS_H_
24#define TTOBJS_H_
25
26
29
30
31FT_BEGIN_HEADER
32
33
34 /**************************************************************************
35 *
36 * @Type:
37 * TT_Driver
38 *
39 * @Description:
40 * A handle to a TrueType driver object.
41 */
42 typedef struct TT_DriverRec_* TT_Driver;
43
44
45 /**************************************************************************
46 *
47 * @Type:
48 * TT_GlyphSlot
49 *
50 * @Description:
51 * A handle to a TrueType glyph slot object.
52 *
53 * @Note:
54 * This is a direct typedef of FT_GlyphSlot, as there is nothing
55 * specific about the TrueType glyph slot.
56 */
57 typedef FT_GlyphSlot TT_GlyphSlot;
58
59
60#ifdef TT_USE_BYTECODE_INTERPRETER
61
62 /**************************************************************************
63 *
64 * @Struct:
65 * TT_GraphicsState
66 *
67 * @Description:
68 * The TrueType graphics state used during bytecode interpretation.
69 */
70 typedef struct TT_GraphicsState_
71 {
72 FT_UShort rp0;
73 FT_UShort rp1;
74 FT_UShort rp2;
75
76 FT_UShort gep0;
77 FT_UShort gep1;
78 FT_UShort gep2;
79
80 FT_UnitVector dualVector;
81 FT_UnitVector projVector;
82 FT_UnitVector freeVector;
83
84 FT_Long loop;
85 FT_Int round_state;
86 FT_F26Dot6 compensation[4]; /* device-specific compensations */
87
88 /* default values below can be modified by 'fpgm' and 'prep' */
89 FT_F26Dot6 minimum_distance;
90 FT_F26Dot6 control_value_cutin;
91 FT_F26Dot6 single_width_cutin;
92 FT_F26Dot6 single_width_value;
93 FT_UShort delta_base;
94 FT_UShort delta_shift;
95
96 FT_Bool auto_flip;
97 FT_Byte instruct_control;
98 /* According to Greg Hitchcock from Microsoft, the `scan_control' */
99 /* variable as documented in the TrueType specification is a 32-bit */
100 /* integer; the high-word part holds the SCANTYPE value, the low-word */
101 /* part the SCANCTRL value. We separate it into two fields. */
102 FT_Bool scan_control;
103 FT_Int scan_type;
104
105 } TT_GraphicsState;
106
107
108 FT_LOCAL( void )
109 tt_glyphzone_done( FT_Memory memory,
110 TT_GlyphZone zone );
111
112 FT_LOCAL( FT_Error )
113 tt_glyphzone_new( FT_Memory memory,
114 FT_UShort maxPoints,
115 FT_UShort maxContours,
116 TT_GlyphZone zone );
117
118#endif /* TT_USE_BYTECODE_INTERPRETER */
119
120
121
122 /**************************************************************************
123 *
124 * A note regarding non-squared pixels:
125 *
126 * (This text will probably go into some docs at some time; for now, it
127 * is kept here to explain some definitions in the TT_Size_Metrics
128 * record).
129 *
130 * The CVT is a one-dimensional array containing values that control
131 * certain important characteristics in a font, like the height of all
132 * capitals, all lowercase letter, default spacing or stem width/height.
133 *
134 * These values are found in FUnits in the font file, and must be scaled
135 * to pixel coordinates before being used by the CVT and glyph programs.
136 * Unfortunately, when using distinct x and y resolutions (or distinct x
137 * and y pointsizes), there are two possible scalings.
138 *
139 * A first try was to implement a `lazy' scheme where all values were
140 * scaled when first used. However, while some values are always used
141 * in the same direction, some others are used under many different
142 * circumstances and orientations.
143 *
144 * I have found a simpler way to do the same, and it even seems to work
145 * in most of the cases:
146 *
147 * - All CVT values are scaled to the maximum ppem size.
148 *
149 * - When performing a read or write in the CVT, a ratio factor is used
150 * to perform adequate scaling. Example:
151 *
152 * x_ppem = 14
153 * y_ppem = 10
154 *
155 * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt
156 * entries are scaled to it.
157 *
158 * x_ratio = 1.0
159 * y_ratio = y_ppem/ppem (< 1.0)
160 *
161 * We compute the current ratio like:
162 *
163 * - If projVector is horizontal,
164 * ratio = x_ratio = 1.0
165 *
166 * - if projVector is vertical,
167 * ratio = y_ratio
168 *
169 * - else,
170 * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 )
171 *
172 * Reading a cvt value returns
173 * ratio * cvt[index]
174 *
175 * Writing a cvt value in pixels:
176 * cvt[index] / ratio
177 *
178 * The current ppem is simply
179 * ratio * ppem
180 *
181 */
182
183
184 /**************************************************************************
185 *
186 * Metrics used by the TrueType size and context objects.
187 */
188 typedef struct TT_Size_Metrics_
189 {
190 /* for non-square pixels */
191 FT_Long x_ratio;
192 FT_Long y_ratio;
193
194 FT_Long ratio; /* current ratio */
195 FT_Fixed scale;
196 FT_UShort ppem; /* maximum ppem size */
197
198 FT_Bool rotated; /* `is the glyph rotated?'-flag */
199 FT_Bool stretched; /* `is the glyph stretched?'-flag */
200
201 } TT_Size_Metrics;
202
203
204 /**************************************************************************
205 *
206 * TrueType size class.
207 */
208 typedef struct TT_SizeRec_
209 {
210 FT_SizeRec root;
211
212 /* we have our own copy of metrics so that we can modify */
213 /* it without affecting auto-hinting (when used) */
214 FT_Size_Metrics* metrics; /* for the current rendering mode */
215 FT_Size_Metrics hinted_metrics; /* for the hinted rendering mode */
216
217 TT_Size_Metrics ttmetrics;
218
219 FT_Byte* widthp; /* glyph widths from the hdmx table */
220
221 FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
222
223#ifdef TT_USE_BYTECODE_INTERPRETER
224
225 FT_Long point_size; /* for the `MPS' bytecode instruction */
226
227 TT_GraphicsState GS;
228
229 TT_GlyphZoneRec twilight; /* The instance's twilight zone */
230
231 TT_ExecContext context;
232
233 /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
234 /* otherwise it is the returned error code */
235 FT_Error bytecode_ready;
236 FT_Error cvt_ready;
237
238#endif /* TT_USE_BYTECODE_INTERPRETER */
239
240 } TT_SizeRec;
241
242
243 /**************************************************************************
244 *
245 * TrueType driver class.
246 */
247 typedef struct TT_DriverRec_
248 {
249 FT_DriverRec root;
250
251 TT_GlyphZoneRec zone; /* glyph loader points zone */
252
253 FT_UInt interpreter_version;
254
255 } TT_DriverRec;
256
257
258 /* Note: All of the functions below (except tt_size_reset()) are used */
259 /* as function pointers in a FT_Driver_ClassRec. Therefore their */
260 /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
261 /* TT_Size, etc., so that the compiler can confirm that the types and */
262 /* number of parameters are correct. In all cases the FT_xxx types are */
263 /* cast to their TT_xxx counterparts inside the functions since FreeType */
264 /* will always use the TT driver to create them. */
265
266
267 /**************************************************************************
268 *
269 * Face functions
270 */
271 FT_LOCAL( FT_Error )
272 tt_face_init( FT_Stream stream,
273 FT_Face ttface, /* TT_Face */
274 FT_Int face_index,
275 FT_Int num_params,
276 FT_Parameter* params );
277
278 FT_LOCAL( void )
279 tt_face_done( FT_Face ttface ); /* TT_Face */
280
281
282 /**************************************************************************
283 *
284 * Size functions
285 */
286 FT_LOCAL( FT_Error )
287 tt_size_init( FT_Size ttsize ); /* TT_Size */
288
289 FT_LOCAL( void )
290 tt_size_done( FT_Size ttsize ); /* TT_Size */
291
292#ifdef TT_USE_BYTECODE_INTERPRETER
293
294 FT_LOCAL( FT_Error )
295 tt_size_run_fpgm( TT_Size size );
296
297 FT_LOCAL( FT_Error )
298 tt_size_run_prep( TT_Size size );
299
300 FT_LOCAL( FT_Error )
301 tt_size_init_bytecode( TT_Size size,
302 FT_Bool pedantic );
303
304#endif /* TT_USE_BYTECODE_INTERPRETER */
305
306 FT_LOCAL( void )
307 tt_size_reset_height( FT_Size size );
308
309 FT_LOCAL( FT_Error )
310 tt_size_reset( TT_Size size );
311
312
313 /**************************************************************************
314 *
315 * Driver functions
316 */
317 FT_LOCAL( FT_Error )
318 tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
319
320 FT_LOCAL( void )
321 tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
322
323
324 /**************************************************************************
325 *
326 * Slot functions
327 */
328 FT_LOCAL( FT_Error )
329 tt_slot_init( FT_GlyphSlot slot );
330
331
332 /* auxiliary */
333#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
334
335
336FT_END_HEADER
337
338#endif /* TTOBJS_H_ */
339
340
341/* END */