1
/***************************************************************************/
5
/* Objects manager (specification). */
7
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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_UInt opc; /* function #, or instruction code */
179
FT_Bool active; /* is it active? */
181
} TT_DefRecord, *TT_DefArray;
184
/*************************************************************************/
186
/* Subglyph transformation record. */
188
typedef struct TT_Transform_
190
FT_Fixed xx, xy; /* transformation matrix coefficients */
192
FT_F26Dot6 ox, oy; /* offsets */
197
/*************************************************************************/
199
/* A note regarding non-squared pixels: */
201
/* (This text will probably go into some docs at some time; for now, it */
202
/* is kept here to explain some definitions in the TT_Size_Metrics */
205
/* The CVT is a one-dimensional array containing values that control */
206
/* certain important characteristics in a font, like the height of all */
207
/* capitals, all lowercase letter, default spacing or stem width/height. */
209
/* These values are found in FUnits in the font file, and must be scaled */
210
/* to pixel coordinates before being used by the CVT and glyph programs. */
211
/* Unfortunately, when using distinct x and y resolutions (or distinct x */
212
/* and y pointsizes), there are two possible scalings. */
214
/* A first try was to implement a `lazy' scheme where all values were */
215
/* scaled when first used. However, while some values are always used */
216
/* in the same direction, some others are used under many different */
217
/* circumstances and orientations. */
219
/* I have found a simpler way to do the same, and it even seems to work */
220
/* in most of the cases: */
222
/* - All CVT values are scaled to the maximum ppem size. */
224
/* - When performing a read or write in the CVT, a ratio factor is used */
225
/* to perform adequate scaling. Example: */
230
/* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
231
/* entries are scaled to it. */
234
/* y_ratio = y_ppem/ppem (< 1.0) */
236
/* We compute the current ratio like: */
238
/* - If projVector is horizontal, */
239
/* ratio = x_ratio = 1.0 */
241
/* - if projVector is vertical, */
242
/* ratio = y_ratio */
245
/* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
247
/* Reading a cvt value returns */
248
/* ratio * cvt[index] */
250
/* Writing a cvt value in pixels: */
251
/* cvt[index] / ratio */
253
/* The current ppem is simply */
256
/*************************************************************************/
259
/*************************************************************************/
261
/* Metrics used by the TrueType size and context objects. */
263
typedef struct TT_Size_Metrics_
265
/* for non-square pixels */
269
FT_UShort ppem; /* maximum ppem size */
270
FT_Long ratio; /* current ratio */
273
FT_F26Dot6 compensations[4]; /* device-specific compensations */
277
FT_Bool rotated; /* `is the glyph rotated?'-flag */
278
FT_Bool stretched; /* `is the glyph stretched?'-flag */
283
/*************************************************************************/
285
/* TrueType size class. */
287
typedef struct TT_SizeRec_
291
/* we have our own copy of metrics so that we can modify */
292
/* it without affecting auto-hinting (when used) */
293
FT_Size_Metrics metrics;
295
TT_Size_Metrics ttmetrics;
297
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
299
#ifdef TT_USE_BYTECODE_INTERPRETER
301
FT_UInt num_function_defs; /* number of function definitions */
302
FT_UInt max_function_defs;
303
TT_DefArray function_defs; /* table of function definitions */
305
FT_UInt num_instruction_defs; /* number of ins. definitions */
306
FT_UInt max_instruction_defs;
307
TT_DefArray instruction_defs; /* table of ins. definitions */
312
TT_CodeRangeTable codeRangeTable;
316
FT_ULong cvt_size; /* the scaled control value table */
319
FT_UShort storage_size; /* The storage area is now part of */
320
FT_Long* storage; /* the instance */
322
TT_GlyphZoneRec twilight; /* The instance's twilight zone */
324
/* debugging variables */
326
/* When using the debugger, we must keep the */
327
/* execution context tied to the instance */
328
/* object rather than asking it on demand. */
331
TT_ExecContext context;
333
FT_Bool bytecode_ready;
336
#endif /* TT_USE_BYTECODE_INTERPRETER */
341
/*************************************************************************/
343
/* TrueType driver class. */
345
typedef struct TT_DriverRec_
348
TT_ExecContext context; /* execution context */
349
TT_GlyphZoneRec zone; /* glyph loader points zone */
351
void* extension_component;
356
/* Note: All of the functions below (except tt_size_reset()) are used */
357
/* as function pointers in a FT_Driver_ClassRec. Therefore their */
358
/* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
359
/* TT_Size, etc., so that the compiler can confirm that the types and */
360
/* number of parameters are correct. In all cases the FT_xxx types are */
361
/* cast to their TT_xxx counterparts inside the functions since FreeType */
362
/* will always use the TT driver to create them. */
365
/*************************************************************************/
370
tt_face_init( FT_Stream stream,
371
FT_Face ttface, /* TT_Face */
374
FT_Parameter* params );
377
tt_face_done( FT_Face ttface ); /* TT_Face */
380
/*************************************************************************/
385
tt_size_init( FT_Size ttsize ); /* TT_Size */
388
tt_size_done( FT_Size ttsize ); /* TT_Size */
390
#ifdef TT_USE_BYTECODE_INTERPRETER
393
tt_size_run_fpgm( TT_Size size );
396
tt_size_run_prep( TT_Size size );
399
tt_size_ready_bytecode( TT_Size size );
401
#endif /* TT_USE_BYTECODE_INTERPRETER */
404
tt_size_reset( TT_Size size );
407
/*************************************************************************/
409
/* Driver functions */
412
tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
415
tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
418
/*************************************************************************/
423
tt_slot_init( FT_GlyphSlot slot );
428
#endif /* __TTOBJS_H__ */