blob: 77f86625c41de0ca3e9a43f01811f50975c51684 [file] [log] [blame]
David Turner4f99c3c2000-05-29 20:55:13 +00001/***************************************************************************/
2/* */
3/* t2gload.h */
4/* */
5/* OpenType Glyph Loader (specification). */
6/* */
Werner Lemberg7a4fda82000-06-13 23:21:00 +00007/* Copyright 1996-2000 by */
David Turner4f99c3c2000-05-29 20:55:13 +00008/* David Turner, Robert Wilhelm, and Werner Lemberg. */
9/* */
Werner Lemberg7a4fda82000-06-13 23:21:00 +000010/* This file is part of the FreeType project, and may only be used, */
11/* modified, and distributed under the terms of the FreeType project */
David Turner4f99c3c2000-05-29 20:55:13 +000012/* 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
Werner Lemberg90d99642000-12-09 00:45:38 +000019#ifndef __T2GLOAD_H__
20#define __T2GLOAD_H__
21
David Turner4f99c3c2000-05-29 20:55:13 +000022
David Turner19ed8af2000-12-08 02:42:29 +000023#include <ft2build.h>
24#include FT_FREETYPE_H
25#include FT_SOURCE_FILE(cff,cffobjs.h)
David Turnera90663f2000-07-08 00:41:13 +000026
Werner Lemberg90d99642000-12-09 00:45:38 +000027
David Turner19ed8af2000-12-08 02:42:29 +000028FT_BEGIN_HEADER
David Turner0f991b42000-06-07 20:04:34 +000029
Werner Lemberg90d99642000-12-09 00:45:38 +000030
Werner Lemberg7a4fda82000-06-13 23:21:00 +000031#define T2_MAX_OPERANDS 48
32#define T2_MAX_SUBRS_CALLS 32
David Turner0f991b42000-06-07 20:04:34 +000033
Werner Lemberg7a4fda82000-06-13 23:21:00 +000034
35 /*************************************************************************/
36 /* */
37 /* <Structure> */
38 /* T2_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 /* 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 T2_Builder_
David Turner4f99c3c2000-05-29 20:55:13 +000088 {
David Turnerf0df85b2000-06-22 00:17:42 +000089 FT_Memory memory;
90 TT_Face face;
91 T2_GlyphSlot glyph;
92 FT_GlyphLoader* loader;
93 FT_Outline* base;
94 FT_Outline* current;
David Turner4f99c3c2000-05-29 20:55:13 +000095
David Turnerf0df85b2000-06-22 00:17:42 +000096 FT_Vector last;
David Turner4f99c3c2000-05-29 20:55:13 +000097
David Turnerf0df85b2000-06-22 00:17:42 +000098 FT_Fixed scale_x;
99 FT_Fixed scale_y;
David Turner4f99c3c2000-05-29 20:55:13 +0000100
David Turnerf0df85b2000-06-22 00:17:42 +0000101 FT_Pos pos_x;
102 FT_Pos pos_y;
David Turner4f99c3c2000-05-29 20:55:13 +0000103
David Turnerf0df85b2000-06-22 00:17:42 +0000104 FT_Vector left_bearing;
105 FT_Vector advance;
David Turner4f99c3c2000-05-29 20:55:13 +0000106
David Turnerf0df85b2000-06-22 00:17:42 +0000107 FT_BBox bbox; /* bounding box */
108 FT_Bool path_begun;
109 FT_Bool load_points;
110 FT_Bool no_recurse;
David Turner4f99c3c2000-05-29 20:55:13 +0000111
David Turnerf0df85b2000-06-22 00:17:42 +0000112 FT_Error error; /* only used for memory errors */
113 FT_Bool metrics_only;
David Turner0f991b42000-06-07 20:04:34 +0000114
115 } T2_Builder;
David Turner4f99c3c2000-05-29 20:55:13 +0000116
117
David Turner0f991b42000-06-07 20:04:34 +0000118 /* execution context charstring zone */
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000119
120 typedef struct T2_Decoder_Zone_
David Turner0f991b42000-06-07 20:04:34 +0000121 {
David Turnerf9b8dec2000-06-16 19:34:52 +0000122 FT_Byte* base;
123 FT_Byte* limit;
124 FT_Byte* cursor;
David Turner0f991b42000-06-07 20:04:34 +0000125
126 } T2_Decoder_Zone;
127
128
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000129 typedef struct T2_Decoder_
David Turner0f991b42000-06-07 20:04:34 +0000130 {
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000131 T2_Builder builder;
132 CFF_Font* cff;
David Turner0f991b42000-06-07 20:04:34 +0000133
David Turnerf9b8dec2000-06-16 19:34:52 +0000134 FT_Fixed stack[T2_MAX_OPERANDS + 1];
135 FT_Fixed* top;
David Turner0f991b42000-06-07 20:04:34 +0000136
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000137 T2_Decoder_Zone zones[T2_MAX_SUBRS_CALLS + 1];
138 T2_Decoder_Zone* zone;
David Turner0f991b42000-06-07 20:04:34 +0000139
David Turnerf9b8dec2000-06-16 19:34:52 +0000140 FT_Int flex_state;
141 FT_Int num_flex_vectors;
142 FT_Vector flex_vectors[7];
David Turner0f991b42000-06-07 20:04:34 +0000143
David Turnerf9b8dec2000-06-16 19:34:52 +0000144 FT_Pos glyph_width;
145 FT_Pos nominal_width;
David Turner0f991b42000-06-07 20:04:34 +0000146
David Turnerf9b8dec2000-06-16 19:34:52 +0000147 FT_Bool read_width;
148 FT_Int num_hints;
149 FT_Fixed* buildchar;
150 FT_Int len_buildchar;
David Turner0f991b42000-06-07 20:04:34 +0000151
David Turnerf9b8dec2000-06-16 19:34:52 +0000152 FT_UInt num_locals;
153 FT_UInt num_globals;
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000154
David Turnerf9b8dec2000-06-16 19:34:52 +0000155 FT_Int locals_bias;
156 FT_Int globals_bias;
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000157
David Turnerf9b8dec2000-06-16 19:34:52 +0000158 FT_Byte** locals;
159 FT_Byte** globals;
David Turner0f991b42000-06-07 20:04:34 +0000160
David Turner19ed8af2000-12-08 02:42:29 +0000161 FT_Byte** glyph_names; /* for pure CFF fonts only */
162 FT_UInt num_glyphs; /* number of glyphs in font */
163
David Turner0f991b42000-06-07 20:04:34 +0000164 } T2_Decoder;
165
166
Werner Lembergcc069be2000-12-08 16:17:16 +0000167 FT_LOCAL
168 void T2_Init_Decoder( T2_Decoder* decoder,
169 TT_Face face,
170 T2_Size size,
171 T2_GlyphSlot slot );
David Turner4f99c3c2000-05-29 20:55:13 +0000172
Werner Lembergcc069be2000-12-08 16:17:16 +0000173 FT_LOCAL
174 void T2_Prepare_Decoder( T2_Decoder* decoder,
175 FT_UInt glyph_index );
David Turner4f99c3c2000-05-29 20:55:13 +0000176
David Turner0f991b42000-06-07 20:04:34 +0000177#if 0 /* unused until we support pure CFF fonts */
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000178
David Turner0f991b42000-06-07 20:04:34 +0000179 /* Compute the maximum advance width of a font through quick parsing */
Werner Lembergcc069be2000-12-08 16:17:16 +0000180 FT_LOCAL
181 FT_Error T2_Compute_Max_Advance( TT_Face face,
182 FT_Int* max_advance );
Werner Lemberg7a4fda82000-06-13 23:21:00 +0000183
Werner Lembergcc9fc492000-06-30 06:21:26 +0000184#endif /* 0 */
David Turner4f99c3c2000-05-29 20:55:13 +0000185
Werner Lembergcc069be2000-12-08 16:17:16 +0000186 FT_LOCAL
187 FT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
188 FT_Byte* charstring_base,
189 FT_Int charstring_len );
David Turner0f991b42000-06-07 20:04:34 +0000190
Werner Lembergcc069be2000-12-08 16:17:16 +0000191 FT_LOCAL
192 FT_Error T2_Load_Glyph( T2_GlyphSlot glyph,
193 T2_Size size,
194 FT_Int glyph_index,
195 FT_Int load_flags );
David Turner0f991b42000-06-07 20:04:34 +0000196
197
David Turner19ed8af2000-12-08 02:42:29 +0000198FT_END_HEADER
David Turner4f99c3c2000-05-29 20:55:13 +0000199
Werner Lemberg90d99642000-12-09 00:45:38 +0000200#endif /* __T2GLOAD_H__ */
David Turner4f99c3c2000-05-29 20:55:13 +0000201
202
203/* END */