• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************/
2 /*                                                                         */
3 /*  cffgload.h                                                             */
4 /*                                                                         */
5 /*    OpenType Glyph Loader (specification).                               */
6 /*                                                                         */
7 /*  Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 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 #define CFF_MAX_TRANS_ELEMENTS  32
34 
35 
36   /*************************************************************************/
37   /*                                                                       */
38   /* <Structure>                                                           */
39   /*    CFF_Builder                                                        */
40   /*                                                                       */
41   /* <Description>                                                         */
42   /*     A structure used during glyph loading to store its outline.       */
43   /*                                                                       */
44   /* <Fields>                                                              */
45   /*    memory        :: The current memory object.                        */
46   /*                                                                       */
47   /*    face          :: The current face object.                          */
48   /*                                                                       */
49   /*    glyph         :: The current glyph slot.                           */
50   /*                                                                       */
51   /*    loader        :: The current glyph loader.                         */
52   /*                                                                       */
53   /*    base          :: The base glyph outline.                           */
54   /*                                                                       */
55   /*    current       :: The current glyph outline.                        */
56   /*                                                                       */
57   /*    pos_x         :: The horizontal translation (if composite glyph).  */
58   /*                                                                       */
59   /*    pos_y         :: The vertical translation (if composite glyph).    */
60   /*                                                                       */
61   /*    left_bearing  :: The left side bearing point.                      */
62   /*                                                                       */
63   /*    advance       :: The horizontal advance vector.                    */
64   /*                                                                       */
65   /*    bbox          :: Unused.                                           */
66   /*                                                                       */
67   /*    path_begun    :: A flag which indicates that a new path has begun. */
68   /*                                                                       */
69   /*    load_points   :: If this flag is not set, no points are loaded.    */
70   /*                                                                       */
71   /*    no_recurse    :: Set but not used.                                 */
72   /*                                                                       */
73   /*    metrics_only  :: A boolean indicating that we only want to compute */
74   /*                     the metrics of a given glyph, not load all of its */
75   /*                     points.                                           */
76   /*                                                                       */
77   /*    hints_funcs   :: Auxiliary pointer for hinting.                    */
78   /*                                                                       */
79   /*    hints_globals :: Auxiliary pointer for hinting.                    */
80   /*                                                                       */
81   typedef struct  CFF_Builder_
82   {
83     FT_Memory       memory;
84     TT_Face         face;
85     CFF_GlyphSlot   glyph;
86     FT_GlyphLoader  loader;
87     FT_Outline*     base;
88     FT_Outline*     current;
89 
90     FT_Pos          pos_x;
91     FT_Pos          pos_y;
92 
93     FT_Vector       left_bearing;
94     FT_Vector       advance;
95 
96     FT_BBox         bbox;          /* bounding box */
97     FT_Bool         path_begun;
98     FT_Bool         load_points;
99     FT_Bool         no_recurse;
100 
101     FT_Bool         metrics_only;
102 
103     void*           hints_funcs;    /* hinter-specific */
104     void*           hints_globals;  /* hinter-specific */
105 
106   } CFF_Builder;
107 
108 
109   /* execution context charstring zone */
110 
111   typedef struct  CFF_Decoder_Zone_
112   {
113     FT_Byte*  base;
114     FT_Byte*  limit;
115     FT_Byte*  cursor;
116 
117   } CFF_Decoder_Zone;
118 
119 
120   typedef struct  CFF_Decoder_
121   {
122     CFF_Builder        builder;
123     CFF_Font           cff;
124 
125     FT_Fixed           stack[CFF_MAX_OPERANDS + 1];
126     FT_Fixed*          top;
127 
128     CFF_Decoder_Zone   zones[CFF_MAX_SUBRS_CALLS + 1];
129     CFF_Decoder_Zone*  zone;
130 
131     FT_Int             flex_state;
132     FT_Int             num_flex_vectors;
133     FT_Vector          flex_vectors[7];
134 
135     FT_Pos             glyph_width;
136     FT_Pos             nominal_width;
137 
138     FT_Bool            read_width;
139     FT_Bool            width_only;
140     FT_Int             num_hints;
141     FT_Fixed           buildchar[CFF_MAX_TRANS_ELEMENTS];
142 
143     FT_UInt            num_locals;
144     FT_UInt            num_globals;
145 
146     FT_Int             locals_bias;
147     FT_Int             globals_bias;
148 
149     FT_Byte**          locals;
150     FT_Byte**          globals;
151 
152     FT_Byte**          glyph_names;   /* for pure CFF fonts only  */
153     FT_UInt            num_glyphs;    /* number of glyphs in font */
154 
155     FT_Render_Mode     hint_mode;
156 
157     FT_Bool            seac;
158 
159   } CFF_Decoder;
160 
161 
162   FT_LOCAL( void )
163   cff_decoder_init( CFF_Decoder*    decoder,
164                     TT_Face         face,
165                     CFF_Size        size,
166                     CFF_GlyphSlot   slot,
167                     FT_Bool         hinting,
168                     FT_Render_Mode  hint_mode );
169 
170   FT_LOCAL( FT_Error )
171   cff_decoder_prepare( CFF_Decoder*  decoder,
172                        CFF_Size      size,
173                        FT_UInt       glyph_index );
174 
175 #if 0  /* unused until we support pure CFF fonts */
176 
177   /* Compute the maximum advance width of a font through quick parsing */
178   FT_LOCAL( FT_Error )
179   cff_compute_max_advance( TT_Face  face,
180                            FT_Int*  max_advance );
181 
182 #endif /* 0 */
183 
184   FT_LOCAL( FT_Error )
185   cff_decoder_parse_charstrings( CFF_Decoder*  decoder,
186                                  FT_Byte*      charstring_base,
187                                  FT_ULong      charstring_len );
188 
189   FT_LOCAL( FT_Error )
190   cff_slot_load( CFF_GlyphSlot  glyph,
191                  CFF_Size       size,
192                  FT_UInt        glyph_index,
193                  FT_Int32       load_flags );
194 
195 
196 FT_END_HEADER
197 
198 #endif /* __CFFGLOAD_H__ */
199 
200 
201 /* END */
202