]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/gstype1.h
Import cups.org releases
[thirdparty/cups.git] / pstoraster / gstype1.h
1 /* Copyright (C) 1990, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved.
2
3 This file is part of GNU Ghostscript.
4
5 GNU Ghostscript is distributed in the hope that it will be useful, but
6 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
7 to anyone for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing. Refer
9 to the GNU General Public License for full details.
10
11 Everyone is granted permission to copy, modify and redistribute GNU
12 Ghostscript, but only under the conditions described in the GNU General
13 Public License. A copy of this license is supposed to have been given
14 to you along with GNU Ghostscript so you can know your rights and
15 responsibilities. It should be in a file named COPYING. Among other
16 things, the copyright notice and this notice must be preserved on all
17 copies.
18
19 Aladdin Enterprises supports the work of the GNU Project, but is not
20 affiliated with the Free Software Foundation or the GNU Project. GNU
21 Ghostscript, as distributed by Aladdin Enterprises, does not require any
22 GNU software to build or run it.
23 */
24
25 /*$Id$ */
26 /* Client interface to Adobe Type 1 font routines */
27
28 #ifndef gstype1_INCLUDED
29 # define gstype1_INCLUDED
30
31 /* ------ Normal client interface ------ */
32
33 #define crypt_charstring_seed 4330
34 typedef struct gs_type1_state_s gs_type1_state;
35
36 #ifndef gx_path_DEFINED
37 # define gx_path_DEFINED
38 typedef struct gx_path_s gx_path;
39
40 #endif
41 #ifndef gs_show_enum_s_DEFINED
42 struct gs_show_enum_s;
43
44 #endif
45 #ifndef gs_font_type1_DEFINED
46 # define gs_font_type1_DEFINED
47 typedef struct gs_font_type1_s gs_font_type1;
48
49 #endif
50 #ifndef gs_type1_data_s_DEFINED
51 struct gs_type1_data_s;
52
53 #endif
54 int gs_type1_interp_init(P7(gs_type1_state * pcis, gs_imager_state * pis,
55 gx_path * ppath, const gs_log2_scale_point * pscale,
56 bool charpath_flag, int paint_type,
57 gs_font_type1 * pfont));
58 void gs_type1_set_lsb(P2(gs_type1_state * pcis, const gs_point * psbpt));
59 void gs_type1_set_width(P2(gs_type1_state * pcis, const gs_point * pwpt));
60
61 /* Backward compatibility */
62 #define gs_type1_init(pcis, penum, psbpt, charpath_flag, paint_type, pfont)\
63 (gs_type1_interp_init(pcis, (gs_imager_state *)((penum)->pgs),\
64 (penum)->pgs->path, &(penum)->log2_current_scale,\
65 charpath_flag, paint_type, pfont) |\
66 ((psbpt) == 0 ? 0 : (gs_type1_set_lsb(pcis, psbpt), 0)))
67 /*
68 * Continue interpreting a Type 1 CharString. If str != 0, it is taken as
69 * the byte string to interpret. Return 0 on successful completion, <0 on
70 * error, or >0 when client intervention is required (or allowed). The int*
71 * argument is where the othersubr # is stored for callothersubr.
72 */
73 #define type1_result_sbw 1 /* allow intervention after [h]sbw */
74 #define type1_result_callothersubr 2
75
76 int gs_type1_interpret(P3(gs_type1_state *, const gs_const_string *, int *));
77
78 /* ------ CharString number representation ------ */
79
80 /* Define the representation of integers used by both Type 1 and Type 2. */
81 typedef enum {
82
83 /* Values from 32 to 246 represent small integers. */
84 c_num1 = 32,
85 #define c_value_num1(ch) ((int)(byte)(ch) - 139)
86
87 /* The next 4 values represent 2-byte positive integers. */
88 c_pos2_0 = 247,
89 c_pos2_1 = 248,
90 c_pos2_2 = 249,
91 c_pos2_3 = 250,
92 #define c_value_pos2(c1,c2)\
93 (((int)(byte)((c1) - (int)c_pos2_0) << 8) + (int)(byte)(c2) + 108)
94
95 /* The next 4 values represent 2-byte negative integers. */
96 c_neg2_0 = 251,
97 c_neg2_1 = 252,
98 c_neg2_2 = 253,
99 c_neg2_3 = 254
100 #define c_value_neg2(c1,c2)\
101 -(((int)(byte)((c1) - (int)c_neg2_0) << 8) + (int)(byte)(c2) + 108)
102
103 } char_num_command;
104
105 /* ------ Type 1 & Type 2 CharString representation ------ */
106
107 /*
108 * We define both the Type 1 and Type 2 operators here, because they
109 * overlap so much.
110 */
111 typedef enum {
112
113 /* Commands with identical functions in Type 1 and Type 2 */
114 /* charstrings. */
115
116 c_undef0 = 0,
117 c_undef2 = 2,
118 c_callsubr = 10,
119 c_return = 11,
120 c_undoc15 = 15, /* An obsolete and undocumented */
121 /* command used in some very old */
122 /* Adobe fonts. */
123 c_undef17 = 17,
124
125 /* Commands with similar but not identical functions */
126 /* in Type 1 and Type 2 charstrings. */
127
128 cx_hstem = 1,
129 cx_vstem = 3,
130 cx_vmoveto = 4,
131 cx_rlineto = 5,
132 cx_hlineto = 6,
133 cx_vlineto = 7,
134 cx_rrcurveto = 8,
135 cx_escape = 12, /* extends the command set */
136 cx_endchar = 14,
137 cx_rmoveto = 21,
138 cx_hmoveto = 22,
139 cx_vhcurveto = 30,
140 cx_hvcurveto = 31,
141
142 cx_num4 = 255, /* 4-byte numbers */
143
144 /* Commands recognized only in Type 1 charstrings. */
145
146 c1_closepath = 9,
147 c1_hsbw = 13,
148
149 /* Commands not recognized in Type 1 charstrings. */
150
151 #define case_c1_undefs\
152 case 16: case 18: case 19:\
153 case 20: case 23: case 24:\
154 case 25: case 26: case 27: case 28: case 29
155
156 /* Commands only recognized in Type 2 charstrings. */
157
158 c2_blend = 16,
159 c2_hstemhm = 18,
160 c2_hintmask = 19,
161 c2_cntrmask = 20,
162 c2_vstemhm = 23,
163 c2_rcurveline = 24,
164 c2_rlinecurve = 25,
165 c2_vvcurveto = 26,
166 c2_hhcurveto = 27,
167 c2_shortint = 28,
168 c2_callgsubr = 29
169
170 /* Commands not recognized in Type 2 charstrings. */
171
172 #define case_c2_undefs\
173 case 9: case 13
174
175 } char_command;
176
177 #define char1_command_names\
178 0, "hstem", 0, "vstem", "vmoveto",\
179 "rlineto", "hlineto", "vlineto", "rrcurveto", "closepath",\
180 "callsubr", "return", "(escape)", "hsbw", "endchar",\
181 "undoc15", 0, 0, 0, 0,\
182 0, "rmoveto", "hmoveto", 0, 0,\
183 0, 0, 0, 0, 0,\
184 "vhcurveto", "hvcurveto"
185 #define char2_command_names\
186 0, "hstem", 0, "vstem", "vmoveto",\
187 "rlineto", "hlineto", "vlineto", "rrcurveto", 0,\
188 "callsubr", "return", "(escape)", 0, "endchar",\
189 "undoc15", "blend", 0, "hstemhm", "hintmask",\
190 "cntrmask", "rmoveto", "hmoveto", "vstemhm", "rcurveline",\
191 "rlinecurve", "vvcurveto", "hhcurveto", "shortint", "callgsubr",\
192 "vhcurveto", "hvcurveto"
193
194 /*
195 * Extended (escape) commands in Type 1 charstrings.
196 */
197 typedef enum {
198 ce1_dotsection = 0,
199 ce1_vstem3 = 1,
200 ce1_hstem3 = 2,
201 ce1_seac = 6,
202 ce1_sbw = 7,
203 ce1_div = 12,
204 ce1_undoc15 = 15, /* An obsolete and undocumented */
205 /* command used in some very old */
206 /* Adobe fonts. */
207 ce1_callothersubr = 16,
208 ce1_pop = 17,
209 ce1_setcurrentpoint = 33
210 } char1_extended_command;
211
212 #define char1_extended_command_count 34
213 #define char1_extended_command_names\
214 "dotsection", "vstem3", "hstem3", 0, 0,\
215 0, "seac", "sbw", 0, 0,\
216 0, 0, "div", 0, 0,\
217 "undoc15", "callothersubr", "pop", 0, 0,\
218 0, 0, 0, 0, 0,\
219 0, 0, 0, 0, 0,\
220 0, 0, 0, "setcurrentpoint"
221
222 /*
223 * Extended (escape) commands in Type 2 charstrings.
224 */
225 typedef enum {
226 ce2_and = 3,
227 ce2_or = 4,
228 ce2_not = 5,
229 ce2_store = 8,
230 ce2_abs = 9,
231 ce2_add = 10,
232 ce2_sub = 11,
233 ce2_div = 12, /* same as ce1_div */
234 ce2_load = 13,
235 ce2_neg = 14,
236 ce2_eq = 15,
237 ce2_drop = 18,
238 ce2_put = 20,
239 ce2_get = 21,
240 ce2_ifelse = 22,
241 ce2_random = 23,
242 ce2_mul = 24,
243 ce2_sqrt = 26,
244 ce2_dup = 27,
245 ce2_exch = 28,
246 ce2_index = 29,
247 ce2_roll = 30,
248 ce2_hflex = 34,
249 ce2_flex = 35,
250 ce2_hflex1 = 36,
251 ce2_flex1 = 37
252 } char2_extended_command;
253
254 #define char2_extended_command_count 38
255 #define char2_extended_command_names\
256 0, 0, 0, "and", "or",\
257 "not", 0, 0, "store", "abs",\
258 "add", "sub", "div", "load", "neg",\
259 "eq", 0, 0, "drop", 0,\
260 "put", "get", "ifelse", "random", "mul",\
261 0, "sqrt", "dup", "exch", "index",\
262 "roll", 0, 0, 0, "hflex",\
263 "flex", "hflex1", "flex1"
264
265 #endif /* gstype1_INCLUDED */