ttobjs.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:20k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*  ttobjs.h                                                               */
  4. /*                                                                         */
  5. /*    Objects manager (specification).                                     */
  6. /*                                                                         */
  7. /*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 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. #ifndef __TTOBJS_H__
  18. #define __TTOBJS_H__
  19. #include <ft2build.h>
  20. #include FT_INTERNAL_OBJECTS_H
  21. #include FT_INTERNAL_TRUETYPE_TYPES_H
  22. FT_BEGIN_HEADER
  23.   /*************************************************************************/
  24.   /*                                                                       */
  25.   /* <Type>                                                                */
  26.   /*    TT_Driver                                                          */
  27.   /*                                                                       */
  28.   /* <Description>                                                         */
  29.   /*    A handle to a TrueType driver object.                              */
  30.   /*                                                                       */
  31.   typedef struct TT_DriverRec_*  TT_Driver;
  32.   /*************************************************************************/
  33.   /*                                                                       */
  34.   /* <Type>                                                                */
  35.   /*    TT_Instance                                                        */
  36.   /*                                                                       */
  37.   /* <Description>                                                         */
  38.   /*    A handle to a TrueType size object.                                */
  39.   /*                                                                       */
  40.   typedef struct TT_SizeRec_*  TT_Size;
  41.   /*************************************************************************/
  42.   /*                                                                       */
  43.   /* <Type>                                                                */
  44.   /*    TT_GlyphSlot                                                       */
  45.   /*                                                                       */
  46.   /* <Description>                                                         */
  47.   /*    A handle to a TrueType glyph slot object.                          */
  48.   /*                                                                       */
  49.   /* <Note>                                                                */
  50.   /*    This is a direct typedef of FT_GlyphSlot, as there is nothing      */
  51.   /*    specific about the TrueType glyph slot.                            */
  52.   /*                                                                       */
  53.   typedef FT_GlyphSlot  TT_GlyphSlot;
  54.   /*************************************************************************/
  55.   /*                                                                       */
  56.   /* <Struct>                                                              */
  57.   /*    TT_GraphicsState                                                   */
  58.   /*                                                                       */
  59.   /* <Description>                                                         */
  60.   /*    The TrueType graphics state used during bytecode interpretation.   */
  61.   /*                                                                       */
  62.   typedef struct  TT_GraphicsState_
  63.   {
  64.     FT_UShort      rp0;
  65.     FT_UShort      rp1;
  66.     FT_UShort      rp2;
  67.     FT_UnitVector  dualVector;
  68.     FT_UnitVector  projVector;
  69.     FT_UnitVector  freeVector;
  70. #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
  71.     FT_Bool        both_x_axis;
  72. #endif
  73.     FT_Long        loop;
  74.     FT_F26Dot6     minimum_distance;
  75.     FT_Int         round_state;
  76.     FT_Bool        auto_flip;
  77.     FT_F26Dot6     control_value_cutin;
  78.     FT_F26Dot6     single_width_cutin;
  79.     FT_F26Dot6     single_width_value;
  80.     FT_Short       delta_base;
  81.     FT_Short       delta_shift;
  82.     FT_Byte        instruct_control;
  83.     FT_Bool        scan_control;
  84.     FT_Int         scan_type;
  85.     FT_UShort      gep0;
  86.     FT_UShort      gep1;
  87.     FT_UShort      gep2;
  88.   } TT_GraphicsState;
  89. #ifdef TT_USE_BYTECODE_INTERPRETER
  90.   FT_LOCAL( void )
  91.   tt_glyphzone_done( TT_GlyphZone  zone );
  92.   FT_LOCAL( FT_Error )
  93.   tt_glyphzone_new( FT_Memory     memory,
  94.                     FT_UShort     maxPoints,
  95.                     FT_Short      maxContours,
  96.                     TT_GlyphZone  zone );
  97. #endif /* TT_USE_BYTECODE_INTERPRETER */
  98.   /*************************************************************************/
  99.   /*                                                                       */
  100.   /*  EXECUTION SUBTABLES                                                  */
  101.   /*                                                                       */
  102.   /*  These sub-tables relate to instruction execution.                    */
  103.   /*                                                                       */
  104.   /*************************************************************************/
  105. #define TT_MAX_CODE_RANGES  3
  106.   /*************************************************************************/
  107.   /*                                                                       */
  108.   /* There can only be 3 active code ranges at once:                       */
  109.   /*   - the Font Program                                                  */
  110.   /*   - the CVT Program                                                   */
  111.   /*   - a glyph's instructions set                                        */
  112.   /*                                                                       */
  113.   typedef enum  TT_CodeRange_Tag_
  114.   {
  115.     tt_coderange_none = 0,
  116.     tt_coderange_font,
  117.     tt_coderange_cvt,
  118.     tt_coderange_glyph
  119.   } TT_CodeRange_Tag;
  120.   typedef struct  TT_CodeRange_
  121.   {
  122.     FT_Byte*  base;
  123.     FT_ULong  size;
  124.   } TT_CodeRange;
  125.   typedef TT_CodeRange  TT_CodeRangeTable[TT_MAX_CODE_RANGES];
  126.   /*************************************************************************/
  127.   /*                                                                       */
  128.   /* Defines a function/instruction definition record.                     */
  129.   /*                                                                       */
  130.   typedef struct  TT_DefRecord_
  131.   {
  132.     FT_Int   range;      /* in which code range is it located? */
  133.     FT_Long  start;      /* where does it start?               */
  134.     FT_UInt  opc;        /* function #, or instruction code    */
  135.     FT_Bool  active;     /* is it active?                      */
  136.   } TT_DefRecord, *TT_DefArray;
  137.   /*************************************************************************/
  138.   /*                                                                       */
  139.   /* Subglyph transformation record.                                       */
  140.   /*                                                                       */
  141.   typedef struct  TT_Transform_
  142.   {
  143.     FT_Fixed    xx, xy;     /* transformation matrix coefficients */
  144.     FT_Fixed    yx, yy;
  145.     FT_F26Dot6  ox, oy;     /* offsets        */
  146.   } TT_Transform;
  147.   /*************************************************************************/
  148.   /*                                                                       */
  149.   /* Subglyph loading record.  Used to load composite components.          */
  150.   /*                                                                       */
  151.   typedef struct  TT_SubglyphRec_
  152.   {
  153.     FT_Long          index;        /* subglyph index; initialized with -1 */
  154.     FT_Bool          is_scaled;    /* is the subglyph scaled?             */
  155.     FT_Bool          is_hinted;    /* should it be hinted?                */
  156.     FT_Bool          preserve_pps; /* preserve phantom points?            */
  157.     FT_Long          file_offset;
  158.     FT_BBox          bbox;
  159.     FT_Pos           left_bearing;
  160.     FT_Pos           advance;
  161.     TT_GlyphZoneRec  zone;
  162.     FT_Long          arg1;         /* first argument                      */
  163.     FT_Long          arg2;         /* second argument                     */
  164.     FT_UShort        element_flag; /* current load element flag           */
  165.     TT_Transform     transform;    /* transformation matrix               */
  166.     FT_Vector        pp1, pp2;     /* phantom points (horizontal)         */
  167.     FT_Vector        pp3, pp4;     /* phantom points (vertical)           */
  168.   } TT_SubGlyphRec, *TT_SubGlyph_Stack;
  169.   /*************************************************************************/
  170.   /*                                                                       */
  171.   /* A note regarding non-squared pixels:                                  */
  172.   /*                                                                       */
  173.   /* (This text will probably go into some docs at some time; for now, it  */
  174.   /*  is kept here to explain some definitions in the TIns_Metrics         */
  175.   /*  record).                                                             */
  176.   /*                                                                       */
  177.   /* The CVT is a one-dimensional array containing values that control     */
  178.   /* certain important characteristics in a font, like the height of all   */
  179.   /* capitals, all lowercase letter, default spacing or stem width/height. */
  180.   /*                                                                       */
  181.   /* These values are found in FUnits in the font file, and must be scaled */
  182.   /* to pixel coordinates before being used by the CVT and glyph programs. */
  183.   /* Unfortunately, when using distinct x and y resolutions (or distinct x */
  184.   /* and y pointsizes), there are two possible scalings.                   */
  185.   /*                                                                       */
  186.   /* A first try was to implement a `lazy' scheme where all values were    */
  187.   /* scaled when first used.  However, while some values are always used   */
  188.   /* in the same direction, some others are used under many different      */
  189.   /* circumstances and orientations.                                       */
  190.   /*                                                                       */
  191.   /* I have found a simpler way to do the same, and it even seems to work  */
  192.   /* in most of the cases:                                                 */
  193.   /*                                                                       */
  194.   /* - All CVT values are scaled to the maximum ppem size.                 */
  195.   /*                                                                       */
  196.   /* - When performing a read or write in the CVT, a ratio factor is used  */
  197.   /*   to perform adequate scaling.  Example:                              */
  198.   /*                                                                       */
  199.   /*     x_ppem = 14                                                       */
  200.   /*     y_ppem = 10                                                       */
  201.   /*                                                                       */
  202.   /*   We choose ppem = x_ppem = 14 as the CVT scaling size.  All cvt      */
  203.   /*   entries are scaled to it.                                           */
  204.   /*                                                                       */
  205.   /*     x_ratio = 1.0                                                     */
  206.   /*     y_ratio = y_ppem/ppem (< 1.0)                                     */
  207.   /*                                                                       */
  208.   /*   We compute the current ratio like:                                  */
  209.   /*                                                                       */
  210.   /*   - If projVector is horizontal,                                      */
  211.   /*       ratio = x_ratio = 1.0                                           */
  212.   /*                                                                       */
  213.   /*   - if projVector is vertical,                                        */
  214.   /*       ratio = y_ratio                                                 */
  215.   /*                                                                       */
  216.   /*   - else,                                                             */
  217.   /*       ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
  218.   /*                                                                       */
  219.   /*   Reading a cvt value returns                                         */
  220.   /*     ratio * cvt[index]                                                */
  221.   /*                                                                       */
  222.   /*   Writing a cvt value in pixels:                                      */
  223.   /*     cvt[index] / ratio                                                */
  224.   /*                                                                       */
  225.   /*   The current ppem is simply                                          */
  226.   /*     ratio * ppem                                                      */
  227.   /*                                                                       */
  228.   /*************************************************************************/
  229.   /*************************************************************************/
  230.   /*                                                                       */
  231.   /* Metrics used by the TrueType size and context objects.                */
  232.   /*                                                                       */
  233.   typedef struct  TT_Size_Metrics_
  234.   {
  235.     /* for non-square pixels */
  236.     FT_Long     x_ratio;
  237.     FT_Long     y_ratio;
  238.     FT_UShort   ppem;               /* maximum ppem size              */
  239.     FT_Long     ratio;              /* current ratio                  */
  240.     FT_Fixed    scale;
  241.     FT_F26Dot6  compensations[4];   /* device-specific compensations  */
  242.     FT_Bool     valid;
  243.     FT_Bool     rotated;            /* `is the glyph rotated?'-flag   */
  244.     FT_Bool     stretched;          /* `is the glyph stretched?'-flag */
  245.   } TT_Size_Metrics;
  246.   /*************************************************************************/
  247.   /*                                                                       */
  248.   /* TrueType size class.                                                  */
  249.   /*                                                                       */
  250.   typedef struct  TT_SizeRec_
  251.   {
  252.     FT_SizeRec         root;
  253.     /* we have our own copy of metrics so that we can modify */
  254.     /* it without affecting auto-hinting (when used)         */
  255.     FT_Size_Metrics    metrics;
  256.     TT_Size_Metrics    ttmetrics;
  257.     FT_ULong           strike_index;      /* 0xFFFFFFFF to indicate invalid */
  258. #ifdef TT_USE_BYTECODE_INTERPRETER
  259.     FT_UInt            num_function_defs; /* number of function definitions */
  260.     FT_UInt            max_function_defs;
  261.     TT_DefArray        function_defs;     /* table of function definitions  */
  262.     FT_UInt            num_instruction_defs;  /* number of ins. definitions */
  263.     FT_UInt            max_instruction_defs;
  264.     TT_DefArray        instruction_defs;      /* table of ins. definitions  */
  265.     FT_UInt            max_func;
  266.     FT_UInt            max_ins;
  267.     TT_CodeRangeTable  codeRangeTable;
  268.     TT_GraphicsState   GS;
  269.     FT_ULong           cvt_size;      /* the scaled control value table */
  270.     FT_Long*           cvt;
  271.     FT_UShort          storage_size; /* The storage area is now part of */
  272.     FT_Long*           storage;      /* the instance                    */
  273.     TT_GlyphZoneRec    twilight;     /* The instance's twilight zone    */
  274.     /* debugging variables */
  275.     /* When using the debugger, we must keep the */
  276.     /* execution context tied to the instance    */
  277.     /* object rather than asking it on demand.   */
  278.     FT_Bool            debug;
  279.     TT_ExecContext     context;
  280.     FT_Bool            bytecode_ready;
  281.     FT_Bool            cvt_ready;
  282. #endif /* TT_USE_BYTECODE_INTERPRETER */
  283.   } TT_SizeRec;
  284.   /*************************************************************************/
  285.   /*                                                                       */
  286.   /* TrueType driver class.                                                */
  287.   /*                                                                       */
  288.   typedef struct  TT_DriverRec_
  289.   {
  290.     FT_DriverRec     root;
  291.     TT_ExecContext   context;  /* execution context        */
  292.     TT_GlyphZoneRec  zone;     /* glyph loader points zone */
  293.     void*            extension_component;
  294.   } TT_DriverRec;
  295.   /* Note: All of the functions below (except tt_size_reset()) are used    */
  296.   /* as function pointers in a FT_Driver_ClassRec.  Therefore their        */
  297.   /* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face,  */
  298.   /* TT_Size, etc., so that the compiler can confirm that the types and    */
  299.   /* number of parameters are correct.  In all cases the FT_xxx types are  */
  300.   /* cast to their TT_xxx counterparts inside the functions since FreeType */
  301.   /* will always use the TT driver to create them.                         */
  302.   /*************************************************************************/
  303.   /*                                                                       */
  304.   /* Face functions                                                        */
  305.   /*                                                                       */
  306.   FT_LOCAL( FT_Error )
  307.   tt_face_init( FT_Stream      stream,
  308.                 FT_Face        ttface,      /* TT_Face */
  309.                 FT_Int         face_index,
  310.                 FT_Int         num_params,
  311.                 FT_Parameter*  params );
  312.   FT_LOCAL( void )
  313.   tt_face_done( FT_Face  ttface );          /* TT_Face */
  314.   /*************************************************************************/
  315.   /*                                                                       */
  316.   /* Size functions                                                        */
  317.   /*                                                                       */
  318.   FT_LOCAL( FT_Error )
  319.   tt_size_init( FT_Size  ttsize );          /* TT_Size */
  320.   FT_LOCAL( void )
  321.   tt_size_done( FT_Size  ttsize );          /* TT_Size */
  322. #ifdef TT_USE_BYTECODE_INTERPRETER
  323.   FT_LOCAL( FT_Error )
  324.   tt_size_run_fpgm( TT_Size  size );
  325.   FT_LOCAL( FT_Error )
  326.   tt_size_run_prep( TT_Size  size );
  327.   FT_LOCAL( FT_Error )
  328.   tt_size_ready_bytecode( TT_Size  size );
  329. #endif /* TT_USE_BYTECODE_INTERPRETER */
  330.   FT_LOCAL( FT_Error )
  331.   tt_size_reset( TT_Size  size );
  332.   /*************************************************************************/
  333.   /*                                                                       */
  334.   /* Driver functions                                                      */
  335.   /*                                                                       */
  336.   FT_LOCAL( FT_Error )
  337.   tt_driver_init( FT_Module  ttdriver );    /* TT_Driver */
  338.   FT_LOCAL( void )
  339.   tt_driver_done( FT_Module  ttdriver );    /* TT_Driver */
  340.   /*************************************************************************/
  341.   /*                                                                       */
  342.   /* Slot functions                                                        */
  343.   /*                                                                       */
  344.   FT_LOCAL( FT_Error )
  345.   tt_slot_init( FT_GlyphSlot  slot );
  346. FT_END_HEADER
  347. #endif /* __TTOBJS_H__ */
  348. /* END */