1 /***************************************************************************/
5 /* Objects manager (specification). */
7 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 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 FT_Bool scan_control
;
112 #ifdef TT_USE_BYTECODE_INTERPRETER
115 tt_glyphzone_done( TT_GlyphZone zone
);
118 tt_glyphzone_new( FT_Memory memory
,
120 FT_Short maxContours
,
123 #endif /* TT_USE_BYTECODE_INTERPRETER */
127 /*************************************************************************/
129 /* EXECUTION SUBTABLES */
131 /* These sub-tables relate to instruction execution. */
133 /*************************************************************************/
136 #define TT_MAX_CODE_RANGES 3
139 /*************************************************************************/
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 */
146 typedef enum TT_CodeRange_Tag_
148 tt_coderange_none
= 0,
156 typedef struct TT_CodeRange_
163 typedef TT_CodeRange TT_CodeRangeTable
[TT_MAX_CODE_RANGES
];
166 /*************************************************************************/
168 /* Defines a function/instruction definition record. */
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 /*************************************************************************/
182 /* Subglyph transformation record. */
184 typedef struct TT_Transform_
186 FT_Fixed xx
, xy
; /* transformation matrix coefficients */
188 FT_F26Dot6 ox
, oy
; /* offsets */
193 /*************************************************************************/
195 /* Subglyph loading record. Used to load composite components. */
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? */
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 /*************************************************************************/
227 /* A note regarding non-squared pixels: */
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 */
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. */
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. */
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. */
247 /* I have found a simpler way to do the same, and it even seems to work */
248 /* in most of the cases: */
250 /* - All CVT values are scaled to the maximum ppem size. */
252 /* - When performing a read or write in the CVT, a ratio factor is used */
253 /* to perform adequate scaling. Example: */
258 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
259 /* entries are scaled to it. */
262 /* y_ratio = y_ppem/ppem (< 1.0) */
264 /* We compute the current ratio like: */
266 /* - If projVector is horizontal, */
267 /* ratio = x_ratio = 1.0 */
269 /* - if projVector is vertical, */
270 /* ratio = y_ratio */
273 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
275 /* Reading a cvt value returns */
276 /* ratio * cvt[index] */
278 /* Writing a cvt value in pixels: */
279 /* cvt[index] / ratio */
281 /* The current ppem is simply */
284 /*************************************************************************/
287 /*************************************************************************/
289 /* Metrics used by the TrueType size and context objects. */
291 typedef struct TT_Size_Metrics_
293 /* for non-square pixels */
297 FT_UShort ppem
; /* maximum ppem size */
298 FT_Long ratio
; /* current ratio */
301 FT_F26Dot6 compensations
[4]; /* device-specific compensations */
305 FT_Bool rotated
; /* `is the glyph rotated?'-flag */
306 FT_Bool stretched
; /* `is the glyph stretched?'-flag */
311 /*************************************************************************/
313 /* TrueType size class. */
315 typedef struct TT_SizeRec_
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 */
340 TT_CodeRangeTable codeRangeTable
;
344 FT_ULong cvt_size
; /* the scaled control value table */
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. */
359 TT_ExecContext context
;
361 FT_Bool bytecode_ready
;
364 #endif /* TT_USE_BYTECODE_INTERPRETER */
369 /*************************************************************************/
371 /* TrueType driver class. */
373 typedef struct TT_DriverRec_
376 TT_ExecContext context
; /* execution context */
377 TT_GlyphZoneRec zone
; /* glyph loader points zone */
379 void* extension_component
;
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 /*************************************************************************/
398 tt_face_init( FT_Stream stream
,
399 FT_Face ttface
, /* TT_Face */
402 FT_Parameter
* params
);
405 tt_face_done( FT_Face ttface
); /* TT_Face */
408 /*************************************************************************/
413 tt_size_init( FT_Size ttsize
); /* TT_Size */
416 tt_size_done( FT_Size ttsize
); /* TT_Size */
418 #ifdef TT_USE_BYTECODE_INTERPRETER
421 tt_size_run_fpgm( TT_Size size
);
424 tt_size_run_prep( TT_Size size
);
427 tt_size_ready_bytecode( TT_Size size
);
429 #endif /* TT_USE_BYTECODE_INTERPRETER */
432 tt_size_reset( TT_Size size
);
435 /*************************************************************************/
437 /* Driver functions */
440 tt_driver_init( FT_Module ttdriver
); /* TT_Driver */
443 tt_driver_done( FT_Module ttdriver
); /* TT_Driver */
446 /*************************************************************************/
451 tt_slot_init( FT_GlyphSlot slot
);
456 #endif /* __TTOBJS_H__ */