1 /* $XConsortium: out_outl.c,v 1.2 91/05/11 09:52:48 rws Exp $ */
2
3 /*
4
5 Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
6 You are hereby granted permission under all Bitstream propriety rights to
7 use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
8 software and the Bitstream Charter outline font for any purpose and without
9 restrictions; provided, that this notice is left intact on all copies of such
10 software or font and that Bitstream's trademark is acknowledged as shown below
11 on all unmodified copies of such font.
12
13 BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
14
15
16 BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
17 WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 PARTICULAR PURPOSE. BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
19 DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
20 INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
21 WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.
22
23 */
24
25
26 /**************************** O U T _ 2 _ 1 . C ******************************
27 * *
28 * This is the standard output module for vector output mode. *
29 * *
30 ****************************************************************************/
31
32
33 #include "spdo_prv.h" /* General definitions for Speedo */
34
35
36 #define DEBUG 0
37
38 #if DEBUG
39 #include <stdio.h>
40 #define SHOW(X) printf("X = %d\n", X)
41 #else
42 #define SHOW(X)
43 #endif
44
45 /* the following macro is used to limit points on the outline to the bounding box */
46
47 #define RANGECHECK(value,min,max) (((value) >= (min) ? (value) : (min)) < (max) ? (value) : (max))
48 /***** GLOBAL VARIABLES *****/
49
50 /***** GLOBAL FUNCTIONS *****/
51
52 /***** EXTERNAL VARIABLES *****/
53
54 /***** EXTERNAL FUNCTIONS *****/
55
56 /***** STATIC VARIABLES *****/
57
58 /***** STATIC FUNCTIONS *****/
59
60
61 #if INCL_OUTLINE
init_outline(specsarg)62 FUNCTION boolean init_outline(specsarg)
63 GDECL
64 specs_t GLOBALFAR *specsarg;
65 /*
66 * init_out2() is called by sp_set_specs() to initialize the output module.
67 * Returns TRUE if output module can accept requested specifications.
68 * Returns FALSE otherwise.
69 */
70 {
71 #if DEBUG
72 printf("INIT_OUT_2()\n");
73 #endif
74 if (specsarg->flags & (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM))
75 return FALSE; /* Clipping not supported */
76 return (TRUE);
77 }
78 #endif
79
80 #if INCL_OUTLINE
begin_char_outline(Psw,Pmin,Pmax)81 FUNCTION boolean begin_char_outline(Psw, Pmin, Pmax)
82 GDECL
83 point_t Psw; /* End of escapement vector (sub-pixels) */
84 point_t Pmin; /* Bottom left corner of bounding box */
85 point_t Pmax; /* Top right corner of bounding box */
86 /*
87 * If two or more output modules are included in the configuration, begin_char2()
88 * is called by begin_char() to signal the start of character output data.
89 * If only one output module is included in the configuration, begin_char() is
90 * called by make_simp_char() and make_comp_char().
91 */
92 {
93 fix31 set_width_x;
94 fix31 set_width_y;
95 fix31 xmin;
96 fix31 xmax;
97 fix31 ymin;
98 fix31 ymax;
99
100 #if DEBUG
101 printf("BEGIN_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
102 (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
103 (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
104 (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
105 #endif
106 sp_globals.poshift = 16 - sp_globals.pixshift;
107 set_width_x = (fix31)Psw.x << sp_globals.poshift;
108 set_width_y = (fix31)Psw.y << sp_globals.poshift;
109 xmin = (fix31)Pmin.x << sp_globals.poshift;
110 xmax = (fix31)Pmax.x << sp_globals.poshift;
111 ymin = (fix31)Pmin.y << sp_globals.poshift;
112 ymax = (fix31)Pmax.y << sp_globals.poshift;
113 sp_globals.xmin = Pmin.x;
114 sp_globals.xmax = Pmax.x;
115 sp_globals.ymin = Pmin.y;
116 sp_globals.ymax = Pmax.y;
117 open_outline(set_width_x, set_width_y, xmin, xmax, ymin, ymax);
118 return TRUE;
119 }
120 #endif
121
122 #if INCL_OUTLINE
begin_sub_char_outline(Psw,Pmin,Pmax)123 FUNCTION void begin_sub_char_outline(Psw, Pmin, Pmax)
124 GDECL
125 point_t Psw; /* End of sub-char escapement vector */
126 point_t Pmin; /* Bottom left corner of sub-char bounding box */
127 point_t Pmax; /* Top right corner of sub-char bounding box */
128 /*
129 * If two or more output modules are included in the configuration, begin_sub_char2()
130 * is called by begin_sub_char() to signal the start of sub-character output data.
131 * If only one output module is included in the configuration, begin_sub_char() is
132 * called by make_comp_char().
133 */
134 {
135 #if DEBUG
136 printf("BEGIN_SUB_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n",
137 (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
138 (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
139 (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
140 #endif
141 start_new_char();
142 }
143 #endif
144
145
146 #if INCL_OUTLINE
begin_contour_outline(P1,outside)147 FUNCTION void begin_contour_outline(P1, outside)
148 GDECL
149 point_t P1; /* Start point of contour */
150 boolean outside; /* TRUE if outside (counter-clockwise) contour */
151 /*
152 * If two or more output modules are included in the configuration, begin_contour2()
153 * is called by begin_contour() to define the start point of a new contour
154 * and to indicate whether it is an outside (counter-clockwise) contour
155 * or an inside (clockwise) contour.
156 * If only one output module is included in the configuration, begin_sub_char() is
157 * called by proc_outl_data().
158 */
159 {
160 fix15 x,y;
161 #if DEBUG
162 printf("BEGIN_CONTOUR_2(%3.1f, %3.1f, %s)\n",
163 (real)P1.x / (real)onepix, (real)P1.y / (real)onepix, outside? "outside": "inside");
164 #endif
165 x = RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
166 y = RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
167
168 start_contour((fix31)x << sp_globals.poshift, (fix31)y << sp_globals.poshift, outside);
169 }
170 #endif
171
172 #if INCL_OUTLINE
curve_outline(P1,P2,P3,depth)173 FUNCTION void curve_outline(P1, P2, P3,depth)
174 GDECL
175 point_t P1; /* First control point of Bezier curve */
176 point_t P2; /* Second control point of Bezier curve */
177 point_t P3; /* End point of Bezier curve */
178 fix15 depth;
179 /*
180 * If two or more output modules are included in the configuration, curve2()
181 * is called by curve() to output one curve segment.
182 * If only one output module is included in the configuration, curve() is
183 * called by proc_outl_data().
184 * This function is only called when curve output is enabled.
185 */
186 {
187 fix15 x1,y1,x2,y2,x3,y3;
188 #if DEBUG
189 printf("CURVE_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n",
190 (real)P1.x / (real)onepix, (real)P1.y / (real)onepix,
191 (real)P2.x / (real)onepix, (real)P2.y / (real)onepix,
192 (real)P3.x / (real)onepix, (real)P3.y / (real)onepix);
193 #endif
194 x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
195 y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
196
197 x2= RANGECHECK(P2.x,sp_globals.xmin,sp_globals.xmax);
198 y2= RANGECHECK(P2.y,sp_globals.ymin,sp_globals.ymax);
199
200 x3= RANGECHECK(P3.x,sp_globals.xmin,sp_globals.xmax);
201 y3= RANGECHECK(P3.y,sp_globals.ymin,sp_globals.ymax);
202
203 curve_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift,
204 (fix31)x2<< sp_globals.poshift, (fix31)y2 << sp_globals.poshift,
205 (fix31)x3 << sp_globals.poshift, (fix31)y3 << sp_globals.poshift);
206 }
207 #endif
208
209 #if INCL_OUTLINE
line_outline(P1)210 FUNCTION void line_outline(P1)
211 GDECL
212 point_t P1; /* End point of vector */
213 /*
214 * If two or more output modules are included in the configuration, line2()
215 * is called by line() to output one vector.
216 * If only one output module is included in the configuration, line() is
217 * called by proc_outl_data(). If curve output is enabled, line() is also
218 * called by split_curve().
219 */
220 {
221 fix15 x1,y1;
222 #if DEBUG
223 printf("LINE_2(%3.1f, %3.1f)\n", (real)P1.x / (real)onepix, (real)P1.y / (real)onepix);
224 #endif
225 x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
226 y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
227
228 line_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift);
229 }
230 #endif
231
232 #if INCL_OUTLINE
end_contour_outline()233 FUNCTION void end_contour_outline()
234 GDECL
235 /*
236 * If two or more output modules are included in the configuration, end_contour2()
237 * is called by end_contour() to signal the end of a contour.
238 * If only one output module is included in the configuration, end_contour() is
239 * called by proc_outl_data().
240 */
241 {
242 #if DEBUG
243 printf("END_CONTOUR_2()\n");
244 #endif
245 close_contour();
246 }
247 #endif
248
249
250 #if INCL_OUTLINE
end_sub_char_outline()251 FUNCTION void end_sub_char_outline()
252 GDECL
253 /*
254 * If two or more output modules are included in the configuration, end_sub_char2()
255 * is called by end_sub_char() to signal the end of sub-character data.
256 * If only one output module is included in the configuration, end_sub_char() is
257 * called by make_comp_char().
258 */
259 {
260 #if DEBUG
261 printf("END_SUB_CHAR_2()\n");
262 #endif
263 }
264 #endif
265
266
267 #if INCL_OUTLINE
end_char_outline()268 FUNCTION boolean end_char_outline()
269 GDECL
270 /*
271 * If two or more output modules are included in the configuration, end_char2()
272 * is called by end_char() to signal the end of the character data.
273 * If only one output module is included in the configuration, end_char() is
274 * called by make_simp_char() and make_comp_char().
275 * Returns TRUE if output process is complete
276 * Returns FALSE to repeat output of the transformed data beginning
277 * with the first contour (of the first sub-char if compound).
278 */
279 {
280 #if DEBUG
281 printf("END_CHAR_2()\n");
282 #endif
283 close_outline();
284 return TRUE;
285 }
286 #endif
287
288