w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ttobjs.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * ttobjs.h
4  *
5  * Objects manager (specification).
6  *
7  * Copyright (C) 1996-2020 by
8  * David Turner, Robert Wilhelm, and Werner Lemberg.
9  *
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.
15  *
16  */
17 
18 
19 #ifndef TTOBJS_H_
20 #define TTOBJS_H_
21 
22 
23 #include <freetype/internal/ftobjs.h>
24 #include <freetype/internal/tttypes.h>
25 
26 
28 
29 
30  /**************************************************************************
31  *
32  * @Type:
33  * TT_Driver
34  *
35  * @Description:
36  * A handle to a TrueType driver object.
37  */
38  typedef struct TT_DriverRec_* TT_Driver;
39 
40 
41  /**************************************************************************
42  *
43  * @Type:
44  * TT_GlyphSlot
45  *
46  * @Description:
47  * A handle to a TrueType glyph slot object.
48  *
49  * @Note:
50  * This is a direct typedef of FT_GlyphSlot, as there is nothing
51  * specific about the TrueType glyph slot.
52  */
54 
55 
56  /**************************************************************************
57  *
58  * @Struct:
59  * TT_GraphicsState
60  *
61  * @Description:
62  * The TrueType graphics state used during bytecode interpretation.
63  */
64  typedef struct TT_GraphicsState_
65  {
69 
73 
77 
84 
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. */
92 
96 
98 
99 
100 #ifdef TT_USE_BYTECODE_INTERPRETER
101 
102  FT_LOCAL( void )
103  tt_glyphzone_done( TT_GlyphZone zone );
104 
105  FT_LOCAL( FT_Error )
106  tt_glyphzone_new( FT_Memory memory,
108  FT_Short maxContours,
109  TT_GlyphZone zone );
110 
111 #endif /* TT_USE_BYTECODE_INTERPRETER */
112 
113 
114 
115  /**************************************************************************
116  *
117  * EXECUTION SUBTABLES
118  *
119  * These sub-tables relate to instruction execution.
120  *
121  */
122 
123 
124 #define TT_MAX_CODE_RANGES 3
125 
126 
127  /**************************************************************************
128  *
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
133  */
134  typedef enum TT_CodeRange_Tag_
135  {
140 
142 
143 
144  typedef struct TT_CodeRange_
145  {
148 
150 
152 
153 
154  /**************************************************************************
155  *
156  * Defines a function/instruction definition record.
157  */
158  typedef struct TT_DefRecord_
159  {
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 */
167 
169 
170 
171  /**************************************************************************
172  *
173  * Subglyph transformation record.
174  */
175  typedef struct TT_Transform_
176  {
177  FT_Fixed xx, xy; /* transformation matrix coefficients */
179  FT_F26Dot6 ox, oy; /* offsets */
180 
182 
183 
184  /**************************************************************************
185  *
186  * A note regarding non-squared pixels:
187  *
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).
191  *
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.
195  *
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.
200  *
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.
205  *
206  * I have found a simpler way to do the same, and it even seems to work
207  * in most of the cases:
208  *
209  * - All CVT values are scaled to the maximum ppem size.
210  *
211  * - When performing a read or write in the CVT, a ratio factor is used
212  * to perform adequate scaling. Example:
213  *
214  * x_ppem = 14
215  * y_ppem = 10
216  *
217  * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt
218  * entries are scaled to it.
219  *
220  * x_ratio = 1.0
221  * y_ratio = y_ppem/ppem (< 1.0)
222  *
223  * We compute the current ratio like:
224  *
225  * - If projVector is horizontal,
226  * ratio = x_ratio = 1.0
227  *
228  * - if projVector is vertical,
229  * ratio = y_ratio
230  *
231  * - else,
232  * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 )
233  *
234  * Reading a cvt value returns
235  * ratio * cvt[index]
236  *
237  * Writing a cvt value in pixels:
238  * cvt[index] / ratio
239  *
240  * The current ppem is simply
241  * ratio * ppem
242  *
243  */
244 
245 
246  /**************************************************************************
247  *
248  * Metrics used by the TrueType size and context objects.
249  */
250  typedef struct TT_Size_Metrics_
251  {
252  /* for non-square pixels */
255 
256  FT_UShort ppem; /* maximum ppem size */
257  FT_Long ratio; /* current ratio */
259 
260  FT_F26Dot6 compensations[4]; /* device-specific compensations */
261 
263 
264  FT_Bool rotated; /* `is the glyph rotated?'-flag */
265  FT_Bool stretched; /* `is the glyph stretched?'-flag */
266 
268 
269 
270  /**************************************************************************
271  *
272  * TrueType size class.
273  */
274  typedef struct TT_SizeRec_
275  {
277 
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 */
282 
284 
285  FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
286 
287 #ifdef TT_USE_BYTECODE_INTERPRETER
288 
289  FT_Long point_size; /* for the `MPS' bytecode instruction */
290 
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 */
294 
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 */
298 
299  FT_UInt max_func;
300  FT_UInt max_ins;
301 
302  TT_CodeRangeTable codeRangeTable;
303 
305 
306  FT_ULong cvt_size; /* the scaled control value table */
307  FT_Long* cvt;
308 
309  FT_UShort storage_size; /* The storage area is now part of */
310  FT_Long* storage; /* the instance */
311 
312  TT_GlyphZoneRec twilight; /* The instance's twilight zone */
313 
315 
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;
320 
321 #endif /* TT_USE_BYTECODE_INTERPRETER */
322 
324 
325 
326  /**************************************************************************
327  *
328  * TrueType driver class.
329  */
330  typedef struct TT_DriverRec_
331  {
333 
334  TT_GlyphZoneRec zone; /* glyph loader points zone */
335 
337 
339 
340 
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. */
348 
349 
350  /**************************************************************************
351  *
352  * Face functions
353  */
354  FT_LOCAL( FT_Error )
356  FT_Face ttface, /* TT_Face */
357  FT_Int face_index,
358  FT_Int num_params,
359  FT_Parameter* params );
360 
361  FT_LOCAL( void )
362  tt_face_done( FT_Face ttface ); /* TT_Face */
363 
364 
365  /**************************************************************************
366  *
367  * Size functions
368  */
369  FT_LOCAL( FT_Error )
370  tt_size_init( FT_Size ttsize ); /* TT_Size */
371 
372  FT_LOCAL( void )
373  tt_size_done( FT_Size ttsize ); /* TT_Size */
374 
375 #ifdef TT_USE_BYTECODE_INTERPRETER
376 
377  FT_LOCAL( FT_Error )
378  tt_size_run_fpgm( TT_Size size,
379  FT_Bool pedantic );
380 
381  FT_LOCAL( FT_Error )
382  tt_size_run_prep( TT_Size size,
383  FT_Bool pedantic );
384 
385  FT_LOCAL( FT_Error )
386  tt_size_ready_bytecode( TT_Size size,
387  FT_Bool pedantic );
388 
389 #endif /* TT_USE_BYTECODE_INTERPRETER */
390 
391  FT_LOCAL( FT_Error )
393  FT_Bool only_height );
394 
395 
396  /**************************************************************************
397  *
398  * Driver functions
399  */
400  FT_LOCAL( FT_Error )
401  tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
402 
403  FT_LOCAL( void )
404  tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
405 
406 
407  /**************************************************************************
408  *
409  * Slot functions
410  */
411  FT_LOCAL( FT_Error )
413 
414 
415  /* auxiliary */
416 #define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
417 
418 
420 
421 #endif /* TTOBJS_H_ */
422 
423 
424 /* END */
char pedantic
Definition: afm2tfm.c:233
static uint32_t cvt(uint32_t val)
int params
Definition: definitions.c:42
const unsigned int maxPoints
Definition: drvbase.h:80
#define GS
Definition: in_ps.cpp:25
#define FT_END_HEADER
Definition: ftheader.h:57
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
signed long FT_F26Dot6
Definition: fttypes.h:275
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
signed long FT_Long
Definition: fttypes.h:242
unsigned short FT_UShort
Definition: fttypes.h:209
signed short FT_Short
Definition: fttypes.h:198
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
#define FT_LOCAL(x)
struct TT_CodeRange_ TT_CodeRange
tt_face_init(FT_Stream stream, FT_Face ttface, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
Definition: ttobjs.c:605
tt_size_init(FT_Size ttsize)
Definition: ttobjs.c:1239
tt_size_done(FT_Size ttsize)
Definition: ttobjs.c:1270
struct TT_SizeRec_ TT_SizeRec
struct TT_Transform_ TT_Transform
struct TT_DefRecord_ * TT_DefArray
tt_slot_init(FT_GlyphSlot slot)
Definition: ttobjs.c:1470
tt_size_reset(TT_Size size, FT_Bool only_height)
Definition: ttobjs.c:1302
struct TT_DriverRec_ TT_DriverRec
tt_driver_init(FT_Module ttdriver)
Definition: ttobjs.c:1410
struct TT_DefRecord_ TT_DefRecord
enum TT_CodeRange_Tag_ TT_CodeRange_Tag
typedefFT_BEGIN_HEADER struct TT_DriverRec_ * TT_Driver
Definition: ttobjs.h:38
TT_CodeRange TT_CodeRangeTable[3]
Definition: ttobjs.h:151
tt_face_done(FT_Face ttface)
Definition: ttobjs.c:768
tt_driver_done(FT_Module ttdriver)
Definition: ttobjs.c:1448
FT_GlyphSlot TT_GlyphSlot
Definition: ttobjs.h:53
#define TT_MAX_CODE_RANGES
Definition: ttobjs.h:124
struct TT_Size_Metrics_ TT_Size_Metrics
TT_CodeRange_Tag_
Definition: ttobjs.h:135
@ tt_coderange_none
Definition: ttobjs.h:136
@ tt_coderange_font
Definition: ttobjs.h:137
@ tt_coderange_cvt
Definition: ttobjs.h:138
@ tt_coderange_glyph
Definition: ttobjs.h:139
struct TT_GraphicsState_ TT_GraphicsState
static char storage
Definition: pnmtosgi.c:48
static int size
Definition: ppmlabel.c:24
struct stream_s stream
Definition: pts_fax.h:93
slotref slot
Definition: opcodes.h:237
FT_Byte * base
Definition: ttobjs.h:146
FT_Long size
Definition: ttobjs.h:147
FT_ULong sph_fdef_flags
Definition: ttobjs.h:166
FT_Long start
Definition: ttobjs.h:161
FT_UInt opc
Definition: ttobjs.h:163
FT_Long end
Definition: ttobjs.h:162
FT_Bool active
Definition: ttobjs.h:164
FT_Int range
Definition: ttobjs.h:160
FT_Bool inline_delta
Definition: ttobjs.h:165
TT_GlyphZoneRec zone
Definition: ttobjs.h:334
FT_DriverRec root
Definition: ttobjs.h:332
FT_UInt interpreter_version
Definition: ttobjs.h:336
FT_F26Dot6 single_width_value
Definition: ttobjs.h:81
FT_Byte instruct_control
Definition: ttobjs.h:85
FT_UShort delta_shift
Definition: ttobjs.h:83
FT_UShort rp0
Definition: ttobjs.h:66
FT_Bool scan_control
Definition: ttobjs.h:90
FT_UShort gep1
Definition: ttobjs.h:94
FT_UnitVector dualVector
Definition: ttobjs.h:70
FT_UShort delta_base
Definition: ttobjs.h:82
FT_UnitVector freeVector
Definition: ttobjs.h:72
FT_Int round_state
Definition: ttobjs.h:76
FT_UShort gep0
Definition: ttobjs.h:93
FT_UnitVector projVector
Definition: ttobjs.h:71
FT_F26Dot6 control_value_cutin
Definition: ttobjs.h:79
FT_UShort gep2
Definition: ttobjs.h:95
FT_UShort rp2
Definition: ttobjs.h:68
FT_Long loop
Definition: ttobjs.h:74
FT_Int scan_type
Definition: ttobjs.h:91
FT_F26Dot6 minimum_distance
Definition: ttobjs.h:75
FT_Bool auto_flip
Definition: ttobjs.h:78
FT_UShort rp1
Definition: ttobjs.h:67
FT_F26Dot6 single_width_cutin
Definition: ttobjs.h:80
FT_Size_Metrics * metrics
Definition: ttobjs.h:280
FT_SizeRec root
Definition: ttobjs.h:276
FT_Size_Metrics hinted_metrics
Definition: ttobjs.h:281
TT_Size_Metrics ttmetrics
Definition: ttobjs.h:283
FT_ULong strike_index
Definition: ttobjs.h:285
FT_Bool rotated
Definition: ttobjs.h:264
FT_Bool valid
Definition: ttobjs.h:262
FT_Bool stretched
Definition: ttobjs.h:265
FT_Long y_ratio
Definition: ttobjs.h:254
FT_Long ratio
Definition: ttobjs.h:257
FT_Fixed scale
Definition: ttobjs.h:258
FT_F26Dot6 compensations[4]
Definition: ttobjs.h:260
FT_UShort ppem
Definition: ttobjs.h:256
FT_Long x_ratio
Definition: ttobjs.h:253
FT_F26Dot6 oy
Definition: ttobjs.h:179
FT_Fixed yy
Definition: ttobjs.h:178
FT_Fixed yx
Definition: ttobjs.h:178
FT_F26Dot6 ox
Definition: ttobjs.h:179
FT_Fixed xx
Definition: ttobjs.h:177
FT_Fixed xy
Definition: ttobjs.h:177
Definition: zic.c:110
@ point_size
Definition: t1info.c:77