update for HEAD-2003050101
[reactos.git] / lib / freetype / src / cff / cffgload.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  cffgload.h                                                             */
4 /*                                                                         */
5 /*    OpenType Glyph Loader (specification).                               */
6 /*                                                                         */
7 /*  Copyright 1996-2001, 2002 by                                           */
8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9 /*                                                                         */
10 /*  This file is part of the FreeType project, and may only be used,       */
11 /*  modified, and distributed under the terms of the FreeType project      */
12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13 /*  this file you indicate that you have read the license and              */
14 /*  understand and accept it fully.                                        */
15 /*                                                                         */
16 /***************************************************************************/
17
18
19 #ifndef __CFFGLOAD_H__
20 #define __CFFGLOAD_H__
21
22
23 #include <ft2build.h>
24 #include FT_FREETYPE_H
25 #include "cffobjs.h"
26
27
28 FT_BEGIN_HEADER
29
30
31 #define CFF_MAX_OPERANDS     48
32 #define CFF_MAX_SUBRS_CALLS  32
33
34
35   /*************************************************************************/
36   /*                                                                       */
37   /* <Structure>                                                           */
38   /*    CFF_Builder                                                        */
39   /*                                                                       */
40   /* <Description>                                                         */
41   /*     A structure used during glyph loading to store its outline.       */
42   /*                                                                       */
43   /* <Fields>                                                              */
44   /*    memory        :: The current memory object.                        */
45   /*                                                                       */
46   /*    face          :: The current face object.                          */
47   /*                                                                       */
48   /*    glyph         :: The current glyph slot.                           */
49   /*                                                                       */
50   /*    loader        :: The current glyph loader.                         */
51   /*                                                                       */
52   /*    base          :: The base glyph outline.                           */
53   /*                                                                       */
54   /*    current       :: The current glyph outline.                        */
55   /*                                                                       */
56   /*    last          :: The last point position.                          */
57   /*                                                                       */
58   /*    scale_x       :: The horizontal scale (FUnits to sub-pixels).      */
59   /*                                                                       */
60   /*    scale_y       :: The vertical scale (FUnits to sub-pixels).        */
61   /*                                                                       */
62   /*    pos_x         :: The horizontal translation (if composite glyph).  */
63   /*                                                                       */
64   /*    pos_y         :: The vertical translation (if composite glyph).    */
65   /*                                                                       */
66   /*    left_bearing  :: The left side bearing point.                      */
67   /*                                                                       */
68   /*    advance       :: The horizontal advance vector.                    */
69   /*                                                                       */
70   /*    bbox          :: Unused.                                           */
71   /*                                                                       */
72   /*    path_begun    :: A flag which indicates that a new path has begun. */
73   /*                                                                       */
74   /*    load_points   :: If this flag is not set, no points are loaded.    */
75   /*                                                                       */
76   /*    no_recurse    :: Set but not used.                                 */
77   /*                                                                       */
78   /*    error         :: An error code that is only used to report memory  */
79   /*                     allocation problems.                              */
80   /*                                                                       */
81   /*    metrics_only  :: A boolean indicating that we only want to compute */
82   /*                     the metrics of a given glyph, not load all of its */
83   /*                     points.                                           */
84   /*                                                                       */
85   /*    hints_funcs   :: Auxiliary pointer for hinting.                    */
86   /*                                                                       */
87   /*    hints_globals :: Auxiliary pointer for hinting.                    */
88   /*                                                                       */
89   typedef struct  CFF_Builder_
90   {
91     FT_Memory       memory;
92     TT_Face         face;
93     CFF_GlyphSlot   glyph;
94     FT_GlyphLoader  loader;
95     FT_Outline*     base;
96     FT_Outline*     current;
97
98     FT_Vector       last;
99
100     FT_Fixed        scale_x;
101     FT_Fixed        scale_y;
102
103     FT_Pos          pos_x;
104     FT_Pos          pos_y;
105
106     FT_Vector       left_bearing;
107     FT_Vector       advance;
108
109     FT_BBox         bbox;          /* bounding box */
110     FT_Bool         path_begun;
111     FT_Bool         load_points;
112     FT_Bool         no_recurse;
113
114     FT_Error        error;         /* only used for memory errors */
115     FT_Bool         metrics_only;
116
117     FT_UInt32       hint_flags;
118
119     void*           hints_funcs;    /* hinter-specific */
120     void*           hints_globals;  /* hinter-specific */
121
122   } CFF_Builder;
123
124
125   /* execution context charstring zone */
126
127   typedef struct  CFF_Decoder_Zone_
128   {
129     FT_Byte*  base;
130     FT_Byte*  limit;
131     FT_Byte*  cursor;
132
133   } CFF_Decoder_Zone;
134
135
136   typedef struct  CFF_Decoder_
137   {
138     CFF_Builder        builder;
139     CFF_Font           cff;
140
141     FT_Fixed           stack[CFF_MAX_OPERANDS + 1];
142     FT_Fixed*          top;
143
144     CFF_Decoder_Zone   zones[CFF_MAX_SUBRS_CALLS + 1];
145     CFF_Decoder_Zone*  zone;
146
147     FT_Int             flex_state;
148     FT_Int             num_flex_vectors;
149     FT_Vector          flex_vectors[7];
150
151     FT_Pos             glyph_width;
152     FT_Pos             nominal_width;
153
154     FT_Bool            read_width;
155     FT_Int             num_hints;
156     FT_Fixed*          buildchar;
157     FT_Int             len_buildchar;
158
159     FT_UInt            num_locals;
160     FT_UInt            num_globals;
161
162     FT_Int             locals_bias;
163     FT_Int             globals_bias;
164
165     FT_Byte**          locals;
166     FT_Byte**          globals;
167
168     FT_Byte**          glyph_names;   /* for pure CFF fonts only  */
169     FT_UInt            num_glyphs;    /* number of glyphs in font */
170
171     FT_Render_Mode     hint_mode;
172
173   } CFF_Decoder;
174
175
176   FT_LOCAL( void )
177   cff_decoder_init( CFF_Decoder*    decoder,
178                     TT_Face         face,
179                     CFF_Size        size,
180                     CFF_GlyphSlot   slot,
181                     FT_Bool         hinting,
182                     FT_Render_Mode  hint_mode );
183
184   FT_LOCAL( void )
185   cff_decoder_prepare( CFF_Decoder*  decoder,
186                        FT_UInt       glyph_index );
187
188 #if 0  /* unused until we support pure CFF fonts */
189
190   /* Compute the maximum advance width of a font through quick parsing */
191   FT_LOCAL( FT_Error )
192   cff_compute_max_advance( TT_Face  face,
193                            FT_Int*  max_advance );
194
195 #endif /* 0 */
196
197   FT_LOCAL( FT_Error )
198   cff_decoder_parse_charstrings( CFF_Decoder*  decoder,
199                                  FT_Byte*      charstring_base,
200                                  FT_ULong      charstring_len );
201
202   FT_LOCAL( FT_Error )
203   cff_slot_load( CFF_GlyphSlot  glyph,
204                  CFF_Size       size,
205                  FT_Int         glyph_index,
206                  FT_Int32       load_flags );
207
208
209 FT_END_HEADER
210
211 #endif /* __CFFGLOAD_H__ */
212
213
214 /* END */