1 /***************************************************************************/
5 /* Objects manager (specification). */
7 /* Copyright 1996-2009, 2011-2012 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
24 #include FT_INTERNAL_OBJECTS_H
25 #include FT_INTERNAL_TRUETYPE_TYPES_H
31 /*************************************************************************/
37 /* A handle to a TrueType driver object. */
39 typedef struct TT_DriverRec_* TT_Driver;
42 /*************************************************************************/
48 /* A handle to a TrueType size object. */
50 typedef struct TT_SizeRec_* TT_Size;
53 /*************************************************************************/
59 /* A handle to a TrueType glyph slot object. */
62 /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
63 /* specific about the TrueType glyph slot. */
65 typedef FT_GlyphSlot TT_GlyphSlot;
68 /*************************************************************************/
71 /* TT_GraphicsState */
74 /* The TrueType graphics state used during bytecode interpretation. */
76 typedef struct TT_GraphicsState_
82 FT_UnitVector dualVector;
83 FT_UnitVector projVector;
84 FT_UnitVector freeVector;
86 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
91 FT_F26Dot6 minimum_distance;
95 FT_F26Dot6 control_value_cutin;
96 FT_F26Dot6 single_width_cutin;
97 FT_F26Dot6 single_width_value;
101 FT_Byte instruct_control;
102 /* According to Greg Hitchcock from Microsoft, the `scan_control' */
103 /* variable as documented in the TrueType specification is a 32-bit */
104 /* integer; the high-word part holds the SCANTYPE value, the low-word */
105 /* part the SCANCTRL value. We separate it into two fields. */
106 FT_Bool scan_control;
116 #ifdef TT_USE_BYTECODE_INTERPRETER
119 tt_glyphzone_done( TT_GlyphZone zone );
122 tt_glyphzone_new( FT_Memory memory,
124 FT_Short maxContours,
127 #endif /* TT_USE_BYTECODE_INTERPRETER */
131 /*************************************************************************/
133 /* EXECUTION SUBTABLES */
135 /* These sub-tables relate to instruction execution. */
137 /*************************************************************************/
140 #define TT_MAX_CODE_RANGES 3
143 /*************************************************************************/
145 /* There can only be 3 active code ranges at once: */
146 /* - the Font Program */
147 /* - the CVT Program */
148 /* - a glyph's instructions set */
150 typedef enum TT_CodeRange_Tag_
152 tt_coderange_none = 0,
160 typedef struct TT_CodeRange_
167 typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
170 /*************************************************************************/
172 /* Defines a function/instruction definition record. */
174 typedef struct TT_DefRecord_
176 FT_Int range; /* in which code range is it located? */
177 FT_Long start; /* where does it start? */
178 FT_Long end; /* where does it end? */
179 FT_UInt opc; /* function #, or instruction code */
180 FT_Bool active; /* is it active? */
182 } TT_DefRecord, *TT_DefArray;
185 /*************************************************************************/
187 /* Subglyph transformation record. */
189 typedef struct TT_Transform_
191 FT_Fixed xx, xy; /* transformation matrix coefficients */
193 FT_F26Dot6 ox, oy; /* offsets */
198 /*************************************************************************/
200 /* A note regarding non-squared pixels: */
202 /* (This text will probably go into some docs at some time; for now, it */
203 /* is kept here to explain some definitions in the TT_Size_Metrics */
206 /* The CVT is a one-dimensional array containing values that control */
207 /* certain important characteristics in a font, like the height of all */
208 /* capitals, all lowercase letter, default spacing or stem width/height. */
210 /* These values are found in FUnits in the font file, and must be scaled */
211 /* to pixel coordinates before being used by the CVT and glyph programs. */
212 /* Unfortunately, when using distinct x and y resolutions (or distinct x */
213 /* and y pointsizes), there are two possible scalings. */
215 /* A first try was to implement a `lazy' scheme where all values were */
216 /* scaled when first used. However, while some values are always used */
217 /* in the same direction, some others are used under many different */
218 /* circumstances and orientations. */
220 /* I have found a simpler way to do the same, and it even seems to work */
221 /* in most of the cases: */
223 /* - All CVT values are scaled to the maximum ppem size. */
225 /* - When performing a read or write in the CVT, a ratio factor is used */
226 /* to perform adequate scaling. Example: */
231 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
232 /* entries are scaled to it. */
235 /* y_ratio = y_ppem/ppem (< 1.0) */
237 /* We compute the current ratio like: */
239 /* - If projVector is horizontal, */
240 /* ratio = x_ratio = 1.0 */
242 /* - if projVector is vertical, */
243 /* ratio = y_ratio */
246 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
248 /* Reading a cvt value returns */
249 /* ratio * cvt[index] */
251 /* Writing a cvt value in pixels: */
252 /* cvt[index] / ratio */
254 /* The current ppem is simply */
257 /*************************************************************************/
260 /*************************************************************************/
262 /* Metrics used by the TrueType size and context objects. */
264 typedef struct TT_Size_Metrics_
266 /* for non-square pixels */
270 FT_UShort ppem; /* maximum ppem size */
271 FT_Long ratio; /* current ratio */
274 FT_F26Dot6 compensations[4]; /* device-specific compensations */
278 FT_Bool rotated; /* `is the glyph rotated?'-flag */
279 FT_Bool stretched; /* `is the glyph stretched?'-flag */
284 /*************************************************************************/
286 /* TrueType size class. */
288 typedef struct TT_SizeRec_
292 /* we have our own copy of metrics so that we can modify */
293 /* it without affecting auto-hinting (when used) */
294 FT_Size_Metrics metrics;
296 TT_Size_Metrics ttmetrics;
298 FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
300 #ifdef TT_USE_BYTECODE_INTERPRETER
302 FT_UInt num_function_defs; /* number of function definitions */
303 FT_UInt max_function_defs;
304 TT_DefArray function_defs; /* table of function definitions */
306 FT_UInt num_instruction_defs; /* number of ins. definitions */
307 FT_UInt max_instruction_defs;
308 TT_DefArray instruction_defs; /* table of ins. definitions */
313 TT_CodeRangeTable codeRangeTable;
317 FT_ULong cvt_size; /* the scaled control value table */
320 FT_UShort storage_size; /* The storage area is now part of */
321 FT_Long* storage; /* the instance */
323 TT_GlyphZoneRec twilight; /* The instance's twilight zone */
325 /* debugging variables */
327 /* When using the debugger, we must keep the */
328 /* execution context tied to the instance */
329 /* object rather than asking it on demand. */
332 TT_ExecContext context;
334 FT_Bool bytecode_ready;
337 #endif /* TT_USE_BYTECODE_INTERPRETER */
342 /*************************************************************************/
344 /* TrueType driver class. */
346 typedef struct TT_DriverRec_
349 TT_ExecContext context; /* execution context */
350 TT_GlyphZoneRec zone; /* glyph loader points zone */
352 void* extension_component;
357 /* Note: All of the functions below (except tt_size_reset()) are used */
358 /* as function pointers in a FT_Driver_ClassRec. Therefore their */
359 /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
360 /* TT_Size, etc., so that the compiler can confirm that the types and */
361 /* number of parameters are correct. In all cases the FT_xxx types are */
362 /* cast to their TT_xxx counterparts inside the functions since FreeType */
363 /* will always use the TT driver to create them. */
366 /*************************************************************************/
371 tt_face_init( FT_Stream stream,
372 FT_Face ttface, /* TT_Face */
375 FT_Parameter* params );
378 tt_face_done( FT_Face ttface ); /* TT_Face */
381 /*************************************************************************/
386 tt_size_init( FT_Size ttsize ); /* TT_Size */
389 tt_size_done( FT_Size ttsize ); /* TT_Size */
391 #ifdef TT_USE_BYTECODE_INTERPRETER
394 tt_size_run_fpgm( TT_Size size,
398 tt_size_run_prep( TT_Size size,
402 tt_size_ready_bytecode( TT_Size size,
405 #endif /* TT_USE_BYTECODE_INTERPRETER */
408 tt_size_reset( TT_Size size );
411 /*************************************************************************/
413 /* Driver functions */
416 tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
419 tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
422 /*************************************************************************/
427 tt_slot_init( FT_GlyphSlot slot );
432 #endif /* __TTOBJS_H__ */