Bug 1690340 - Part 1: Hide all the panel tools in the developer tools menu. r=jdescottes
[gecko.git] / modules / freetype2 / src / truetype / ttobjs.h
blobd986deabc411a1426b5eeb0800532198c951ca70
1 /****************************************************************************
3 * ttobjs.h
5 * Objects manager (specification).
7 * Copyright (C) 1996-2020 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.
19 #ifndef TTOBJS_H_
20 #define TTOBJS_H_
23 #include <freetype/internal/ftobjs.h>
24 #include <freetype/internal/tttypes.h>
27 FT_BEGIN_HEADER
30 /**************************************************************************
32 * @Type:
33 * TT_Driver
35 * @Description:
36 * A handle to a TrueType driver object.
38 typedef struct TT_DriverRec_* TT_Driver;
41 /**************************************************************************
43 * @Type:
44 * TT_GlyphSlot
46 * @Description:
47 * A handle to a TrueType glyph slot object.
49 * @Note:
50 * This is a direct typedef of FT_GlyphSlot, as there is nothing
51 * specific about the TrueType glyph slot.
53 typedef FT_GlyphSlot TT_GlyphSlot;
56 /**************************************************************************
58 * @Struct:
59 * TT_GraphicsState
61 * @Description:
62 * The TrueType graphics state used during bytecode interpretation.
64 typedef struct TT_GraphicsState_
66 FT_UShort rp0;
67 FT_UShort rp1;
68 FT_UShort rp2;
70 FT_UnitVector dualVector;
71 FT_UnitVector projVector;
72 FT_UnitVector freeVector;
74 FT_Long loop;
75 FT_F26Dot6 minimum_distance;
76 FT_Int round_state;
78 FT_Bool auto_flip;
79 FT_F26Dot6 control_value_cutin;
80 FT_F26Dot6 single_width_cutin;
81 FT_F26Dot6 single_width_value;
82 FT_UShort delta_base;
83 FT_UShort delta_shift;
85 FT_Byte instruct_control;
86 /* According to Greg Hitchcock from Microsoft, the `scan_control' */
87 /* variable as documented in the TrueType specification is a 32-bit */
88 /* integer; the high-word part holds the SCANTYPE value, the low-word */
89 /* part the SCANCTRL value. We separate it into two fields. */
90 FT_Bool scan_control;
91 FT_Int scan_type;
93 FT_UShort gep0;
94 FT_UShort gep1;
95 FT_UShort gep2;
97 } TT_GraphicsState;
100 #ifdef TT_USE_BYTECODE_INTERPRETER
102 FT_LOCAL( void )
103 tt_glyphzone_done( TT_GlyphZone zone );
105 FT_LOCAL( FT_Error )
106 tt_glyphzone_new( FT_Memory memory,
107 FT_UShort maxPoints,
108 FT_Short maxContours,
109 TT_GlyphZone zone );
111 #endif /* TT_USE_BYTECODE_INTERPRETER */
115 /**************************************************************************
117 * EXECUTION SUBTABLES
119 * These sub-tables relate to instruction execution.
124 #define TT_MAX_CODE_RANGES 3
127 /**************************************************************************
129 * There can only be 3 active code ranges at once:
130 * - the Font Program
131 * - the CVT Program
132 * - a glyph's instructions set
134 typedef enum TT_CodeRange_Tag_
136 tt_coderange_none = 0,
137 tt_coderange_font,
138 tt_coderange_cvt,
139 tt_coderange_glyph
141 } TT_CodeRange_Tag;
144 typedef struct TT_CodeRange_
146 FT_Byte* base;
147 FT_Long size;
149 } TT_CodeRange;
151 typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
154 /**************************************************************************
156 * Defines a function/instruction definition record.
158 typedef struct TT_DefRecord_
160 FT_Int range; /* in which code range is it located? */
161 FT_Long start; /* where does it start? */
162 FT_Long end; /* where does it end? */
163 FT_UInt opc; /* function #, or instruction code */
164 FT_Bool active; /* is it active? */
165 FT_Bool inline_delta; /* is function that defines inline delta? */
166 FT_ULong sph_fdef_flags; /* flags to identify special functions */
168 } TT_DefRecord, *TT_DefArray;
171 /**************************************************************************
173 * Subglyph transformation record.
175 typedef struct TT_Transform_
177 FT_Fixed xx, xy; /* transformation matrix coefficients */
178 FT_Fixed yx, yy;
179 FT_F26Dot6 ox, oy; /* offsets */
181 } TT_Transform;
184 /**************************************************************************
186 * A note regarding non-squared pixels:
188 * (This text will probably go into some docs at some time; for now, it
189 * is kept here to explain some definitions in the TT_Size_Metrics
190 * record).
192 * The CVT is a one-dimensional array containing values that control
193 * certain important characteristics in a font, like the height of all
194 * capitals, all lowercase letter, default spacing or stem width/height.
196 * These values are found in FUnits in the font file, and must be scaled
197 * to pixel coordinates before being used by the CVT and glyph programs.
198 * Unfortunately, when using distinct x and y resolutions (or distinct x
199 * and y pointsizes), there are two possible scalings.
201 * A first try was to implement a `lazy' scheme where all values were
202 * scaled when first used. However, while some values are always used
203 * in the same direction, some others are used under many different
204 * circumstances and orientations.
206 * I have found a simpler way to do the same, and it even seems to work
207 * in most of the cases:
209 * - All CVT values are scaled to the maximum ppem size.
211 * - When performing a read or write in the CVT, a ratio factor is used
212 * to perform adequate scaling. Example:
214 * x_ppem = 14
215 * y_ppem = 10
217 * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt
218 * entries are scaled to it.
220 * x_ratio = 1.0
221 * y_ratio = y_ppem/ppem (< 1.0)
223 * We compute the current ratio like:
225 * - If projVector is horizontal,
226 * ratio = x_ratio = 1.0
228 * - if projVector is vertical,
229 * ratio = y_ratio
231 * - else,
232 * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 )
234 * Reading a cvt value returns
235 * ratio * cvt[index]
237 * Writing a cvt value in pixels:
238 * cvt[index] / ratio
240 * The current ppem is simply
241 * ratio * ppem
246 /**************************************************************************
248 * Metrics used by the TrueType size and context objects.
250 typedef struct TT_Size_Metrics_
252 /* for non-square pixels */
253 FT_Long x_ratio;
254 FT_Long y_ratio;
256 FT_UShort ppem; /* maximum ppem size */
257 FT_Long ratio; /* current ratio */
258 FT_Fixed scale;
260 FT_F26Dot6 compensations[4]; /* device-specific compensations */
262 FT_Bool valid;
264 FT_Bool rotated; /* `is the glyph rotated?'-flag */
265 FT_Bool stretched; /* `is the glyph stretched?'-flag */
267 } TT_Size_Metrics;
270 /**************************************************************************
272 * TrueType size class.
274 typedef struct TT_SizeRec_
276 FT_SizeRec root;
278 /* we have our own copy of metrics so that we can modify */
279 /* it without affecting auto-hinting (when used) */
280 FT_Size_Metrics* metrics; /* for the current rendering mode */
281 FT_Size_Metrics hinted_metrics; /* for the hinted rendering mode */
283 TT_Size_Metrics ttmetrics;
285 FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
287 #ifdef TT_USE_BYTECODE_INTERPRETER
289 FT_Long point_size; /* for the `MPS' bytecode instruction */
291 FT_UInt num_function_defs; /* number of function definitions */
292 FT_UInt max_function_defs;
293 TT_DefArray function_defs; /* table of function definitions */
295 FT_UInt num_instruction_defs; /* number of ins. definitions */
296 FT_UInt max_instruction_defs;
297 TT_DefArray instruction_defs; /* table of ins. definitions */
299 FT_UInt max_func;
300 FT_UInt max_ins;
302 TT_CodeRangeTable codeRangeTable;
304 TT_GraphicsState GS;
306 FT_ULong cvt_size; /* the scaled control value table */
307 FT_Long* cvt;
309 FT_UShort storage_size; /* The storage area is now part of */
310 FT_Long* storage; /* the instance */
312 TT_GlyphZoneRec twilight; /* The instance's twilight zone */
314 TT_ExecContext context;
316 /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
317 /* otherwise it is the returned error code */
318 FT_Error bytecode_ready;
319 FT_Error cvt_ready;
321 #endif /* TT_USE_BYTECODE_INTERPRETER */
323 } TT_SizeRec;
326 /**************************************************************************
328 * TrueType driver class.
330 typedef struct TT_DriverRec_
332 FT_DriverRec root;
334 TT_GlyphZoneRec zone; /* glyph loader points zone */
336 FT_UInt interpreter_version;
338 } TT_DriverRec;
341 /* Note: All of the functions below (except tt_size_reset()) are used */
342 /* as function pointers in a FT_Driver_ClassRec. Therefore their */
343 /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
344 /* TT_Size, etc., so that the compiler can confirm that the types and */
345 /* number of parameters are correct. In all cases the FT_xxx types are */
346 /* cast to their TT_xxx counterparts inside the functions since FreeType */
347 /* will always use the TT driver to create them. */
350 /**************************************************************************
352 * Face functions
354 FT_LOCAL( FT_Error )
355 tt_face_init( FT_Stream stream,
356 FT_Face ttface, /* TT_Face */
357 FT_Int face_index,
358 FT_Int num_params,
359 FT_Parameter* params );
361 FT_LOCAL( void )
362 tt_face_done( FT_Face ttface ); /* TT_Face */
365 /**************************************************************************
367 * Size functions
369 FT_LOCAL( FT_Error )
370 tt_size_init( FT_Size ttsize ); /* TT_Size */
372 FT_LOCAL( void )
373 tt_size_done( FT_Size ttsize ); /* TT_Size */
375 #ifdef TT_USE_BYTECODE_INTERPRETER
377 FT_LOCAL( FT_Error )
378 tt_size_run_fpgm( TT_Size size,
379 FT_Bool pedantic );
381 FT_LOCAL( FT_Error )
382 tt_size_run_prep( TT_Size size,
383 FT_Bool pedantic );
385 FT_LOCAL( FT_Error )
386 tt_size_ready_bytecode( TT_Size size,
387 FT_Bool pedantic );
389 #endif /* TT_USE_BYTECODE_INTERPRETER */
391 FT_LOCAL( FT_Error )
392 tt_size_reset( TT_Size size,
393 FT_Bool only_height );
396 /**************************************************************************
398 * Driver functions
400 FT_LOCAL( FT_Error )
401 tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
403 FT_LOCAL( void )
404 tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
407 /**************************************************************************
409 * Slot functions
411 FT_LOCAL( FT_Error )
412 tt_slot_init( FT_GlyphSlot slot );
415 /* auxiliary */
416 #define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
419 FT_END_HEADER
421 #endif /* TTOBJS_H_ */
424 /* END */