blob: 988ff4d23c2f83c58b212042e6af328e441001fb [file] [log] [blame]
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +00001/***************************************************************************/
2/* */
3/* cffgload.h */
4/* */
5/* OpenType Glyph Loader (specification). */
6/* */
7/* Copyright 1996-2000 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
David Turner8d3a4012001-03-20 11:14:24 +000025#include "cffobjs.h"
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +000026
27
28FT_BEGIN_HEADER
29
30
31#define CFF_MAX_OPERANDS 48
32#define CFF_MAX_SUBRS_CALLS 32
33
34
35 /*************************************************************************/
36 /* */
37 /* <Structure> */
Werner Lembergd573c7e2001-01-03 07:14:12 +000038 /* CFF_Builder */
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +000039 /* */
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 /* current :: The current glyph outline. */
51 /* */
52 /* base :: The base glyph outline. */
53 /* */
54 /* max_points :: maximum points in builder outline */
55 /* */
56 /* max_contours :: Maximal number of contours in builder outline. */
57 /* */
58 /* last :: The last point position. */
59 /* */
60 /* scale_x :: The horizontal scale (FUnits to sub-pixels). */
61 /* */
62 /* scale_y :: The vertical scale (FUnits to sub-pixels). */
63 /* */
64 /* pos_x :: The horizontal translation (if composite glyph). */
65 /* */
66 /* pos_y :: The vertical translation (if composite glyph). */
67 /* */
68 /* left_bearing :: The left side bearing point. */
69 /* */
70 /* advance :: The horizontal advance vector. */
71 /* */
72 /* bbox :: Unused. */
73 /* */
74 /* path_begun :: A flag which indicates that a new path has begun. */
75 /* */
76 /* load_points :: If this flag is not set, no points are loaded. */
77 /* */
78 /* no_recurse :: Set but not used. */
79 /* */
80 /* error :: An error code that is only used to report memory */
81 /* allocation problems. */
82 /* */
83 /* metrics_only :: A boolean indicating that we only want to compute */
84 /* the metrics of a given glyph, not load all of its */
85 /* points. */
86 /* */
87 typedef struct CFF_Builder_
88 {
Werner Lembergd573c7e2001-01-03 07:14:12 +000089 FT_Memory memory;
90 TT_Face face;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +000091 CFF_GlyphSlot glyph;
Werner Lembergd573c7e2001-01-03 07:14:12 +000092 FT_GlyphLoader* loader;
93 FT_Outline* base;
94 FT_Outline* current;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +000095
Werner Lembergd573c7e2001-01-03 07:14:12 +000096 FT_Vector last;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +000097
Werner Lembergd573c7e2001-01-03 07:14:12 +000098 FT_Fixed scale_x;
99 FT_Fixed scale_y;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000100
Werner Lembergd573c7e2001-01-03 07:14:12 +0000101 FT_Pos pos_x;
102 FT_Pos pos_y;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000103
Werner Lembergd573c7e2001-01-03 07:14:12 +0000104 FT_Vector left_bearing;
105 FT_Vector advance;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000106
Werner Lembergd573c7e2001-01-03 07:14:12 +0000107 FT_BBox bbox; /* bounding box */
108 FT_Bool path_begun;
109 FT_Bool load_points;
110 FT_Bool no_recurse;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000111
Werner Lembergd573c7e2001-01-03 07:14:12 +0000112 FT_Error error; /* only used for memory errors */
113 FT_Bool metrics_only;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000114
115 } CFF_Builder;
116
117
118 /* execution context charstring zone */
119
120 typedef struct CFF_Decoder_Zone_
121 {
122 FT_Byte* base;
123 FT_Byte* limit;
124 FT_Byte* cursor;
125
126 } CFF_Decoder_Zone;
127
128
129 typedef struct CFF_Decoder_
130 {
131 CFF_Builder builder;
Werner Lembergd573c7e2001-01-03 07:14:12 +0000132 CFF_Font* cff;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000133
Werner Lembergd573c7e2001-01-03 07:14:12 +0000134 FT_Fixed stack[CFF_MAX_OPERANDS + 1];
135 FT_Fixed* top;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000136
137 CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1];
138 CFF_Decoder_Zone* zone;
139
Werner Lembergd573c7e2001-01-03 07:14:12 +0000140 FT_Int flex_state;
141 FT_Int num_flex_vectors;
142 FT_Vector flex_vectors[7];
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000143
Werner Lembergd573c7e2001-01-03 07:14:12 +0000144 FT_Pos glyph_width;
145 FT_Pos nominal_width;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000146
Werner Lembergd573c7e2001-01-03 07:14:12 +0000147 FT_Bool read_width;
148 FT_Int num_hints;
149 FT_Fixed* buildchar;
150 FT_Int len_buildchar;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000151
Werner Lembergd573c7e2001-01-03 07:14:12 +0000152 FT_UInt num_locals;
153 FT_UInt num_globals;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000154
Werner Lembergd573c7e2001-01-03 07:14:12 +0000155 FT_Int locals_bias;
156 FT_Int globals_bias;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000157
Werner Lembergd573c7e2001-01-03 07:14:12 +0000158 FT_Byte** locals;
159 FT_Byte** globals;
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000160
Werner Lembergd573c7e2001-01-03 07:14:12 +0000161 FT_Byte** glyph_names; /* for pure CFF fonts only */
162 FT_UInt num_glyphs; /* number of glyphs in font */
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000163
164 } CFF_Decoder;
165
166
167 FT_LOCAL
168 void CFF_Init_Decoder( CFF_Decoder* decoder,
Werner Lembergd573c7e2001-01-03 07:14:12 +0000169 TT_Face face,
170 CFF_Size size,
171 CFF_GlyphSlot slot );
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000172
173 FT_LOCAL
174 void CFF_Prepare_Decoder( CFF_Decoder* decoder,
Werner Lembergd573c7e2001-01-03 07:14:12 +0000175 FT_UInt glyph_index );
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000176
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
181 FT_Error CFF_Compute_Max_Advance( TT_Face face,
Werner Lembergd573c7e2001-01-03 07:14:12 +0000182 FT_Int* max_advance );
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000183
184#endif /* 0 */
185
186 FT_LOCAL
187 FT_Error CFF_Parse_CharStrings( CFF_Decoder* decoder,
Werner Lembergd573c7e2001-01-03 07:14:12 +0000188 FT_Byte* charstring_base,
189 FT_Int charstring_len );
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000190
191 FT_LOCAL
192 FT_Error CFF_Load_Glyph( CFF_GlyphSlot glyph,
Werner Lembergd573c7e2001-01-03 07:14:12 +0000193 CFF_Size size,
194 FT_Int glyph_index,
195 FT_Int load_flags );
Tom Kacvinsky8050a6b2001-01-03 00:17:58 +0000196
197
198FT_END_HEADER
199
200#endif /* __CFFGLOAD_H__ */
201
202
203/* END */