1 /* $XConsortium: out_outl.c,v 1.2 91/05/11 09:52:48 rws Exp $ */
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.
13 BITSTREAM CHARTER is a registered trademark of Bitstream Inc.
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.
26 /**************************** O U T _ 2 _ 1 . C ******************************
28 * This is the standard output module for vector output mode. *
30 ****************************************************************************/
33 #include "spdo_prv.h" /* General definitions for Speedo */
40 #define SHOW(X) printf("X = %d\n", X)
45 /* the following macro is used to limit points on the outline to the bounding box */
47 #define RANGECHECK(value,min,max) (((value) >= (min) ? (value) : (min)) < (max) ? (value) : (max))
48 /***** GLOBAL VARIABLES *****/
50 /***** GLOBAL FUNCTIONS *****/
52 /***** EXTERNAL VARIABLES *****/
54 /***** EXTERNAL FUNCTIONS *****/
56 /***** STATIC VARIABLES *****/
58 /***** STATIC FUNCTIONS *****/
62 FUNCTION boolean init_outline(specsarg)
64 specs_t GLOBALFAR *specsarg;
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.
72 printf("INIT_OUT_2()\n");
74 if (specsarg->flags & (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM))
75 return FALSE; /* Clipping not supported */
81 FUNCTION boolean begin_char_outline(Psw, Pmin, Pmax)
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 */
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().
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);
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);
123 FUNCTION void begin_sub_char_outline(Psw, Pmin, Pmax)
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 */
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().
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);
147 FUNCTION void begin_contour_outline(P1, outside)
149 point_t P1; /* Start point of contour */
150 boolean outside; /* TRUE if outside (counter-clockwise) contour */
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().
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");
165 x = RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
166 y = RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
168 start_contour((fix31)x << sp_globals.poshift, (fix31)y << sp_globals.poshift, outside);
173 FUNCTION void curve_outline(P1, P2, P3,depth)
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 */
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.
187 fix15 x1,y1,x2,y2,x3,y3;
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);
194 x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
195 y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
197 x2= RANGECHECK(P2.x,sp_globals.xmin,sp_globals.xmax);
198 y2= RANGECHECK(P2.y,sp_globals.ymin,sp_globals.ymax);
200 x3= RANGECHECK(P3.x,sp_globals.xmin,sp_globals.xmax);
201 y3= RANGECHECK(P3.y,sp_globals.ymin,sp_globals.ymax);
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);
210 FUNCTION void line_outline(P1)
212 point_t P1; /* End point of vector */
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().
223 printf("LINE_2(%3.1f, %3.1f)\n", (real)P1.x / (real)onepix, (real)P1.y / (real)onepix);
225 x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
226 y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);
228 line_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift);
233 FUNCTION void end_contour_outline()
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().
243 printf("END_CONTOUR_2()\n");
251 FUNCTION void end_sub_char_outline()
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().
261 printf("END_SUB_CHAR_2()\n");
268 FUNCTION boolean end_char_outline()
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).
281 printf("END_CHAR_2()\n");