~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/ttobjs.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

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