Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ttobjs.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ttobjs.h */
4 /* */
5 /* Objects manager (specification). */
6 /* */
7 /* Copyright 1996-2009, 2011-2013 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 <ft2build.h>
24 #include FT_INTERNAL_OBJECTS_H
25 #include FT_INTERNAL_TRUETYPE_TYPES_H
26 
27 
29 
30 
31  /*************************************************************************/
32  /* */
33  /* <Type> */
34  /* TT_Driver */
35  /* */
36  /* <Description> */
37  /* A handle to a TrueType driver object. */
38  /* */
39  typedef struct TT_DriverRec_* TT_Driver;
40 
41 
42  /*************************************************************************/
43  /* */
44  /* <Type> */
45  /* TT_Instance */
46  /* */
47  /* <Description> */
48  /* A handle to a TrueType size object. */
49  /* */
50  typedef struct TT_SizeRec_* TT_Size;
51 
52 
53  /*************************************************************************/
54  /* */
55  /* <Type> */
56  /* TT_GlyphSlot */
57  /* */
58  /* <Description> */
59  /* A handle to a TrueType glyph slot object. */
60  /* */
61  /* <Note> */
62  /* This is a direct typedef of FT_GlyphSlot, as there is nothing */
63  /* specific about the TrueType glyph slot. */
64  /* */
66 
67 
68  /*************************************************************************/
69  /* */
70  /* <Struct> */
71  /* TT_GraphicsState */
72  /* */
73  /* <Description> */
74  /* The TrueType graphics state used during bytecode interpretation. */
75  /* */
76  typedef struct TT_GraphicsState_
77  {
81 
85 
86 #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
87  FT_Bool both_x_axis;
88 #endif
89 
93 
100 
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. */
108 
112 
114 
115 
116 #ifdef TT_USE_BYTECODE_INTERPRETER
117 
118  FT_LOCAL( void )
119  tt_glyphzone_done( TT_GlyphZone zone );
120 
121  FT_LOCAL( FT_Error )
122  tt_glyphzone_new( FT_Memory memory,
123  FT_UShort maxPoints,
124  FT_Short maxContours,
125  TT_GlyphZone zone );
126 
127 #endif /* TT_USE_BYTECODE_INTERPRETER */
128 
129 
130 
131  /*************************************************************************/
132  /* */
133  /* EXECUTION SUBTABLES */
134  /* */
135  /* These sub-tables relate to instruction execution. */
136  /* */
137  /*************************************************************************/
138 
139 
140 #define TT_MAX_CODE_RANGES 3
141 
142 
143  /*************************************************************************/
144  /* */
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 */
149  /* */
150  typedef enum TT_CodeRange_Tag_
151  {
156 
158 
159 
160  typedef struct TT_CodeRange_
161  {
164 
165  } TT_CodeRange;
166 
168 
169 
170  /*************************************************************************/
171  /* */
172  /* Defines a function/instruction definition record. */
173  /* */
174  typedef struct TT_DefRecord_
175  {
176  FT_Int range; /* in which code range is it located? */
177  FT_Long start; /* where does it start? */
178  FT_Long end; /* where does it end? */
179  FT_UInt opc; /* function #, or instruction code */
180  FT_Bool active; /* is it active? */
181  FT_Bool inline_delta; /* is function that defines inline delta? */
182  FT_ULong sph_fdef_flags; /* flags to identify special functions */
183 
185 
186 
187  /*************************************************************************/
188  /* */
189  /* Subglyph transformation record. */
190  /* */
191  typedef struct TT_Transform_
192  {
193  FT_Fixed xx, xy; /* transformation matrix coefficients */
195  FT_F26Dot6 ox, oy; /* offsets */
196 
197  } TT_Transform;
198 
199 
200  /*************************************************************************/
201  /* */
202  /* A note regarding non-squared pixels: */
203  /* */
204  /* (This text will probably go into some docs at some time; for now, it */
205  /* is kept here to explain some definitions in the TT_Size_Metrics */
206  /* record). */
207  /* */
208  /* The CVT is a one-dimensional array containing values that control */
209  /* certain important characteristics in a font, like the height of all */
210  /* capitals, all lowercase letter, default spacing or stem width/height. */
211  /* */
212  /* These values are found in FUnits in the font file, and must be scaled */
213  /* to pixel coordinates before being used by the CVT and glyph programs. */
214  /* Unfortunately, when using distinct x and y resolutions (or distinct x */
215  /* and y pointsizes), there are two possible scalings. */
216  /* */
217  /* A first try was to implement a `lazy' scheme where all values were */
218  /* scaled when first used. However, while some values are always used */
219  /* in the same direction, some others are used under many different */
220  /* circumstances and orientations. */
221  /* */
222  /* I have found a simpler way to do the same, and it even seems to work */
223  /* in most of the cases: */
224  /* */
225  /* - All CVT values are scaled to the maximum ppem size. */
226  /* */
227  /* - When performing a read or write in the CVT, a ratio factor is used */
228  /* to perform adequate scaling. Example: */
229  /* */
230  /* x_ppem = 14 */
231  /* y_ppem = 10 */
232  /* */
233  /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
234  /* entries are scaled to it. */
235  /* */
236  /* x_ratio = 1.0 */
237  /* y_ratio = y_ppem/ppem (< 1.0) */
238  /* */
239  /* We compute the current ratio like: */
240  /* */
241  /* - If projVector is horizontal, */
242  /* ratio = x_ratio = 1.0 */
243  /* */
244  /* - if projVector is vertical, */
245  /* ratio = y_ratio */
246  /* */
247  /* - else, */
248  /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
249  /* */
250  /* Reading a cvt value returns */
251  /* ratio * cvt[index] */
252  /* */
253  /* Writing a cvt value in pixels: */
254  /* cvt[index] / ratio */
255  /* */
256  /* The current ppem is simply */
257  /* ratio * ppem */
258  /* */
259  /*************************************************************************/
260 
261 
262  /*************************************************************************/
263  /* */
264  /* Metrics used by the TrueType size and context objects. */
265  /* */
266  typedef struct TT_Size_Metrics_
267  {
268  /* for non-square pixels */
271 
272  FT_UShort ppem; /* maximum ppem size */
273  FT_Long ratio; /* current ratio */
275 
276  FT_F26Dot6 compensations[4]; /* device-specific compensations */
277 
279 
280  FT_Bool rotated; /* `is the glyph rotated?'-flag */
281  FT_Bool stretched; /* `is the glyph stretched?'-flag */
282 
283  } TT_Size_Metrics;
284 
285 
286  /*************************************************************************/
287  /* */
288  /* TrueType size class. */
289  /* */
290  typedef struct TT_SizeRec_
291  {
293 
294  /* we have our own copy of metrics so that we can modify */
295  /* it without affecting auto-hinting (when used) */
297 
299 
300  FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
301 
302 #ifdef TT_USE_BYTECODE_INTERPRETER
303 
304  FT_UInt num_function_defs; /* number of function definitions */
305  FT_UInt max_function_defs;
306  TT_DefArray function_defs; /* table of function definitions */
307 
308  FT_UInt num_instruction_defs; /* number of ins. definitions */
309  FT_UInt max_instruction_defs;
310  TT_DefArray instruction_defs; /* table of ins. definitions */
311 
312  FT_UInt max_func;
313  FT_UInt max_ins;
314 
315  TT_CodeRangeTable codeRangeTable;
316 
317  TT_GraphicsState GS;
318 
319  FT_ULong cvt_size; /* the scaled control value table */
320  FT_Long* cvt;
321 
322  FT_UShort storage_size; /* The storage area is now part of */
323  FT_Long* storage; /* the instance */
324 
325  TT_GlyphZoneRec twilight; /* The instance's twilight zone */
326 
327  /* debugging variables */
328 
329  /* When using the debugger, we must keep the */
330  /* execution context tied to the instance */
331  /* object rather than asking it on demand. */
332 
333  FT_Bool debug;
334  TT_ExecContext context;
335 
336  FT_Bool bytecode_ready;
337  FT_Bool cvt_ready;
338 
339 #endif /* TT_USE_BYTECODE_INTERPRETER */
340 
341  } TT_SizeRec;
342 
343 
344  /*************************************************************************/
345  /* */
346  /* TrueType driver class. */
347  /* */
348  typedef struct TT_DriverRec_
349  {
351  TT_ExecContext context; /* execution context */
352  TT_GlyphZoneRec zone; /* glyph loader points zone */
353 
355 
356  } TT_DriverRec;
357 
358 
359  /* Note: All of the functions below (except tt_size_reset()) are used */
360  /* as function pointers in a FT_Driver_ClassRec. Therefore their */
361  /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
362  /* TT_Size, etc., so that the compiler can confirm that the types and */
363  /* number of parameters are correct. In all cases the FT_xxx types are */
364  /* cast to their TT_xxx counterparts inside the functions since FreeType */
365  /* will always use the TT driver to create them. */
366 
367 
368  /*************************************************************************/
369  /* */
370  /* Face functions */
371  /* */
372  FT_LOCAL( FT_Error )
374  FT_Face ttface, /* TT_Face */
375  FT_Int face_index,
376  FT_Int num_params,
377  FT_Parameter* params );
378 
379  FT_LOCAL( void )
380  tt_face_done( FT_Face ttface ); /* TT_Face */
381 
382 
383  /*************************************************************************/
384  /* */
385  /* Size functions */
386  /* */
387  FT_LOCAL( FT_Error )
388  tt_size_init( FT_Size ttsize ); /* TT_Size */
389 
390  FT_LOCAL( void )
391  tt_size_done( FT_Size ttsize ); /* TT_Size */
392 
393 #ifdef TT_USE_BYTECODE_INTERPRETER
394 
395  FT_LOCAL( FT_Error )
396  tt_size_run_fpgm( TT_Size size,
397  FT_Bool pedantic );
398 
399  FT_LOCAL( FT_Error )
400  tt_size_run_prep( TT_Size size,
401  FT_Bool pedantic );
402 
403  FT_LOCAL( FT_Error )
404  tt_size_ready_bytecode( TT_Size size,
405  FT_Bool pedantic );
406 
407 #endif /* TT_USE_BYTECODE_INTERPRETER */
408 
409  FT_LOCAL( FT_Error )
410  tt_size_reset( TT_Size size );
411 
412 
413  /*************************************************************************/
414  /* */
415  /* Driver functions */
416  /* */
417  FT_LOCAL( FT_Error )
418  tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
419 
420  FT_LOCAL( void )
421  tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
422 
423 
424  /*************************************************************************/
425  /* */
426  /* Slot functions */
427  /* */
428  FT_LOCAL( FT_Error )
429  tt_slot_init( FT_GlyphSlot slot );
430 
431 
432  /* auxiliary */
433 #define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
434 
435 
437 
438 #endif /* __TTOBJS_H__ */
439 
440 
441 /* END */
enum TT_CodeRange_Tag_ TT_CodeRange_Tag
FT_UShort rp1
Definition: ttobjs.h:79
int FT_Error
Definition: fttypes.h:296
FT_Int round_state
Definition: ttobjs.h:92
FT_Byte instruct_control
Definition: ttobjs.h:101
GLuint GLuint stream
FT_F26Dot6 single_width_cutin
Definition: ttobjs.h:96
signed long FT_Long
Definition: fttypes.h:238
FT_ULong size
Definition: ttobjs.h:163
unsigned long FT_ULong
Definition: fttypes.h:249
struct TT_Transform_ TT_Transform
FT_UShort rp2
Definition: ttobjs.h:80
FT_F26Dot6 oy
Definition: ttobjs.h:195
#define FT_END_HEADER
Definition: ftheader.h:54
signed int FT_Int
Definition: fttypes.h:216
FT_ULong strike_index
Definition: ttobjs.h:300
FT_Bool active
Definition: ttobjs.h:180
FT_Bool valid
Definition: ttobjs.h:278
FT_UInt opc
Definition: ttobjs.h:179
FT_Fixed yy
Definition: ttobjs.h:194
FT_Long x_ratio
Definition: ttobjs.h:269
FT_Short delta_base
Definition: ttobjs.h:98
typedefFT_BEGIN_HEADER struct TT_DriverRec_ * TT_Driver
Definition: ttobjs.h:39
tt_slot_init(FT_GlyphSlot slot)
Definition: ttobjs.c:1318
tt_face_init(FT_Stream stream, FT_Face ttface, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
Definition: ttobjs.c:504
struct TT_DriverRec_ TT_DriverRec
FT_UnitVector projVector
Definition: ttobjs.h:83
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
FT_GlyphSlot TT_GlyphSlot
Definition: ttobjs.h:65
struct TT_DefRecord_ TT_DefRecord
FT_UShort gep1
Definition: ttobjs.h:110
unsigned char FT_Byte
Definition: fttypes.h:150
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
FT_DriverRec root
Definition: ttobjs.h:350
struct TT_GraphicsState_ TT_GraphicsState
FT_Byte * base
Definition: ttobjs.h:162
FT_SizeRec root
Definition: ttobjs.h:292
FT_UnitVector dualVector
Definition: ttobjs.h:82
TT_ExecContext context
Definition: ttobjs.h:351
FT_Long start
Definition: ttobjs.h:177
FT_Long ratio
Definition: ttobjs.h:273
FT_F26Dot6 control_value_cutin
Definition: ttobjs.h:95
#define FT_LOCAL(x)
Definition: ftconfig.h:235
FT_Int range
Definition: ttobjs.h:176
FT_UnitVector freeVector
Definition: ttobjs.h:84
TT_CodeRange_Tag_
Definition: ttobjs.h:150
FT_UShort rp0
Definition: ttobjs.h:78
FT_Bool stretched
Definition: ttobjs.h:281
FT_Bool inline_delta
Definition: ttobjs.h:181
TT_Size_Metrics ttmetrics
Definition: ttobjs.h:298
TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES]
Definition: ttobjs.h:167
signed short FT_Short
Definition: fttypes.h:194
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
FT_Bool rotated
Definition: ttobjs.h:280
tt_driver_init(FT_Module ttdriver)
Definition: ttobjs.c:1251
tt_size_done(FT_Size ttsize)
Definition: ttobjs.c:1139
signed long FT_F26Dot6
Definition: fttypes.h:272
TT_GlyphZoneRec zone
Definition: ttobjs.h:352
struct TT_DefRecord_ * TT_DefArray
GLenum const GLfloat * params
struct TT_SizeRec_ TT_SizeRec
signed long FT_Fixed
Definition: fttypes.h:284
tt_driver_done(FT_Module ttdriver)
Definition: ttobjs.c:1284
unsigned int FT_UInt
Definition: fttypes.h:227
FT_Short delta_shift
Definition: ttobjs.h:99
FT_Int scan_type
Definition: ttobjs.h:107
tt_size_reset(TT_Size size)
Definition: ttobjs.c:1166
FT_UShort gep0
Definition: ttobjs.h:109
void * extension_component
Definition: ttobjs.h:354
FT_F26Dot6 minimum_distance
Definition: ttobjs.h:91
FT_Fixed xy
Definition: ttobjs.h:193
FT_ULong sph_fdef_flags
Definition: ttobjs.h:182
FT_Fixed scale
Definition: ttobjs.h:274
tt_size_init(FT_Size ttsize)
Definition: ttobjs.c:1110
FT_Bool scan_control
Definition: ttobjs.h:106
FT_Long loop
Definition: ttobjs.h:90
tt_face_done(FT_Face ttface)
Definition: ttobjs.c:671
struct TT_CodeRange_ TT_CodeRange
unsigned short FT_UShort
Definition: fttypes.h:205
struct TT_Size_Metrics_ TT_Size_Metrics
FT_UShort ppem
Definition: ttobjs.h:272
FT_Bool auto_flip
Definition: ttobjs.h:94
GLsizeiptr size
FT_F26Dot6 single_width_value
Definition: ttobjs.h:97
FT_Long end
Definition: ttobjs.h:178
struct TT_SizeRec_ * TT_Size
Definition: ttobjs.h:50
FT_Long y_ratio
Definition: ttobjs.h:270
#define TT_MAX_CODE_RANGES
Definition: ttobjs.h:140
FT_Size_Metrics metrics
Definition: ttobjs.h:296
FT_UShort gep2
Definition: ttobjs.h:111