Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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