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]
ttinterp.h
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ttinterp.h */
4 /* */
5 /* TrueType bytecode interpreter (specification). */
6 /* */
7 /* Copyright 1996-2007, 2010, 2012-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 __TTINTERP_H__
20 #define __TTINTERP_H__
21 
22 #include <ft2build.h>
23 #include "ttobjs.h"
24 
25 
27 
28 
29 #ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
30 
31 #define EXEC_OP_ TT_ExecContext exc,
32 #define EXEC_OP TT_ExecContext exc
33 #define EXEC_ARG_ exc,
34 #define EXEC_ARG exc
35 
36 #else /* static implementation */
37 
38 #define EXEC_OP_ /* void */
39 #define EXEC_OP /* void */
40 #define EXEC_ARG_ /* void */
41 #define EXEC_ARG /* void */
42 
43 #endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
44 
45 
46  /*************************************************************************/
47  /* */
48  /* Rounding mode constants. */
49  /* */
50 #define TT_Round_Off 5
51 #define TT_Round_To_Half_Grid 0
52 #define TT_Round_To_Grid 1
53 #define TT_Round_To_Double_Grid 2
54 #define TT_Round_Up_To_Grid 4
55 #define TT_Round_Down_To_Grid 3
56 #define TT_Round_Super 6
57 #define TT_Round_Super_45 7
58 
59 
60  /*************************************************************************/
61  /* */
62  /* Function types used by the interpreter, depending on various modes */
63  /* (e.g. the rounding mode, whether to render a vertical or horizontal */
64  /* line etc). */
65  /* */
66  /*************************************************************************/
67 
68  /* Rounding function */
69  typedef FT_F26Dot6
71  FT_F26Dot6 compensation );
72 
73  /* Point displacement along the freedom vector routine */
74  typedef void
76  FT_UShort point,
78 
79  /* Distance projection along one of the projection vectors */
80  typedef FT_F26Dot6
82  FT_Pos dy );
83 
84  /* reading a cvt value. Take care of non-square pixels if necessary */
85  typedef FT_F26Dot6
87 
88  /* setting or moving a cvt value. Take care of non-square pixels */
89  /* if necessary */
90  typedef void
92  FT_F26Dot6 value );
93 
94 
95  /*************************************************************************/
96  /* */
97  /* This structure defines a call record, used to manage function calls. */
98  /* */
99  typedef struct TT_CallRec_
100  {
106 
108 
109 
110 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
111 
112  /*************************************************************************/
113  /* */
114  /* These structures define rules used to tweak subpixel hinting for */
115  /* various fonts. "", 0, "", NULL value indicates to match any value. */
116  /* */
117 
118 #define SPH_MAX_NAME_SIZE 32
119 #define SPH_MAX_CLASS_MEMBERS 100
120 
121  typedef struct SPH_TweakRule_
122  {
123  const char family[SPH_MAX_NAME_SIZE];
124  const FT_UInt ppem;
125  const char style[SPH_MAX_NAME_SIZE];
126  const FT_ULong glyph;
127 
128  } SPH_TweakRule;
129 
130 
131  typedef struct SPH_ScaleRule_
132  {
133  const char family[SPH_MAX_NAME_SIZE];
134  const FT_UInt ppem;
135  const char style[SPH_MAX_NAME_SIZE];
136  const FT_ULong glyph;
137  const FT_ULong scale;
138 
139  } SPH_ScaleRule;
140 
141 
142  typedef struct SPH_Font_Class_
143  {
144  const char name[SPH_MAX_NAME_SIZE];
145  const char member[SPH_MAX_CLASS_MEMBERS][SPH_MAX_NAME_SIZE];
146 
147  } SPH_Font_Class;
148 
149 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
150 
151 
152  /*************************************************************************/
153  /* */
154  /* The main structure for the interpreter which collects all necessary */
155  /* variables and states. */
156  /* */
157  typedef struct TT_ExecContextRec_
158  {
162 
163  /* instructions state */
164 
165  FT_Error error; /* last execution error */
166 
167  FT_Long top; /* top of exec. stack */
168 
169  FT_UInt stackSize; /* size of exec. stack */
170  FT_Long* stack; /* current exec. stack */
171 
173  FT_UInt new_top; /* new top after exec. */
174 
175  TT_GlyphZoneRec zp0, /* zone records */
176  zp1,
177  zp2,
178  pts,
179  twilight;
180 
182  TT_Size_Metrics tt_metrics; /* size metrics */
183 
184  TT_GraphicsState GS; /* current graphics state */
185 
186  FT_Int curRange; /* current code range number */
187  FT_Byte* code; /* current code range */
188  FT_Long IP; /* current instruction pointer */
189  FT_Long codeSize; /* size of current range */
190 
191  FT_Byte opcode; /* current opcode */
192  FT_Int length; /* length of current opcode */
193 
194  FT_Bool step_ins; /* true if the interpreter must */
195  /* increment IP after ins. exec */
198 
199  FT_UInt glyphSize; /* glyph instructions buffer size */
200  FT_Byte* glyphIns; /* glyph instructions buffer */
201 
202  FT_UInt numFDefs; /* number of function defs */
203  FT_UInt maxFDefs; /* maximum number of function defs */
204  TT_DefArray FDefs; /* table of FDefs entries */
205 
206  FT_UInt numIDefs; /* number of instruction defs */
207  FT_UInt maxIDefs; /* maximum number of ins defs */
208  TT_DefArray IDefs; /* table of IDefs entries */
209 
210  FT_UInt maxFunc; /* maximum function index */
211  FT_UInt maxIns; /* maximum instruction index */
212 
213  FT_Int callTop, /* top of call stack during execution */
214  callSize; /* size of call stack */
215  TT_CallStack callStack; /* call stack */
216 
217  FT_UShort maxPoints; /* capacity of this context's `pts' */
218  FT_Short maxContours; /* record, expressed in points and */
219  /* contours. */
220 
221  TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
222  /* useful for the debugger */
223 
224  FT_UShort storeSize; /* size of current storage */
225  FT_Long* storage; /* storage area */
226 
227  FT_F26Dot6 period; /* values used for the */
228  FT_F26Dot6 phase; /* `SuperRounding' */
230 
231 #if 0
232  /* this seems to be unused */
233  FT_Int cur_ppem; /* ppem along the current proj vector */
234 #endif
235 
236  FT_Bool instruction_trap; /* If `True', the interpreter will */
237  /* exit after each instruction */
238 
239  TT_GraphicsState default_GS; /* graphics state resulting from */
240  /* the prep program */
241  FT_Bool is_composite; /* true if the glyph is composite */
242  FT_Bool pedantic_hinting; /* true if pedantic interpretation */
243 
244  /* latest interpreter additions */
245 
246  FT_Long F_dot_P; /* dot product of freedom and projection */
247  /* vectors */
248  TT_Round_Func func_round; /* current rounding function */
249 
250  TT_Project_Func func_project, /* current projection function */
251  func_dualproj, /* current dual proj. function */
252  func_freeProj; /* current freedom proj. func */
253 
254  TT_Move_Func func_move; /* current point move function */
255  TT_Move_Func func_move_orig; /* move original position function */
256 
257  TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
258  TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
259  TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
260 
261  FT_Bool grayscale; /* are we hinting for grayscale? */
262 
263 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
264  TT_Round_Func func_round_sphn; /* subpixel rounding function */
265 
266  FT_Bool grayscale_hinting; /* Using grayscale hinting? */
267  FT_Bool subpixel_hinting; /* Using subpixel hinting? */
268  FT_Bool native_hinting; /* Using native hinting? */
269  FT_Bool ignore_x_mode; /* Standard rendering mode for */
270  /* subpixel hinting. On if gray */
271  /* or subpixel hinting is on ) */
272 
273  /* The following 4 aren't fully implemented but here for MS rasterizer */
274  /* compatibility. */
275  FT_Bool compatible_widths; /* compatible widths? */
276  FT_Bool symmetrical_smoothing; /* symmetrical_smoothing? */
277  FT_Bool bgr; /* bgr instead of rgb? */
278  FT_Bool subpixel_positioned; /* subpixel positioned */
279  /* (DirectWrite ClearType)? */
280 
281  FT_Int rasterizer_version; /* MS rasterizer version */
282 
283  FT_Bool iup_called; /* IUP called for glyph? */
284 
285  FT_ULong sph_tweak_flags; /* flags to control */
286  /* hint tweaks */
287 
288  FT_ULong sph_in_func_flags; /* flags to indicate if in */
289  /* special functions */
290 
291 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
292 
294 
295 
297 
298 
299 #ifdef TT_USE_BYTECODE_INTERPRETER
300  FT_LOCAL( FT_Error )
301  TT_Goto_CodeRange( TT_ExecContext exec,
302  FT_Int range,
303  FT_Long IP );
304 
305  FT_LOCAL( FT_Error )
306  TT_Set_CodeRange( TT_ExecContext exec,
307  FT_Int range,
308  void* base,
309  FT_Long length );
310 
311  FT_LOCAL( FT_Error )
312  TT_Clear_CodeRange( TT_ExecContext exec,
313  FT_Int range );
314 
315 
316  FT_LOCAL( FT_Error )
317  Update_Max( FT_Memory memory,
318  FT_ULong* size,
319  FT_Long multiplier,
320  void* _pbuff,
321  FT_ULong new_max );
322 #endif /* TT_USE_BYTECODE_INTERPRETER */
323 
324 
325  /*************************************************************************/
326  /* */
327  /* <Function> */
328  /* TT_New_Context */
329  /* */
330  /* <Description> */
331  /* Queries the face context for a given font. Note that there is */
332  /* now a _single_ execution context in the TrueType driver which is */
333  /* shared among faces. */
334  /* */
335  /* <Input> */
336  /* face :: A handle to the source face object. */
337  /* */
338  /* <Return> */
339  /* A handle to the execution context. Initialized for `face'. */
340  /* */
341  /* <Note> */
342  /* Only the glyph loader and debugger should call this function. */
343  /* */
346 
347 
348 #ifdef TT_USE_BYTECODE_INTERPRETER
349  FT_LOCAL( FT_Error )
350  TT_Done_Context( TT_ExecContext exec );
351 
352  FT_LOCAL( FT_Error )
353  TT_Load_Context( TT_ExecContext exec,
354  TT_Face face,
355  TT_Size size );
356 
357  FT_LOCAL( FT_Error )
358  TT_Save_Context( TT_ExecContext exec,
359  TT_Size ins );
360 
361  FT_LOCAL( FT_Error )
362  TT_Run_Context( TT_ExecContext exec,
363  FT_Bool debug );
364 #endif /* TT_USE_BYTECODE_INTERPRETER */
365 
366 
367  /*************************************************************************/
368  /* */
369  /* <Function> */
370  /* TT_RunIns */
371  /* */
372  /* <Description> */
373  /* Executes one or more instruction in the execution context. This */
374  /* is the main function of the TrueType opcode interpreter. */
375  /* */
376  /* <Input> */
377  /* exec :: A handle to the target execution context. */
378  /* */
379  /* <Return> */
380  /* FreeType error code. 0 means success. */
381  /* */
382  /* <Note> */
383  /* Only the object manager and debugger should call this function. */
384  /* */
385  /* This function is publicly exported because it is directly */
386  /* invoked by the TrueType debugger. */
387  /* */
389  TT_RunIns( TT_ExecContext exec );
390 
391 
393 
394 #endif /* __TTINTERP_H__ */
395 
396 
397 /* END */
GLenum GLuint GLenum GLsizei length
const TT_GraphicsState tt_default_graphics_state
void(* TT_Move_Func)(EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance)
Definition: ttinterp.h:75
int FT_Error
Definition: fttypes.h:296
TT_Set_CVT_Func func_move_cvt
Definition: ttinterp.h:259
TT_Set_CVT_Func func_write_cvt
Definition: ttinterp.h:258
signed long FT_Long
Definition: fttypes.h:238
GLenum GLenum GLenum GLenum GLenum scale
unsigned long FT_ULong
Definition: fttypes.h:249
FT_UInt glyphSize
Definition: ttinterp.h:199
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
TT_Get_CVT_Func func_read_cvt
Definition: ttinterp.h:257
#define FT_END_HEADER
Definition: ftheader.h:54
signed int FT_Int
Definition: fttypes.h:216
FT_Memory memory
Definition: ttinterp.h:161
FT_Int Caller_Range
Definition: ttinterp.h:101
TT_DefArray IDefs
Definition: ttinterp.h:208
FT_Long * stack
Definition: ttinterp.h:170
FT_Long Cur_Restart
Definition: ttinterp.h:104
FT_F26Dot6 phase
Definition: ttinterp.h:228
typedefFT_BEGIN_HEADER struct TT_DriverRec_ * TT_Driver
Definition: ttobjs.h:39
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
FT_F26Dot6(* TT_Round_Func)(EXEC_OP_ FT_F26Dot6 distance, FT_F26Dot6 compensation)
Definition: ttinterp.h:70
GLenum GLint * range
TT_New_Context(TT_Driver driver)
TT_Size_Metrics tt_metrics
Definition: ttinterp.h:182
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
GLenum GLuint GLint GLenum face
FT_Long codeSize
Definition: ttinterp.h:189
unsigned char FT_Byte
Definition: fttypes.h:150
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
FT_ULong cvtSize
Definition: ttinterp.h:196
TT_CodeRangeTable codeRangeTable
Definition: ttinterp.h:221
FT_Short maxContours
Definition: ttinterp.h:218
FT_UInt maxIDefs
Definition: ttinterp.h:207
FT_Long * storage
Definition: ttinterp.h:225
FT_Long Cur_End
Definition: ttinterp.h:105
FT_Long Caller_IP
Definition: ttinterp.h:102
#define FT_LOCAL(x)
Definition: ftconfig.h:235
FT_Long * cvt
Definition: ttinterp.h:197
FT_UInt numIDefs
Definition: ttinterp.h:206
FT_Bool step_ins
Definition: ttinterp.h:194
FT_UInt idx
Definition: cffcmap.c:127
FT_F26Dot6 period
Definition: ttinterp.h:227
FT_Size_Metrics metrics
Definition: ttinterp.h:181
TT_Project_Func func_project
Definition: ttinterp.h:250
TT_GlyphZoneRec zp2
Definition: ttinterp.h:175
FT_Error error
Definition: ttinterp.h:165
FT_F26Dot6 threshold
Definition: ttinterp.h:229
FT_Long Cur_Count
Definition: ttinterp.h:103
TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES]
Definition: ttobjs.h:167
GLsizei GLsizei GLfloat distance
GLsizei const GLfloat * value
FT_Bool grayscale
Definition: ttinterp.h:261
FT_UShort storeSize
Definition: ttinterp.h:224
struct TT_CallRec_ * TT_CallStack
signed short FT_Short
Definition: fttypes.h:194
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
FT_Bool pedantic_hinting
Definition: ttinterp.h:242
FT_F26Dot6(* TT_Project_Func)(EXEC_OP_ FT_Pos dx, FT_Pos dy)
Definition: ttinterp.h:81
CFF_Driver driver
Definition: cffdrivr.c:585
GLuint const GLchar * name
signed long FT_F26Dot6
Definition: fttypes.h:272
TT_Round_Func func_round
Definition: ttinterp.h:248
FT_UShort maxPoints
Definition: ttinterp.h:217
FT_UInt maxFDefs
Definition: ttinterp.h:203
TT_GraphicsState GS
Definition: ttinterp.h:184
unsigned int FT_UInt
Definition: fttypes.h:227
#define FT_EXPORT(x)
Definition: ftconfig.h:269
FT_F26Dot6(* TT_Get_CVT_Func)(EXEC_OP_ FT_ULong idx)
Definition: ttinterp.h:86
FT_Bool is_composite
Definition: ttinterp.h:241
TT_DefArray FDefs
Definition: ttinterp.h:204
TT_Move_Func func_move
Definition: ttinterp.h:254
void(* TT_Set_CVT_Func)(EXEC_OP_ FT_ULong idx, FT_F26Dot6 value)
Definition: ttinterp.h:91
FT_UInt numFDefs
Definition: ttinterp.h:202
FT_Byte * glyphIns
Definition: ttinterp.h:200
unsigned short FT_UShort
Definition: fttypes.h:205
TT_GraphicsState default_GS
Definition: ttinterp.h:239
TT_Move_Func func_move_orig
Definition: ttinterp.h:255
GLsizeiptr size
FT_Byte * code
Definition: ttinterp.h:187
TT_CallStack callStack
Definition: ttinterp.h:215
struct TT_ExecContextRec_ TT_ExecContextRec
FT_UInt stackSize
Definition: ttinterp.h:169
struct TT_CallRec_ TT_CallRec
FT_Bool instruction_trap
Definition: ttinterp.h:236
#define EXEC_OP_
Definition: ttinterp.h:31
TT_RunIns(TT_ExecContext exec)