summaryrefslogtreecommitdiff
path: root/fonts/utilities/ps2mf/PSparse.h
blob: 75c5c0a0b7c377a8bece46fa7a997c09c8f68820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* PSparse.h */

char * PS_header_commands [] =
{
	"/FontInfo",
	"/FontName",
	"/Encoding",
	"/PaintType",
	"/FontType",
	"/FontMatrix",
	"/FontBBox",
	"/UniqueID",
	"/Metrics",
	"/StrokeWidth",
	"/Private",
	"/CharStrings",
	"/FID",
	"/version",
	"/Notice",
	"/FullName",
	"/FamilyName",
	"/Weight",
	"/ItalicAngle",
	"/isFixedPitch",
	"/UnderlinePosition",
	"/UnderlineThickness",
	"/BlueFuzz",
	"/BlueScale",
	"/BlueShift",
	"/BlueValues",
	"/ExpansionFactor",
	"/FamilyBlues",
	"/FamilyOtherBlues",
	"/ForceBold",
	"/LanguageGroup",
	"/lenIV",
	"/MinFeature",
	"/ND",
	"/NP",
	"/OtherBlues",
	"/OtherSubrs",
	"/password",
	"/RD",
	"/RndStemUp",
	"/StdHW",
	"/StdVW",
	"/StemSnapH",
	"/StemSnapV",
	"/Subrs",
	NULL
};

#define FontInfo (0)
#define FontName (1)
#define Encoding (2)
#define PaintType (3)
#define FontType (4)
#define FontMatrix (5)
#define FontBBox (6)
#define UniqueID (7)
#define Metrics (8)
#define StrokeWidth (9)
#define Private (10)
#define CharStrings (11)
#define FID (12)
#define version (13)
#define Notice (14)
#define FullName (15)
#define FamilyName (16)
#define Weight (17)
#define ItalicAngle (18)
#define isFixedPitch (19)
#define UnderlinePosition (20)
#define UnderlineThickness (21)
#define BlueFuzz (22)
#define BlueScale (23)
#define BlueShift (24)
#define BlueValues (25)
#define ExpansionFactor (26)
#define FamilyBlues (27)
#define FamilyOtherBlues (28)
#define ForceBold (29)
#define LanguageGroup (30)
#define lenIV (31)
#define MinFeature (32)
#define ND (33)
#define NP (34)
#define OtherBlues (35)
#define OtherSubrs (36)
#define password (37)
#define RD (38)
#define RndStemUp (39)
#define StdHW (40)
#define StdVW (41)
#define StemSnapH (42)
#define StemSnapV (43)
#define Subrs (44)
#define not_a_PS_header_command (-1)

char * charstring_commands [] =
{
	"hstem",
	"vstem",
	"vmoveto",
	"rlineto",
	"hlineto",
	"vlineto",
	"rrcurveto",
	"closepath",
	"callsubr",
	"return",
	"escape",
	"hsbw",
	"endchar",
	"rmoveto",
	"hmoveto",
	"vhcurveto",
	"hvcurveto",
	"dotsection",
	"vstem3",
	"hstem3",
	"seac",
	"sbw",
	"div",
	"callothersubr",
	"pop",
	"setcurrentpoint",
	NULL
};

#define hstem (0)
#define vstem (1)
#define vmoveto (2)
#define rlineto (3)
#define hlineto (4)
#define vlineto (5)
#define rrcurveto (6)
#define closepath (7)
#define callsubr (8)
#define return_command (9) /* return is a reserved word !!!! */
#define escape (10)
#define hsbw (11)
#define endchar (12)
#define rmoveto (13)
#define hmoveto (14)
#define vhcurveto (15)
#define hvcurveto (16)
#define dotsection (17)
#define vstem3 (18)
#define hstem3 (19)
#define seac (20)
#define sbw (21)
#define div (22)
#define callothersubr (23)
#define pop_command (24)
#define setcurrentpoint (25)
#define not_a_charstring_command (-1)
#define charstring_command_numeric (-2)
#define charstring_command_char (-3)
#define charstring_commands_end (-4)

char * seac_candidates [] =
{
	"A",
	"C",
	"E",
	"I",
	"N",
	"O",
	"S",
	"U",
	"Y",
	"Z",
	"a",
	"c",
	"dotlessi",
	"e",
	"n",
	"o",
	"s",
	"u",
	"y",
	"z",
	"acute",
	"caron",
	"cedilla",
	"circumflex",
	"dieresis",
	"grave",
	"ring",
	"tilde",
	NULL
};

#define MAX_Subrs_entries 1000 /* Really I have seen a font with 612 entries */
#define MAX_Subrs_stack 11
bool processing_Subr;
int current_Subr;

typedef struct Subrs_entry
{
	char * token;
	struct Subrs_entry * next;
} Subrs_entry_tp;
Subrs_entry_tp * Subrs_entries [MAX_Subrs_entries],
               * Subrs_stack [MAX_Subrs_stack];

char coding_vector [255][35];

#define MAX_stack 1500
float stack [MAX_stack];
int top_of_stack;
float numeric_val;
char current_char [35];
int current_AFM_num;
bool after_hint;
float the_sbx;

int active_path, path_number;
bool active_flex;
typedef struct Flex
{
	float x [7], y [7];
	int n;
} Flex_tp;
Flex_tp flex;
typedef struct cartesian
{
	float x;
	float y;
} cartesian_tp;
cartesian_tp current_point;
bool processing_seacs, have_found_seacs;
long charstring_position;

#define MAX_blue_values 7
#define MAX_other_blues 5
typedef struct blue_pairs
{
	int overshoot;
	int position;
} blue_pairs_tp;
blue_pairs_tp blue_values [MAX_blue_values], other_blues [MAX_other_blues];
int num_of_blue_values, num_of_other_blues;
float blue_scale;
int blue_shift;
int blue_fuzz;

bool first_time_generating;
int linepos;

#ifndef __P
#ifdef __STDC__
#define __P(a) a
#else
#define __P(a) ()
#endif
#endif

bool candidate_for_seac __P((void));
int charstring_command __P((char * s));
void do_callothersubr __P((int othersubr, int n));
void do_callsubr __P((int subr_no));
void do_closepath __P((void));
void do_div __P((float num1, float num2));
void do_dotsection __P((void));
void do_endchar __P((void));
void do_hlineto __P((float dx));
void do_hmoveto __P((float dx));
void do_hsbw __P((float sbx, float wx));
void do_hstem __P((float y, float dy));
void do_hstem3 __P((float y0, float dy0, float y1, float dy1, float y2,
                    float dy2));
void do_hvcurveto __P((float dx1, float dx2, float dy2, float dy3));
float do_pop __P((void));
void do_rcurveto __P((float dx1, float dy1, float dx2, float dy2, float dx3,
                      float dy3));
void do_return __P((void));
void do_rlineto __P((float dx, float dy));
void do_rmoveto __P((float dx, float dy));
void do_rrcurveto __P((float dx1, float dy1, float dx2, float dy2, float dx3,
                       float dy3));
void do_sbw __P((float sbx, float sby, float wx, float wy));
void do_seac __P((float asb, float adx, float ady, int bchar, int achar));
void do_setcurrentpoint __P((float x, float y));
void do_vhcurveto __P((float dy1, float dx2, float dy2, float dx3));
void do_vlineto __P((float dy));
void do_vmoveto __P((float dy));
void do_vstem __P((float x, float dx));
void do_vstem3 __P((float x0, float dx0, float x1, float dx1, float x2,
                    float dx2));
void eat_this_character __P((char * s));
void get_blue_scale __P((void));
void get_blue_values __P((void));
void get_font_matrix __P((void));
void get_font_type __P((void));
void get_is_fixed_pitch __P((void));
void get_italic_angle __P((void));
void get_other_blues __P((void));
void get_paint_type __P((void));
Subrs_entry_tp * new_Subrs_entry __P((void));
char * next_param_string __P((void));
void parse_PS_header __P((void));
void parse_charstrings_dictionary __P((void));
float pop __P((void));
void process_callothersubr __P((void));
void process_callsubr __P((void));
void process_closepath __P((void));
void process_div __P((void));
void process_dotsection __P((void));
void process_endchar __P((void));
void process_escape __P((void));
void process_hlineto __P((void));
void process_hmoveto __P((void));
void process_hsbw __P((void));
void process_hstem __P((void));
void process_hstem3 __P((void));
void process_hvcurveto __P((void));
void process_one_Subrs_entry __P((void));
float process_pop __P((void));
void process_return __P((void));
void process_rlineto __P((void));
void process_rmoveto __P((void));
void process_rrcurveto __P((void));
void process_sbw __P((void));
void process_seac __P((void));
void process_setcurrentpoint __P((void));
void process_Subrs_entries __P((void));
void process_vhcurveto __P((void));
void process_vlineto __P((void));
void process_vmoveto __P((void));
void process_vstem __P((void));
void process_vstem3 __P((void));
void push __P((float fl));
void start_char __P((char * name));