1 /***************************************************************************/
5 /* Objects manager (specification). */
7 /* Copyright 1996-2018 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 glyph slot object. */
51 /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
52 /* specific about the TrueType glyph slot. */
54 typedef FT_GlyphSlot TT_GlyphSlot
;
57 /*************************************************************************/
60 /* TT_GraphicsState */
63 /* The TrueType graphics state used during bytecode interpretation. */
65 typedef struct TT_GraphicsState_
71 FT_UnitVector dualVector
;
72 FT_UnitVector projVector
;
73 FT_UnitVector freeVector
;
76 FT_F26Dot6 minimum_distance
;
80 FT_F26Dot6 control_value_cutin
;
81 FT_F26Dot6 single_width_cutin
;
82 FT_F26Dot6 single_width_value
;
84 FT_UShort delta_shift
;
86 FT_Byte instruct_control
;
87 /* According to Greg Hitchcock from Microsoft, the `scan_control' */
88 /* variable as documented in the TrueType specification is a 32-bit */
89 /* integer; the high-word part holds the SCANTYPE value, the low-word */
90 /* part the SCANCTRL value. We separate it into two fields. */
101 #ifdef TT_USE_BYTECODE_INTERPRETER
104 tt_glyphzone_done( TT_GlyphZone zone
);
107 tt_glyphzone_new( FT_Memory memory
,
109 FT_Short maxContours
,
112 #endif /* TT_USE_BYTECODE_INTERPRETER */
116 /*************************************************************************/
118 /* EXECUTION SUBTABLES */
120 /* These sub-tables relate to instruction execution. */
122 /*************************************************************************/
125 #define TT_MAX_CODE_RANGES 3
128 /*************************************************************************/
130 /* There can only be 3 active code ranges at once: */
131 /* - the Font Program */
132 /* - the CVT Program */
133 /* - a glyph's instructions set */
135 typedef enum TT_CodeRange_Tag_
137 tt_coderange_none
= 0,
145 typedef struct TT_CodeRange_
152 typedef TT_CodeRange TT_CodeRangeTable
[TT_MAX_CODE_RANGES
];
155 /*************************************************************************/
157 /* Defines a function/instruction definition record. */
159 typedef struct TT_DefRecord_
161 FT_Int range
; /* in which code range is it located? */
162 FT_Long start
; /* where does it start? */
163 FT_Long end
; /* where does it end? */
164 FT_UInt opc
; /* function #, or instruction code */
165 FT_Bool active
; /* is it active? */
166 FT_Bool inline_delta
; /* is function that defines inline delta? */
167 FT_ULong sph_fdef_flags
; /* flags to identify special functions */
169 } TT_DefRecord
, *TT_DefArray
;
172 /*************************************************************************/
174 /* Subglyph transformation record. */
176 typedef struct TT_Transform_
178 FT_Fixed xx
, xy
; /* transformation matrix coefficients */
180 FT_F26Dot6 ox
, oy
; /* offsets */
185 /*************************************************************************/
187 /* A note regarding non-squared pixels: */
189 /* (This text will probably go into some docs at some time; for now, it */
190 /* is kept here to explain some definitions in the TT_Size_Metrics */
193 /* The CVT is a one-dimensional array containing values that control */
194 /* certain important characteristics in a font, like the height of all */
195 /* capitals, all lowercase letter, default spacing or stem width/height. */
197 /* These values are found in FUnits in the font file, and must be scaled */
198 /* to pixel coordinates before being used by the CVT and glyph programs. */
199 /* Unfortunately, when using distinct x and y resolutions (or distinct x */
200 /* and y pointsizes), there are two possible scalings. */
202 /* A first try was to implement a `lazy' scheme where all values were */
203 /* scaled when first used. However, while some values are always used */
204 /* in the same direction, some others are used under many different */
205 /* circumstances and orientations. */
207 /* I have found a simpler way to do the same, and it even seems to work */
208 /* in most of the cases: */
210 /* - All CVT values are scaled to the maximum ppem size. */
212 /* - When performing a read or write in the CVT, a ratio factor is used */
213 /* to perform adequate scaling. Example: */
218 /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
219 /* entries are scaled to it. */
222 /* y_ratio = y_ppem/ppem (< 1.0) */
224 /* We compute the current ratio like: */
226 /* - If projVector is horizontal, */
227 /* ratio = x_ratio = 1.0 */
229 /* - if projVector is vertical, */
230 /* ratio = y_ratio */
233 /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
235 /* Reading a cvt value returns */
236 /* ratio * cvt[index] */
238 /* Writing a cvt value in pixels: */
239 /* cvt[index] / ratio */
241 /* The current ppem is simply */
244 /*************************************************************************/
247 /*************************************************************************/
249 /* Metrics used by the TrueType size and context objects. */
251 typedef struct TT_Size_Metrics_
253 /* for non-square pixels */
257 FT_UShort ppem
; /* maximum ppem size */
258 FT_Long ratio
; /* current ratio */
261 FT_F26Dot6 compensations
[4]; /* device-specific compensations */
265 FT_Bool rotated
; /* `is the glyph rotated?'-flag */
266 FT_Bool stretched
; /* `is the glyph stretched?'-flag */
271 /*************************************************************************/
273 /* TrueType size class. */
275 typedef struct TT_SizeRec_
279 /* we have our own copy of metrics so that we can modify */
280 /* it without affecting auto-hinting (when used) */
281 FT_Size_Metrics
* metrics
; /* for the current rendering mode */
282 FT_Size_Metrics hinted_metrics
; /* for the hinted rendering mode */
284 TT_Size_Metrics ttmetrics
;
286 FT_ULong strike_index
; /* 0xFFFFFFFF to indicate invalid */
288 #ifdef TT_USE_BYTECODE_INTERPRETER
290 FT_Long point_size
; /* for the `MPS' bytecode instruction */
292 FT_UInt num_function_defs
; /* number of function definitions */
293 FT_UInt max_function_defs
;
294 TT_DefArray function_defs
; /* table of function definitions */
296 FT_UInt num_instruction_defs
; /* number of ins. definitions */
297 FT_UInt max_instruction_defs
;
298 TT_DefArray instruction_defs
; /* table of ins. definitions */
303 TT_CodeRangeTable codeRangeTable
;
307 FT_ULong cvt_size
; /* the scaled control value table */
310 FT_UShort storage_size
; /* The storage area is now part of */
311 FT_Long
* storage
; /* the instance */
313 TT_GlyphZoneRec twilight
; /* The instance's twilight zone */
315 TT_ExecContext context
;
317 /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
318 /* otherwise it is the returned error code */
319 FT_Error bytecode_ready
;
322 #endif /* TT_USE_BYTECODE_INTERPRETER */
327 /*************************************************************************/
329 /* TrueType driver class. */
331 typedef struct TT_DriverRec_
335 TT_GlyphZoneRec zone
; /* glyph loader points zone */
337 FT_UInt interpreter_version
;
342 /* Note: All of the functions below (except tt_size_reset()) are used */
343 /* as function pointers in a FT_Driver_ClassRec. Therefore their */
344 /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
345 /* TT_Size, etc., so that the compiler can confirm that the types and */
346 /* number of parameters are correct. In all cases the FT_xxx types are */
347 /* cast to their TT_xxx counterparts inside the functions since FreeType */
348 /* will always use the TT driver to create them. */
351 /*************************************************************************/
356 tt_face_init( FT_Stream stream
,
357 FT_Face ttface
, /* TT_Face */
360 FT_Parameter
* params
);
363 tt_face_done( FT_Face ttface
); /* TT_Face */
366 /*************************************************************************/
371 tt_size_init( FT_Size ttsize
); /* TT_Size */
374 tt_size_done( FT_Size ttsize
); /* TT_Size */
376 #ifdef TT_USE_BYTECODE_INTERPRETER
379 tt_size_run_fpgm( TT_Size size
,
383 tt_size_run_prep( TT_Size size
,
387 tt_size_ready_bytecode( TT_Size size
,
390 #endif /* TT_USE_BYTECODE_INTERPRETER */
393 tt_size_reset( TT_Size size
,
394 FT_Bool only_height
);
397 /*************************************************************************/
399 /* Driver functions */
402 tt_driver_init( FT_Module ttdriver
); /* TT_Driver */
405 tt_driver_done( FT_Module ttdriver
); /* TT_Driver */
408 /*************************************************************************/
413 tt_slot_init( FT_GlyphSlot slot
);
417 #define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
422 #endif /* TTOBJS_H_ */