xref: /plan9/sys/src/cmd/gs/src/ttobjs.h (revision 8deabd962e84f51c67a12f970084955d97d8a8f2)
1 /* Copyright (C) 2003 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: ttobjs.h,v 1.6 2004/10/06 11:32:17 igor Exp $ */
18 
19 /* Changes after FreeType: cut out the TrueType instruction interpreter. */
20 
21 
22 /*******************************************************************
23  *
24  *  ttobjs.h                                                     1.0
25  *
26  *    Objects definition unit.
27  *
28  *  Copyright 1996-1998 by
29  *  David Turner, Robert Wilhelm, and Werner Lemberg.
30  *
31  *  This file is part of the FreeType project, and may only be used
32  *  modified and distributed under the terms of the FreeType project
33  *  license, LICENSE.TXT. By continuing to use, modify, or distribute
34  *  this file you indicate that you have read the license and
35  *  understand and accept it fully.
36  *
37  ******************************************************************/
38 
39 #ifndef TTOBJS_H
40 #define TTOBJS_H
41 
42 #include "ttcommon.h"
43 #include "tttypes.h"
44 #include "tttables.h"
45 #include <setjmp.h>
46 
47 #ifdef __cplusplus
48   extern "C" {
49 #endif
50 
51 /*                                                                       */
52 /*  This file contains the definitions and methods of the four           */
53 /*  kinds of objects managed by the FreeType engine.  These are:         */
54 /*                                                                       */
55 /*                                                                       */
56 /*   Face objects:                                                       */
57 /*                                                                       */
58 /*     There is always one face object per opened TrueType font          */
59 /*     file, and only one.  The face object contains data that is        */
60 /*     independent of current transform/scaling/rotation and             */
61 /*     pointsize, or glyph index.  This data is made of several          */
62 /*     critical tables that are loaded on face object creation.          */
63 /*                                                                       */
64 /*     A face object tracks all active and recycled objects of           */
65 /*     the instance and execution context classes.  Destroying a face    */
66 /*     object will automatically destroy all associated instances.       */
67 /*                                                                       */
68 /*                                                                       */
69 /*   Instance objects:                                                   */
70 /*                                                                       */
71 /*     An instance object always relates to a given face object,         */
72 /*     known as its 'parent' or 'owner', and contains only the           */
73 /*     data that is specific to one given pointsize/transform of         */
74 /*     the face.  You can only create an instance from a face object.    */
75 /*                                                                       */
76 /*     An instance's current transform/pointsize can be changed          */
77 /*     at any time using a single high-level API call,                   */
78 /*     TT_Reset_Instance().                                              */
79 /*                                                                       */
80 /*   Execution Context objects:                                          */
81 /*                                                                       */
82 /*     An execution context (or context in short) relates to a face.     */
83 /*     It contains the data and tables that are necessary to load        */
84 /*     and hint (i.e. execute the glyph instructions of) one glyph.      */
85 /*     A context is a transient object that is queried/created on        */
86 /*     the fly: client applications never deal with them directly.       */
87 /*                                                                       */
88 /*                                                                       */
89 /*   Glyph objects:                                                      */
90 /*                                                                       */
91 /*     A glyph object contains only the minimal glyph information        */
92 /*     needed to render one glyph correctly.  This means that a glyph    */
93 /*     object really contains tables that are sized to hold the          */
94 /*     contents of _any_ glyph of a given face.  A client application    */
95 /*     can usually create one glyph object for a given face, then use    */
96 /*     it for all subsequent loads.                                      */
97 /*                                                                       */
98 /*   Here is an example of a client application :                        */
99 /*   (NOTE: No error checking performed here!)                           */
100 /*                                                                       */
101 /*                                                                       */
102 /*     TT_Face       face;         -- face handle                        */
103 /*     TT_Instance   ins1, ins2;   -- two instance handles               */
104 /*     TT_Glyph      glyph;        -- glyph handle                       */
105 /*                                                                       */
106 /*     TT_Init_FreeType();                                               */
107 /*                                                                       */
108 /*     -- Initialize the engine.  This must be done prior to _any_       */
109 /*        operation.                                                     */
110 /*                                                                       */
111 /*     TT_Open_Face( "/some/face/name.ttf", &face );                     */
112 /*                                                                       */
113 /*     -- create the face object.  This call opens the font file         */
114 /*                                                                       */
115 /*     TT_New_Instance( face, &ins1 );                                   */
116 /*     TT_New_Instance( face, &ins2 );                                   */
117 /*                                                                       */
118 /*     TT_Set_Instance_PointSize( ins1, 8 );                             */
119 /*     TT_Set_Instance_PointSize( ins2, 12 );                            */
120 /*                                                                       */
121 /*     -- create two distinct instances of the same face                 */
122 /*     -- ins1  is pointsize 8 at resolution 96 dpi                      */
123 /*     -- ins2  is pointsize 12 at resolution 96 dpi                     */
124 /*                                                                       */
125 /*     TT_New_Glyph( face, &glyph );                                     */
126 /*                                                                       */
127 /*     -- create a new glyph object which will receive the contents      */
128 /*        of any glyph of 'face'                                         */
129 /*                                                                       */
130 /*     TT_Load_Glyph( ins1, glyph, 64, DEFAULT_GLYPH_LOAD );             */
131 /*                                                                       */
132 /*     -- load glyph indexed 64 at pointsize 8 in the 'glyph' object     */
133 /*     -- NOTE: This call will fail if the instance and the glyph        */
134 /*              do not relate to the same face object.                   */
135 /*                                                                       */
136 /*     TT_Get_Outline( glyph, &outline );                                */
137 /*                                                                       */
138 /*     -- extract the glyph outline from the object and copies it        */
139 /*        to the 'outline' record                                        */
140 /*                                                                       */
141 /*     TT_Get_Metrics( glyph, &metrics );                                */
142 /*                                                                       */
143 /*     -- extract the glyph metrics and put them into the 'metrics'      */
144 /*        record                                                         */
145 /*                                                                       */
146 /*     TT_Load_Glyph( ins2, glyph, 64, DEFAULT_GLYPH_LOAD );             */
147 /*                                                                       */
148 /*     -- load the same glyph at pointsize 12 in the 'glyph' object      */
149 /*                                                                       */
150 /*                                                                       */
151 /*     TT_Close_Face( &face );                                           */
152 /*                                                                       */
153 /*     -- destroy the face object.  This will destroy 'ins1' and         */
154 /*        'ins2'.  However, the glyph object will still be available     */
155 /*                                                                       */
156 /*     TT_Done_FreeType();                                               */
157 /*                                                                       */
158 /*     -- Finalize the engine.  This will also destroy all pending       */
159 /*        glyph objects (here 'glyph').                                  */
160 /*                                                                       */
161 /*                                                                       */
162 
163   struct _TFace;
164   struct _TInstance;
165   struct _TExecution_Context;
166   struct _TGlyph;
167 
168 #ifndef TFace_defined
169 #define TFace_defined
170 typedef struct _TFace  TFace;
171 #endif
172   typedef TFace*         PFace;
173 
174 #ifndef TInstance_defined
175 #define TInstance_defined
176 typedef struct _TInstance TInstance;
177 #endif
178   typedef TInstance*         PInstance;
179 
180 #ifndef TExecution_Context_defined
181 #define TExecution_Context_defined
182 typedef struct _TExecution_Context TExecution_Context;
183 #endif
184   typedef TExecution_Context*         PExecution_Context;
185 
186   typedef struct _TGlyph  TGlyph;
187   typedef TGlyph*         PGlyph;
188 
189 
190   /*************************************************************/
191   /*                                                           */
192   /*  ADDITIONAL SUBTABLES                                     */
193   /*                                                           */
194   /*  These tables are not precisely defined by the specs      */
195   /*  but their structures is implied by the TrueType font     */
196   /*  file layout.                                             */
197   /*                                                           */
198   /*************************************************************/
199 
200   /* Graphics State                            */
201   /*                                           */
202   /* The Graphics State (GS) is managed by the */
203   /* instruction field, but does not come from */
204   /* the font file.  Thus, we can use 'int's   */
205   /* where needed.                             */
206 
207   struct  _TGraphicsState
208   {
209     Int            rp0;
210     Int            rp1;
211     Int            rp2;
212 
213     TT_UnitVector  dualVector;
214     TT_UnitVector  projVector;
215     TT_UnitVector  freeVector;
216 
217     Long           loop;
218     TT_F26Dot6     minimum_distance;
219     Int            round_state;
220 
221     Bool           auto_flip;
222     TT_F26Dot6     control_value_cutin;
223     TT_F26Dot6     single_width_cutin;
224     TT_F26Dot6     single_width_value;
225     Int            delta_base;
226     Int            delta_shift;
227 
228     Byte           instruct_control;
229     Bool           scan_control;
230     Int            scan_type;
231 
232     Int            gep0;
233     Int            gep1;
234     Int            gep2;
235 
236   };
237 
238   typedef struct _TGraphicsState  TGraphicsState;
239 
240 
241   extern const TGraphicsState  Default_GraphicsState;
242 
243 
244   /*************************************************************/
245   /*                                                           */
246   /*  EXECUTION SUBTABLES                                      */
247   /*                                                           */
248   /*  These sub-tables relate to instruction execution.        */
249   /*                                                           */
250   /*************************************************************/
251 
252 #  define MAX_CODE_RANGES   3
253 
254   /* There can only be 3 active code ranges at once:   */
255   /*   - the Font Program                              */
256   /*   - the CVT Program                               */
257   /*   - a glyph's instructions set                    */
258 
259 #  define TT_CodeRange_Font  1
260 #  define TT_CodeRange_Cvt   2
261 #  define TT_CodeRange_Glyph 3
262 
263 
264   struct  _TCodeRange
265   {
266     PByte  Base;
267     Int    Size;
268   };
269 
270   typedef struct _TCodeRange  TCodeRange;
271   typedef TCodeRange*         PCodeRange;
272 
273 
274   /* Defintion of a code range                                       */
275   /*                                                                 */
276   /* Code ranges can be resident to a glyph (i.e. the Font Program)  */
277   /* while some others are volatile (Glyph instructions).            */
278   /* Tracking the state and presence of code ranges allows function  */
279   /* and instruction definitions within a code range to be forgotten */
280   /* when the range is discarded.                                    */
281 
282   typedef TCodeRange  TCodeRangeTable[MAX_CODE_RANGES];
283 
284   /* defines a function/instruction definition record */
285 
286   struct  _TDefRecord
287   {
288     Int   Range;      /* in which code range is it located ? */
289     Int   Start;      /* where does it start ?               */
290     Byte  Opc;        /* function #, or instruction code     */
291     Bool  Active;     /* is it active ?                      */
292   };
293 
294   typedef struct _TDefRecord  TDefRecord;
295   typedef TDefRecord*         PDefRecord;
296   typedef TDefRecord*         PDefArray;
297 
298   /* defines a call record, used to manage function calls. */
299 
300   struct  _TCallRecord
301   {
302     Int  Caller_Range;
303     Int  Caller_IP;
304     Int  Cur_Count;
305     Int  Cur_Restart;
306   };
307 
308   typedef struct _TCallRecord  TCallRecord;
309   typedef TCallRecord*         PCallRecord;
310   typedef TCallRecord*         PCallStack;  /* defines a simple call stack */
311 
312 
313   /* This type defining a set of glyph points will be used to represent */
314   /* each zone (regular and twilight) during instructions decoding.     */
315   struct  _TGlyph_Zone
316   {
317     int           n_points;   /* number of points in zone */
318     int           n_contours; /* number of contours       */
319 
320     PCoordinates  org_x;      /* original points coordinates */
321     PCoordinates  org_y;      /* original points coordinates */
322     PCoordinates  cur_x;      /* current points coordinates  */
323     PCoordinates  cur_y;      /* current points coordinates  */
324 
325     Byte*         touch;      /* current touch flags         */
326     Short*        contours;   /* contour end points          */
327   };
328 
329   typedef struct _TGlyph_Zone  TGlyph_Zone;
330   typedef TGlyph_Zone         *PGlyph_Zone;
331 
332 
333 
334 #ifndef TT_STATIC_INTERPRETER  /* indirect implementation */
335 
336 #define EXEC_OPS   PExecution_Context exc,
337 #define EXEC_OP    PExecution_Context exc
338 #define EXEC_ARGS  exc,
339 #define EXEC_ARG   exc
340 
341 #else                          /* static implementation */
342 
343 #define EXEC_OPS   /* void */
344 #define EXEC_OP    /* void */
345 #define EXEC_ARGS  /* void */
346 #define EXEC_ARG   /* void */
347 
348 #endif
349 
350   /* Rounding function, as used by the interpreter */
351   typedef TT_F26Dot6  (*TRound_Function)( EXEC_OPS TT_F26Dot6 distance,
352                                                    TT_F26Dot6 compensation );
353 
354   /* Point displacement along the freedom vector routine, as */
355   /* used by the interpreter                                 */
356   typedef void  (*TMove_Function)( EXEC_OPS PGlyph_Zone zone,
357                                             Int         point,
358                                             TT_F26Dot6  distance );
359 
360   /* Distance projection along one of the proj. vectors, as used */
361   /* by the interpreter                                          */
362   typedef TT_F26Dot6  (*TProject_Function)( EXEC_OPS TT_F26Dot6 Vx,
363                                                      TT_F26Dot6 Vy );
364 
365   /* reading a cvt value. Take care of non-square pixels when needed */
366   typedef TT_F26Dot6  (*TGet_CVT_Function)( EXEC_OPS  Int index );
367 
368   /* setting or moving a cvt value.  Take care of non-square pixels  */
369   /* when needed                                                     */
370   typedef void  (*TSet_CVT_Function)( EXEC_OPS  Int         index,
371                                                 TT_F26Dot6  value );
372 
373   /* subglyph transformation record */
374   struct  _TTransform
375   {
376     TT_Fixed    xx, xy; /* transformation */
377     TT_Fixed    yx, yy; /*     matrix     */
378     TT_F26Dot6  ox, oy; /*    offsets     */
379   };
380 
381   typedef struct _TTransform  TTransform;
382   typedef TTransform         *PTransform;
383 
384   /* subglyph loading record.  Used to load composite components */
385   struct  _TSubglyph_Record
386   {
387     Int          index;        /* subglyph index           */
388     Bool         is_scaled;    /* is the subglyph scaled?  */
389     Bool         is_hinted;    /* should it be hinted?     */
390     Bool         preserve_pps; /* preserve phantom points? */
391 
392     Long         file_offset;
393 
394     TT_BBox      bbox;
395 
396     TGlyph_Zone  zone;
397 
398     Int          arg1;  /* first argument  */
399     Int          arg2;  /* second argument */
400 
401     Int          element_flag;    /* current load element flag */
402 
403     TTransform   transform;       /* transform */
404 
405     TT_Vector    pp1, pp2;        /* phantom points */
406 
407     Int          leftBearing;     /* in FUnits */
408     Int          advanceWidth;    /* in FUnits */
409   };
410 
411   typedef struct _TSubglyph_Record  TSubglyph_Record;
412   typedef TSubglyph_Record*         PSubglyph_Record;
413   typedef TSubglyph_Record*         PSubglyph_Stack;
414 
415   /* A note regarding non-squared pixels:                                */
416   /*                                                                     */
417   /* (This text will probably go into some docs at some time, for        */
418   /*  now, it is kept there to explain some definitions in the           */
419   /*  TIns_Metrics record).                                              */
420   /*                                                                     */
421   /* The CVT is a one-dimensional array containing values that           */
422   /* control certain important characteristics in a font, like           */
423   /* the height of all capitals, all lowercase letter, default           */
424   /* spacing or stem width/height.                                       */
425   /*                                                                     */
426   /* These values are found in FUnits in the font file, and must be      */
427   /* scaled to pixel coordinates before being used by the CVT and        */
428   /* glyph programs.  Unfortunately, when using distinct x and y         */
429   /* resolutions (or distinct x and y pointsizes), there are two         */
430   /* possible scalings.                                                  */
431   /*                                                                     */
432   /* A first try was to implement a 'lazy' scheme where all values       */
433   /* were scaled when first used.  However, while some values are always */
434   /* used in the same direction, and some other are used in many         */
435   /* different circumstances and orientations.                           */
436   /*                                                                     */
437   /* I have found a simpler way to do the same, and it even seems to     */
438   /* work in most of the cases:                                          */
439   /*                                                                     */
440   /* - all CVT values are scaled to the maximum ppem size                */
441   /*                                                                     */
442   /* - when performing a read or write in the CVT, a ratio factor        */
443   /*   is used to perform adequate scaling. Example:                     */
444   /*                                                                     */
445   /*    x_ppem = 14                                                      */
446   /*    y_ppem = 10                                                      */
447   /*                                                                     */
448   /*   we choose ppem = x_ppem = 14 as the CVT scaling size.  All cvt    */
449   /*   entries are scaled to it.                                         */
450   /*                                                                     */
451   /*    x_ratio = 1.0                                                    */
452   /*    y_ratio = y_ppem/ppem (< 1.0)                                    */
453   /*                                                                     */
454   /*   we compute the current ratio like:                                */
455   /*                                                                     */
456   /*     - if projVector is horizontal,                                  */
457   /*         ratio = x_ratio = 1.0                                       */
458   /*     - if projVector is vertical,                                    */
459   /*         ratop = y_ratio                                             */
460   /*     - else,                                                         */
461   /*         ratio = sqrt((proj.x*x_ratio)^2 + (proj.y*y_ratio)^2)       */
462   /*                                                                     */
463   /*   reading a cvt value returns      ratio * cvt[index]               */
464   /*   writing a cvt value in pixels    cvt[index] / ratio               */
465   /*                                                                     */
466   /*   the current ppem is simply       ratio * ppem                     */
467   /*                                                                     */
468 
469   /* metrics used by the instance and execution context objects */
470   struct  _TIns_Metrics
471   {
472     TT_F26Dot6  pointSize;      /* point size.  1 point = 1/72 inch. */
473 
474     Int         x_resolution;   /* device horizontal resolution in dpi. */
475     Int         y_resolution;   /* device vertical resolution in dpi.   */
476 
477     Int         x_ppem;         /* horizontal pixels per EM */
478     Int         y_ppem;         /* vertical pixels per EM   */
479 
480     Long        x_scale1;
481     Long        x_scale2;    /* used to scale FUnits to fractional pixels */
482 
483     Long        y_scale1;
484     Long        y_scale2;    /* used to scale FUnits to fractional pixels */
485 
486     /* for non-square pixels */
487     Long        x_ratio;
488     Long        y_ratio;
489 
490     Int         ppem;        /* maximum ppem size */
491     Long        ratio;       /* current ratio     */
492     Long        scale1;
493     Long        scale2;      /* scale for ppem */
494 
495     TT_F26Dot6  compensations[4];  /* device-specific compensations */
496 
497     Bool        rotated;        /* `is the glyph rotated?'-flag   */
498     Bool        stretched;      /* `is the glyph stretched?'-flag */
499   };
500 
501   typedef struct _TIns_Metrics  TIns_Metrics;
502   typedef TIns_Metrics         *PIns_Metrics;
503 
504 
505 
506   /***********************************************************************/
507   /*                                                                     */
508   /*                         FreeType Face Type                          */
509   /*                                                                     */
510   /***********************************************************************/
511 
512   struct  _TFace
513   {
514     ttfReader *r;
515     ttfFont *font;
516 
517     /* maximum profile table, as found in the TrueType file */
518     TMaxProfile  maxProfile;
519 
520     /* Note:                                          */
521     /*  it seems that some maximum values cannot be   */
522     /*  taken directly from this table, but rather by */
523     /*  combining some of its fields; e.g. the max.   */
524     /*  number of points seems to be given by         */
525     /*  MAX( maxPoints, maxCompositePoints )          */
526     /*                                                */
527     /*  For this reason, we define later our own      */
528     /*  max values that are used to load and allocate */
529     /*  further tables.                               */
530 
531     /* The glyph locations table */
532     Int       numLocations;
533 
534     /* The HMTX table data, used to compute both left */
535     /* side bearing and advance width for all glyphs  */
536 
537     /* the font program, if any */
538     Int    fontPgmSize;
539     PByte  fontProgram;
540 
541     /* the cvt program, if any */
542     Int    cvtPgmSize;
543     PByte  cvtProgram;
544 
545     /* the original, unscaled, control value table */
546     Int    cvtSize;
547     PShort cvt;
548 
549     /* The following values _must_ be set by the */
550     /* maximum profile loader                    */
551 
552     Int  numGlyphs;      /* the face's total number of glyphs */
553     Int  maxPoints;      /* max glyph points number, simple and composite */
554     Int  maxContours;    /* max glyph contours number, simple and composite */
555     Int  maxComponents;  /* max components in a composite glyph */
556 
557   };
558 
559 
560 
561   /***********************************************************************/
562   /*                                                                     */
563   /*                       FreeType Instance Type                        */
564   /*                                                                     */
565   /***********************************************************************/
566 
567   struct  _TInstance
568   {
569     PFace            face;     /* face object */
570 
571     Bool             valid;
572 
573     TIns_Metrics     metrics;
574 
575     Int              numFDefs;  /* number of function definitions */
576     PDefArray        FDefs;     /* table of FDefs entries         */
577 
578     Int              numIDefs;  /* number of instruction definitions */
579     PDefArray        IDefs;     /* table of IDefs entries            */
580     Int		     countIDefs;/* The number of defined IDefs (igorm). */
581     Byte	     IDefPtr[256]; /* Map opcodes to indices of IDefs (igorm). */
582 
583     TCodeRangeTable  codeRangeTable;
584 
585     TGraphicsState   GS;
586     TGraphicsState   default_GS;
587 
588     Int              cvtSize;   /* the scaled control value table */
589     PLong            cvt;
590 
591     Int              storeSize; /* The storage area is now part of the */
592     PStorage            storage;   /* instance                            */
593 
594   };
595 
596 
597   /***********************************************************************/
598   /*                                                                     */
599   /*                  FreeType Execution Context Type                    */
600   /*                                                                     */
601   /***********************************************************************/
602 
603   struct  _TExecution_Context
604   {
605     PFace           current_face;
606 
607     /* instructions state */
608 
609     Int             error;     /* last execution error */
610 
611     Int             curRange;  /* current code range number   */
612     PByte           code;      /* current code range          */
613     Int             IP;        /* current instruction pointer */
614     Int             codeSize;  /* size of current range       */
615 
616     Byte            opcode;    /* current opcode              */
617     Int             length;    /* length of current opcode    */
618 
619     Bool            step_ins;  /* true if the interpreter must */
620                                 /* increment IP after ins. exec */
621 
622     Int             numFDefs;  /* number of function defs */
623     PDefRecord      FDefs;     /* table of FDefs entries  */
624 
625     Int             numIDefs;  /* number of instruction defs */
626     PDefRecord      IDefs;     /* table of IDefs entries     */
627     Int		    countIDefs;/* The number of defined IDefs (igorm). */
628     Byte	    IDefPtr[256]; /* Map opcodes to indices of IDefs (igorm). */
629 
630     PByte           glyphIns;  /* glyph instructions buffer */
631     Int             glyphSize; /* glyph instructions buffer size */
632 
633     Int             callTop,    /* top of call stack during execution */
634                     callSize;   /* size of call stack */
635     PCallStack      callStack;  /* call stack */
636 
637     TCodeRangeTable codeRangeTable;  /* table of valid coderanges */
638                                      /* useful for the debugger   */
639 
640     Int             storeSize;  /* size of current storage */
641     PStorage        storage;    /* storage area            */
642 
643     Int             stackSize;  /* size of exec. stack */
644     Int             top;        /* top of exec. stack  */
645     PStorage        stack;      /* current exec. stack */
646 
647     Int             args,
648                     new_top;    /* new top after exec.    */
649 
650     TT_F26Dot6      period;     /* values used for the */
651     TT_F26Dot6      phase;      /* 'SuperRounding'     */
652     TT_F26Dot6      threshold;
653 
654     TIns_Metrics    metrics;       /* instance metrics */
655 
656     Int             cur_ppem;       /* ppem along the current proj vector */
657     Long            scale1;         /* scaling values along the current   */
658     Long            scale2;         /* projection vector too..            */
659     Bool            cached_metrics; /* the ppem is computed lazily. used  */
660                                     /* to trigger computation when needed */
661 
662     TGlyph_Zone     zp0,            /* zone records */
663                     zp1,
664                     zp2,
665                     pts,
666                     twilight;
667 
668     Bool            instruction_trap;  /* If True, the interpreter will */
669                                        /* exit after each instruction   */
670 
671     TGraphicsState  GS;            /* current graphics state */
672 
673     TGraphicsState  default_GS;    /* graphics state resulting from  */
674                                    /* the prep program               */
675     Bool            is_composite;  /* ture if the glyph is composite */
676 
677     Int             cvtSize;
678     PLong           cvt;
679 
680     /* latest interpreter additions */
681 
682     Long               F_dot_P;    /* dot product of freedom and projection */
683                                    /* vectors                               */
684     TRound_Function    func_round; /* current rounding function             */
685 
686     TProject_Function  func_project,   /* current projection function */
687                        func_dualproj,  /* current dual proj. function */
688                        func_freeProj;  /* current freedom proj. func  */
689 
690     TMove_Function     func_move;      /* current point move function */
691 
692     TGet_CVT_Function  func_read_cvt;  /* read a cvt entry              */
693     TSet_CVT_Function  func_write_cvt; /* write a cvt entry (in pixels) */
694     TSet_CVT_Function  func_move_cvt;  /* incr a cvt entry (in pixels)  */
695     /* GS extension */
696     jmp_buf            trap;           /* Error throw trap. */
697     Int                n_contours;
698     Int                n_points;
699     Int                maxGlyphSize;
700     Int                lock;
701   };
702 
703 
704   /********************************************************************/
705   /*                                                                  */
706   /*   Code Range Functions                                           */
707   /*                                                                  */
708   /********************************************************************/
709 
710   /* Goto a specified coderange */
711   TT_Error  Goto_CodeRange( PExecution_Context  exec, Int  range, Int  IP );
712   /* Unset the coderange */
713   void  Unset_CodeRange( PExecution_Context  exec );
714 
715   /* Return a pointer to a given coderange record. */
716   /* Used only by the debugger.                    */
717   PCodeRange  Get_CodeRange( PExecution_Context  exec, Int  range );
718 
719   /* Set a given code range properties */
720   TT_Error  Set_CodeRange( PExecution_Context  exec,
721                            Int                 range,
722                            void*               base,
723                            Int                 length );
724 
725   /* Clear a given coderange */
726   TT_Error  Clear_CodeRange( PExecution_Context  exec, Int  range );
727 
728 
729   PExecution_Context  New_Context( PFace  face );
730 
731   TT_Error  Done_Context( PExecution_Context  exec );
732 
733 
734   TT_Error  Context_Load( PExecution_Context  exec,
735                           PInstance           ins );
736 
737   TT_Error  Context_Save( PExecution_Context  exec,
738                           PInstance           ins );
739 
740   TT_Error  Context_Run( PExecution_Context  exec,
741                          Bool                debug );
742 
743   TT_Error  Instance_Init( PInstance  ins );
744 
745   TT_Error  Instance_Reset( PInstance  ins,
746                             Bool       debug );
747 
748   TT_Error  Instance_Create( void*  _instance,
749                              void*  _face );
750 
751   TT_Error  Instance_Destroy( void* _instance );
752 
753   TT_Error  Context_Destroy( void*  _context );
754 
755   TT_Error  Context_Create( void*  _context, void*  _face );
756 
757   /********************************************************************/
758   /*                                                                  */
759   /*   Handy scaling functions                                        */
760   /*                                                                  */
761   /********************************************************************/
762 
763   TT_Pos   Scale_X( PIns_Metrics  metrics, TT_Pos  x );
764   TT_Pos   Scale_Y( PIns_Metrics  metrics, TT_Pos  y );
765 
766   /********************************************************************/
767   /*                                                                  */
768   /*   Component Initializer/Finalizer                                */
769   /*                                                                  */
770   /*   Called from 'freetype.c'                                       */
771   /*   The component must create and register the face, instance and  */
772   /*   execution context cache classes before any object can be       */
773   /*   managed.                                                       */
774   /*                                                                  */
775   /********************************************************************/
776 
777 TT_Error  Face_Create( PFace  _face);
778 TT_Error  Face_Destroy( PFace  _face);
779 
780 #ifdef __cplusplus
781   }
782 #endif
783 
784 #endif /* TTOBJS_H */
785 
786 
787 /* END */
788