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