Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / freetype2 / src / truetype / ttobjs.h
blob6971013af903c1d4d57499a0a882387ae4f622dc
1 /***************************************************************************/
2 /* */
3 /* ttobjs.h */
4 /* */
5 /* Objects manager (specification). */
6 /* */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 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 /***************************************************************************/
19 #ifndef __TTOBJS_H__
20 #define __TTOBJS_H__
23 #include <ft2build.h>
24 #include FT_INTERNAL_OBJECTS_H
25 #include FT_INTERNAL_TRUETYPE_TYPES_H
28 FT_BEGIN_HEADER
31 /*************************************************************************/
32 /* */
33 /* <Type> */
34 /* TT_Driver */
35 /* */
36 /* <Description> */
37 /* A handle to a TrueType driver object. */
38 /* */
39 typedef struct TT_DriverRec_* TT_Driver;
42 /*************************************************************************/
43 /* */
44 /* <Type> */
45 /* TT_Instance */
46 /* */
47 /* <Description> */
48 /* A handle to a TrueType size object. */
49 /* */
50 typedef struct TT_SizeRec_* TT_Size;
53 /*************************************************************************/
54 /* */
55 /* <Type> */
56 /* TT_GlyphSlot */
57 /* */
58 /* <Description> */
59 /* A handle to a TrueType glyph slot object. */
60 /* */
61 /* <Note> */
62 /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
63 /* specific about the TrueType glyph slot. */
64 /* */
65 typedef FT_GlyphSlot TT_GlyphSlot;
68 /*************************************************************************/
69 /* */
70 /* <Struct> */
71 /* TT_GraphicsState */
72 /* */
73 /* <Description> */
74 /* The TrueType graphics state used during bytecode interpretation. */
75 /* */
76 typedef struct TT_GraphicsState_
78 FT_UShort rp0;
79 FT_UShort rp1;
80 FT_UShort rp2;
82 FT_UnitVector dualVector;
83 FT_UnitVector projVector;
84 FT_UnitVector freeVector;
86 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
87 FT_Bool both_x_axis;
88 #endif
90 FT_Long loop;
91 FT_F26Dot6 minimum_distance;
92 FT_Int round_state;
94 FT_Bool auto_flip;
95 FT_F26Dot6 control_value_cutin;
96 FT_F26Dot6 single_width_cutin;
97 FT_F26Dot6 single_width_value;
98 FT_Short delta_base;
99 FT_Short delta_shift;
101 FT_Byte instruct_control;
102 FT_Bool scan_control;
103 FT_Int scan_type;
105 FT_UShort gep0;
106 FT_UShort gep1;
107 FT_UShort gep2;
109 } TT_GraphicsState;
112 #ifdef TT_USE_BYTECODE_INTERPRETER
114 FT_LOCAL( void )
115 tt_glyphzone_done( TT_GlyphZone zone );
117 FT_LOCAL( FT_Error )
118 tt_glyphzone_new( FT_Memory memory,
119 FT_UShort maxPoints,
120 FT_Short maxContours,
121 TT_GlyphZone zone );
123 #endif /* TT_USE_BYTECODE_INTERPRETER */
127 /*************************************************************************/
128 /* */
129 /* EXECUTION SUBTABLES */
130 /* */
131 /* These sub-tables relate to instruction execution. */
132 /* */
133 /*************************************************************************/
136 #define TT_MAX_CODE_RANGES 3
139 /*************************************************************************/
140 /* */
141 /* There can only be 3 active code ranges at once: */
142 /* - the Font Program */
143 /* - the CVT Program */
144 /* - a glyph's instructions set */
145 /* */
146 typedef enum TT_CodeRange_Tag_
148 tt_coderange_none = 0,
149 tt_coderange_font,
150 tt_coderange_cvt,
151 tt_coderange_glyph
153 } TT_CodeRange_Tag;
156 typedef struct TT_CodeRange_
158 FT_Byte* base;
159 FT_ULong size;
161 } TT_CodeRange;
163 typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
166 /*************************************************************************/
167 /* */
168 /* Defines a function/instruction definition record. */
169 /* */
170 typedef struct TT_DefRecord_
172 FT_Int range; /* in which code range is it located? */
173 FT_Long start; /* where does it start? */
174 FT_UInt opc; /* function #, or instruction code */
175 FT_Bool active; /* is it active? */
177 } TT_DefRecord, *TT_DefArray;
180 /*************************************************************************/
181 /* */
182 /* Subglyph transformation record. */
183 /* */
184 typedef struct TT_Transform_
186 FT_Fixed xx, xy; /* transformation matrix coefficients */
187 FT_Fixed yx, yy;
188 FT_F26Dot6 ox, oy; /* offsets */
190 } TT_Transform;
193 /*************************************************************************/
194 /* */
195 /* Subglyph loading record. Used to load composite components. */
196 /* */
197 typedef struct TT_SubglyphRec_
199 FT_Long index; /* subglyph index; initialized with -1 */
200 FT_Bool is_scaled; /* is the subglyph scaled? */
201 FT_Bool is_hinted; /* should it be hinted? */
202 FT_Bool preserve_pps; /* preserve phantom points? */
204 FT_Long file_offset;
206 FT_BBox bbox;
207 FT_Pos left_bearing;
208 FT_Pos advance;
210 TT_GlyphZoneRec zone;
212 FT_Long arg1; /* first argument */
213 FT_Long arg2; /* second argument */
215 FT_UShort element_flag; /* current load element flag */
217 TT_Transform transform; /* transformation matrix */
219 FT_Vector pp1, pp2; /* phantom points (horizontal) */
220 FT_Vector pp3, pp4; /* phantom points (vertical) */
222 } TT_SubGlyphRec, *TT_SubGlyph_Stack;
225 /*************************************************************************/
226 /* */
227 /* A note regarding non-squared pixels: */
228 /* */
229 /* (This text will probably go into some docs at some time; for now, it */
230 /* is kept here to explain some definitions in the TIns_Metrics */
231 /* record). */
232 /* */
233 /* The CVT is a one-dimensional array containing values that control */
234 /* certain important characteristics in a font, like the height of all */
235 /* capitals, all lowercase letter, default spacing or stem width/height. */
236 /* */
237 /* These values are found in FUnits in the font file, and must be scaled */
238 /* to pixel coordinates before being used by the CVT and glyph programs. */
239 /* Unfortunately, when using distinct x and y resolutions (or distinct x */
240 /* and y pointsizes), there are two possible scalings. */
241 /* */
242 /* A first try was to implement a `lazy' scheme where all values were */
243 /* scaled when first used. However, while some values are always used */
244 /* in the same direction, some others are used under many different */
245 /* circumstances and orientations. */
246 /* */
247 /* I have found a simpler way to do the same, and it even seems to work */
248 /* in most of the cases: */
249 /* */
250 /* - All CVT values are scaled to the maximum ppem size. */
251 /* */
252 /* - When performing a read or write in the CVT, a ratio factor is used */
253 /* to perform adequate scaling. Example: */
254 /* */
255 /* x_ppem = 14 */
256 /* y_ppem = 10 */
257 /* */
258 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
259 /* entries are scaled to it. */
260 /* */
261 /* x_ratio = 1.0 */
262 /* y_ratio = y_ppem/ppem (< 1.0) */
263 /* */
264 /* We compute the current ratio like: */
265 /* */
266 /* - If projVector is horizontal, */
267 /* ratio = x_ratio = 1.0 */
268 /* */
269 /* - if projVector is vertical, */
270 /* ratio = y_ratio */
271 /* */
272 /* - else, */
273 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
274 /* */
275 /* Reading a cvt value returns */
276 /* ratio * cvt[index] */
277 /* */
278 /* Writing a cvt value in pixels: */
279 /* cvt[index] / ratio */
280 /* */
281 /* The current ppem is simply */
282 /* ratio * ppem */
283 /* */
284 /*************************************************************************/
287 /*************************************************************************/
288 /* */
289 /* Metrics used by the TrueType size and context objects. */
290 /* */
291 typedef struct TT_Size_Metrics_
293 /* for non-square pixels */
294 FT_Long x_ratio;
295 FT_Long y_ratio;
297 FT_UShort ppem; /* maximum ppem size */
298 FT_Long ratio; /* current ratio */
299 FT_Fixed scale;
301 FT_F26Dot6 compensations[4]; /* device-specific compensations */
303 FT_Bool valid;
305 FT_Bool rotated; /* `is the glyph rotated?'-flag */
306 FT_Bool stretched; /* `is the glyph stretched?'-flag */
308 } TT_Size_Metrics;
311 /*************************************************************************/
312 /* */
313 /* TrueType size class. */
314 /* */
315 typedef struct TT_SizeRec_
317 FT_SizeRec root;
319 /* we have our own copy of metrics so that we can modify */
320 /* it without affecting auto-hinting (when used) */
321 FT_Size_Metrics metrics;
323 TT_Size_Metrics ttmetrics;
325 FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
327 #ifdef TT_USE_BYTECODE_INTERPRETER
329 FT_UInt num_function_defs; /* number of function definitions */
330 FT_UInt max_function_defs;
331 TT_DefArray function_defs; /* table of function definitions */
333 FT_UInt num_instruction_defs; /* number of ins. definitions */
334 FT_UInt max_instruction_defs;
335 TT_DefArray instruction_defs; /* table of ins. definitions */
337 FT_UInt max_func;
338 FT_UInt max_ins;
340 TT_CodeRangeTable codeRangeTable;
342 TT_GraphicsState GS;
344 FT_ULong cvt_size; /* the scaled control value table */
345 FT_Long* cvt;
347 FT_UShort storage_size; /* The storage area is now part of */
348 FT_Long* storage; /* the instance */
350 TT_GlyphZoneRec twilight; /* The instance's twilight zone */
352 /* debugging variables */
354 /* When using the debugger, we must keep the */
355 /* execution context tied to the instance */
356 /* object rather than asking it on demand. */
358 FT_Bool debug;
359 TT_ExecContext context;
361 FT_Bool bytecode_ready;
362 FT_Bool cvt_ready;
364 #endif /* TT_USE_BYTECODE_INTERPRETER */
366 } TT_SizeRec;
369 /*************************************************************************/
370 /* */
371 /* TrueType driver class. */
372 /* */
373 typedef struct TT_DriverRec_
375 FT_DriverRec root;
376 TT_ExecContext context; /* execution context */
377 TT_GlyphZoneRec zone; /* glyph loader points zone */
379 void* extension_component;
381 } TT_DriverRec;
384 /* Note: All of the functions below (except tt_size_reset()) are used */
385 /* as function pointers in a FT_Driver_ClassRec. Therefore their */
386 /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
387 /* TT_Size, etc., so that the compiler can confirm that the types and */
388 /* number of parameters are correct. In all cases the FT_xxx types are */
389 /* cast to their TT_xxx counterparts inside the functions since FreeType */
390 /* will always use the TT driver to create them. */
393 /*************************************************************************/
394 /* */
395 /* Face functions */
396 /* */
397 FT_LOCAL( FT_Error )
398 tt_face_init( FT_Stream stream,
399 FT_Face ttface, /* TT_Face */
400 FT_Int face_index,
401 FT_Int num_params,
402 FT_Parameter* params );
404 FT_LOCAL( void )
405 tt_face_done( FT_Face ttface ); /* TT_Face */
408 /*************************************************************************/
409 /* */
410 /* Size functions */
411 /* */
412 FT_LOCAL( FT_Error )
413 tt_size_init( FT_Size ttsize ); /* TT_Size */
415 FT_LOCAL( void )
416 tt_size_done( FT_Size ttsize ); /* TT_Size */
418 #ifdef TT_USE_BYTECODE_INTERPRETER
420 FT_LOCAL( FT_Error )
421 tt_size_run_fpgm( TT_Size size );
423 FT_LOCAL( FT_Error )
424 tt_size_run_prep( TT_Size size );
426 FT_LOCAL( FT_Error )
427 tt_size_ready_bytecode( TT_Size size );
429 #endif /* TT_USE_BYTECODE_INTERPRETER */
431 FT_LOCAL( FT_Error )
432 tt_size_reset( TT_Size size );
435 /*************************************************************************/
436 /* */
437 /* Driver functions */
438 /* */
439 FT_LOCAL( FT_Error )
440 tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
442 FT_LOCAL( void )
443 tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
446 /*************************************************************************/
447 /* */
448 /* Slot functions */
449 /* */
450 FT_LOCAL( FT_Error )
451 tt_slot_init( FT_GlyphSlot slot );
454 FT_END_HEADER
456 #endif /* __TTOBJS_H__ */
459 /* END */