1 /***************************************************************************/
5 /* Objects manager (specification). */
7 /* Copyright 1996-2000 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 /***************************************************************************/
23 #include <freetype/internal/ftobjs.h>
24 #include <freetype/internal/tttypes.h>
25 #include <freetype/internal/tterrors.h>
33 /*************************************************************************/
39 /* A handle to a TrueType driver object. */
41 typedef struct TT_DriverRec_
* TT_Driver
;
44 /*************************************************************************/
50 /* A handle to a TrueType size object. */
52 typedef struct TT_SizeRec_
* TT_Size
;
55 /*************************************************************************/
61 /* A handle to a TrueType glyph slot object. */
64 /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
65 /* specific about the TrueType glyph slot. */
67 typedef FT_GlyphSlot TT_GlyphSlot
;
70 /*************************************************************************/
73 /* TT_GraphicsState */
76 /* The TrueType graphics state used during bytecode interpretation. */
78 typedef struct TT_GraphicsState_
84 FT_UnitVector dualVector
;
85 FT_UnitVector projVector
;
86 FT_UnitVector freeVector
;
89 FT_F26Dot6 minimum_distance
;
93 FT_F26Dot6 control_value_cutin
;
94 FT_F26Dot6 single_width_cutin
;
95 FT_F26Dot6 single_width_value
;
99 FT_Byte instruct_control
;
100 FT_Bool scan_control
;
110 LOCAL_DEF
void TT_Done_GlyphZone( TT_GlyphZone
* zone
);
112 LOCAL_DEF FT_Error
TT_New_GlyphZone( FT_Memory memory
,
114 FT_Short maxContours
,
115 TT_GlyphZone
* zone
);
118 /*************************************************************************/
120 /* EXECUTION SUBTABLES */
122 /* These sub-tables relate to instruction execution. */
124 /*************************************************************************/
127 #define TT_MAX_CODE_RANGES 3
130 /*************************************************************************/
132 /* There can only be 3 active code ranges at once: */
133 /* - the Font Program */
134 /* - the CVT Program */
135 /* - a glyph's instructions set */
137 typedef enum TT_CodeRange_Tag_
139 tt_coderange_none
= 0,
147 typedef struct TT_CodeRange_
154 typedef TT_CodeRange TT_CodeRangeTable
[TT_MAX_CODE_RANGES
];
157 /*************************************************************************/
159 /* Defines a function/instruction definition record. */
161 typedef struct TT_DefRecord_
163 FT_Int range
; /* in which code range is it located? */
164 FT_Long start
; /* where does it start? */
165 FT_UInt opc
; /* function #, or instruction code */
166 FT_Bool active
; /* is it active? */
168 } TT_DefRecord
, *TT_DefArray
;
171 /*************************************************************************/
173 /* Subglyph transformation record. */
175 typedef struct TT_Transform_
177 FT_Fixed xx
, xy
; /* transformation matrix coefficients */
179 FT_F26Dot6 ox
, oy
; /* offsets */
184 /*************************************************************************/
186 /* Subglyph loading record. Used to load composite components. */
188 typedef struct TT_SubglyphRec_
190 FT_Long index
; /* subglyph index; initialized with -1 */
191 FT_Bool is_scaled
; /* is the subglyph scaled? */
192 FT_Bool is_hinted
; /* should it be hinted? */
193 FT_Bool preserve_pps
; /* preserve phantom points? */
203 FT_Long arg1
; /* first argument */
204 FT_Long arg2
; /* second argument */
206 FT_UShort element_flag
; /* current load element flag */
208 TT_Transform transform
; /* transformation matrix */
210 FT_Vector pp1
, pp2
; /* phantom points */
212 } TT_SubGlyphRec
, *TT_SubGlyph_Stack
;
215 /*************************************************************************/
217 /* A note regarding non-squared pixels: */
219 /* (This text will probably go into some docs at some time; for now, it */
220 /* is kept here to explain some definitions in the TIns_Metrics */
223 /* The CVT is a one-dimensional array containing values that control */
224 /* certain important characteristics in a font, like the height of all */
225 /* capitals, all lowercase letter, default spacing or stem width/height. */
227 /* These values are found in FUnits in the font file, and must be scaled */
228 /* to pixel coordinates before being used by the CVT and glyph programs. */
229 /* Unfortunately, when using distinct x and y resolutions (or distinct x */
230 /* and y pointsizes), there are two possible scalings. */
232 /* A first try was to implement a `lazy' scheme where all values were */
233 /* scaled when first used. However, while some values are always used */
234 /* in the same direction, some others are used under many different */
235 /* circumstances and orientations. */
237 /* I have found a simpler way to do the same, and it even seems to work */
238 /* in most of the cases: */
240 /* - All CVT values are scaled to the maximum ppem size. */
242 /* - When performing a read or write in the CVT, a ratio factor is used */
243 /* to perform adequate scaling. Example: */
248 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
249 /* entries are scaled to it. */
252 /* y_ratio = y_ppem/ppem (< 1.0) */
254 /* We compute the current ratio like: */
256 /* - If projVector is horizontal, */
257 /* ratio = x_ratio = 1.0 */
259 /* - if projVector is vertical, */
260 /* ratio = y_ratio */
263 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
265 /* Reading a cvt value returns */
266 /* ratio * cvt[index] */
268 /* Writing a cvt value in pixels: */
269 /* cvt[index] / ratio */
271 /* The current ppem is simply */
274 /*************************************************************************/
277 /*************************************************************************/
279 /* Metrics used by the TrueType size and context objects. */
281 typedef struct TT_Size_Metrics_
283 /* for non-square pixels */
287 FT_UShort ppem
; /* maximum ppem size */
288 FT_Long ratio
; /* current ratio */
291 FT_F26Dot6 compensations
[4]; /* device-specific compensations */
295 FT_Bool rotated
; /* `is the glyph rotated?'-flag */
296 FT_Bool stretched
; /* `is the glyph stretched?'-flag */
301 /*************************************************************************/
303 /* TrueType size class. */
305 typedef struct TT_SizeRec_
309 TT_Size_Metrics ttmetrics
;
311 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
313 FT_UInt num_function_defs
; /* number of function definitions */
314 FT_UInt max_function_defs
;
315 TT_DefArray function_defs
; /* table of function definitions */
317 FT_UInt num_instruction_defs
; /* number of ins. definitions */
318 FT_UInt max_instruction_defs
;
319 TT_DefArray instruction_defs
; /* table of ins. definitions */
324 TT_CodeRangeTable codeRangeTable
;
328 FT_ULong cvt_size
; /* the scaled control value table */
331 FT_UShort storage_size
; /* The storage area is now part of */
332 FT_Long
* storage
; /* the instance */
334 TT_GlyphZone twilight
; /* The instance's twilight zone */
336 /* debugging variables */
338 /* When using the debugger, we must keep the */
339 /* execution context tied to the instance */
340 /* object rather than asking it on demand. */
343 TT_ExecContext context
;
345 #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
350 /*************************************************************************/
352 /* TrueType driver class. */
354 typedef struct TT_DriverRec_
357 TT_ExecContext context
; /* execution context */
358 TT_GlyphZone zone
; /* glyph loader points zone */
360 void* extension_component
;
365 /*************************************************************************/
370 FT_Error
TT_Init_Face( FT_Stream stream
,
374 FT_Parameter
* params
);
377 void TT_Done_Face( TT_Face face
);
380 /*************************************************************************/
385 FT_Error
TT_Init_Size( TT_Size size
);
388 void TT_Done_Size( TT_Size size
);
391 FT_Error
TT_Reset_Size( TT_Size size
);
394 /*************************************************************************/
396 /* Driver functions */
399 FT_Error
TT_Init_Driver( TT_Driver driver
);
402 void TT_Done_Driver( TT_Driver driver
);
409 #endif /* TTOBJS_H */