1 /***************************************************************************/
5 /* Objects manager (specification). */
7 /* Copyright 1996-2001 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;
87 FT_F26Dot6 minimum_distance;
91 FT_F26Dot6 control_value_cutin;
92 FT_F26Dot6 single_width_cutin;
93 FT_F26Dot6 single_width_value;
97 FT_Byte instruct_control;
108 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
111 TT_Done_GlyphZone( TT_GlyphZone* zone );
114 TT_New_GlyphZone( FT_Memory memory,
116 FT_Short maxContours,
117 TT_GlyphZone* zone );
119 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
123 /*************************************************************************/
125 /* EXECUTION SUBTABLES */
127 /* These sub-tables relate to instruction execution. */
129 /*************************************************************************/
132 #define TT_MAX_CODE_RANGES 3
135 /*************************************************************************/
137 /* There can only be 3 active code ranges at once: */
138 /* - the Font Program */
139 /* - the CVT Program */
140 /* - a glyph's instructions set */
142 typedef enum TT_CodeRange_Tag_
144 tt_coderange_none = 0,
152 typedef struct TT_CodeRange_
159 typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
162 /*************************************************************************/
164 /* Defines a function/instruction definition record. */
166 typedef struct TT_DefRecord_
168 FT_Int range; /* in which code range is it located? */
169 FT_Long start; /* where does it start? */
170 FT_UInt opc; /* function #, or instruction code */
171 FT_Bool active; /* is it active? */
173 } TT_DefRecord, *TT_DefArray;
176 /*************************************************************************/
178 /* Subglyph transformation record. */
180 typedef struct TT_Transform_
182 FT_Fixed xx, xy; /* transformation matrix coefficients */
184 FT_F26Dot6 ox, oy; /* offsets */
189 /*************************************************************************/
191 /* Subglyph loading record. Used to load composite components. */
193 typedef struct TT_SubglyphRec_
195 FT_Long index; /* subglyph index; initialized with -1 */
196 FT_Bool is_scaled; /* is the subglyph scaled? */
197 FT_Bool is_hinted; /* should it be hinted? */
198 FT_Bool preserve_pps; /* preserve phantom points? */
208 FT_Long arg1; /* first argument */
209 FT_Long arg2; /* second argument */
211 FT_UShort element_flag; /* current load element flag */
213 TT_Transform transform; /* transformation matrix */
215 FT_Vector pp1, pp2; /* phantom points */
217 } TT_SubGlyphRec, *TT_SubGlyph_Stack;
220 /*************************************************************************/
222 /* A note regarding non-squared pixels: */
224 /* (This text will probably go into some docs at some time; for now, it */
225 /* is kept here to explain some definitions in the TIns_Metrics */
228 /* The CVT is a one-dimensional array containing values that control */
229 /* certain important characteristics in a font, like the height of all */
230 /* capitals, all lowercase letter, default spacing or stem width/height. */
232 /* These values are found in FUnits in the font file, and must be scaled */
233 /* to pixel coordinates before being used by the CVT and glyph programs. */
234 /* Unfortunately, when using distinct x and y resolutions (or distinct x */
235 /* and y pointsizes), there are two possible scalings. */
237 /* A first try was to implement a `lazy' scheme where all values were */
238 /* scaled when first used. However, while some values are always used */
239 /* in the same direction, some others are used under many different */
240 /* circumstances and orientations. */
242 /* I have found a simpler way to do the same, and it even seems to work */
243 /* in most of the cases: */
245 /* - All CVT values are scaled to the maximum ppem size. */
247 /* - When performing a read or write in the CVT, a ratio factor is used */
248 /* to perform adequate scaling. Example: */
253 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
254 /* entries are scaled to it. */
257 /* y_ratio = y_ppem/ppem (< 1.0) */
259 /* We compute the current ratio like: */
261 /* - If projVector is horizontal, */
262 /* ratio = x_ratio = 1.0 */
264 /* - if projVector is vertical, */
265 /* ratio = y_ratio */
268 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
270 /* Reading a cvt value returns */
271 /* ratio * cvt[index] */
273 /* Writing a cvt value in pixels: */
274 /* cvt[index] / ratio */
276 /* The current ppem is simply */
279 /*************************************************************************/
282 /*************************************************************************/
284 /* Metrics used by the TrueType size and context objects. */
286 typedef struct TT_Size_Metrics_
288 /* for non-square pixels */
292 FT_UShort ppem; /* maximum ppem size */
293 FT_Long ratio; /* current ratio */
296 FT_F26Dot6 compensations[4]; /* device-specific compensations */
300 FT_Bool rotated; /* `is the glyph rotated?'-flag */
301 FT_Bool stretched; /* `is the glyph stretched?'-flag */
306 /*************************************************************************/
308 /* TrueType size class. */
310 typedef struct TT_SizeRec_
314 TT_Size_Metrics ttmetrics;
316 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
318 FT_UInt strike_index; /* 0xFFFF to indicate invalid */
319 FT_Size_Metrics strike_metrics; /* current strike's metrics */
323 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
325 FT_UInt num_function_defs; /* number of function definitions */
326 FT_UInt max_function_defs;
327 TT_DefArray function_defs; /* table of function definitions */
329 FT_UInt num_instruction_defs; /* number of ins. definitions */
330 FT_UInt max_instruction_defs;
331 TT_DefArray instruction_defs; /* table of ins. definitions */
336 TT_CodeRangeTable codeRangeTable;
340 FT_ULong cvt_size; /* the scaled control value table */
343 FT_UShort storage_size; /* The storage area is now part of */
344 FT_Long* storage; /* the instance */
346 TT_GlyphZone twilight; /* The instance's twilight zone */
348 /* debugging variables */
350 /* When using the debugger, we must keep the */
351 /* execution context tied to the instance */
352 /* object rather than asking it on demand. */
355 TT_ExecContext context;
357 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
362 /*************************************************************************/
364 /* TrueType driver class. */
366 typedef struct TT_DriverRec_
369 TT_ExecContext context; /* execution context */
370 TT_GlyphZone zone; /* glyph loader points zone */
372 void* extension_component;
377 /*************************************************************************/
382 TT_Init_Face( FT_Stream stream,
386 FT_Parameter* params );
389 TT_Done_Face( TT_Face face );
392 /*************************************************************************/
397 TT_Init_Size( TT_Size size );
400 TT_Done_Size( TT_Size size );
403 TT_Reset_Size( TT_Size size );
406 /*************************************************************************/
408 /* Driver functions */
411 TT_Init_Driver( TT_Driver driver );
414 TT_Done_Driver( TT_Driver driver );
419 #endif /* __TTOBJS_H__ */