summaryrefslogtreecommitdiff
path: root/src/Speedo/out_outl.c
blob: bebc6844d0afb3a63e7d8f62db4b952f824906a9 (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
/* $Xorg: out_outl.c,v 1.3 2000/08/17 19:46:26 cpqbld Exp $ */

/*

Copyright 1989-1991, Bitstream Inc., Cambridge, MA.
You are hereby granted permission under all Bitstream propriety rights to
use, copy, modify, sublicense, sell, and redistribute the Bitstream Speedo
software and the Bitstream Charter outline font for any purpose and without
restrictions; provided, that this notice is left intact on all copies of such
software or font and that Bitstream's trademark is acknowledged as shown below
on all unmodified copies of such font.

BITSTREAM CHARTER is a registered trademark of Bitstream Inc.


BITSTREAM INC. DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  BITSTREAM SHALL NOT BE LIABLE FOR ANY DIRECT OR INDIRECT
DAMAGES, INCLUDING BUT NOT LIMITED TO LOST PROFITS, LOST DATA, OR ANY OTHER
INCIDENTAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF OR IN ANY WAY CONNECTED
WITH THE SPEEDO SOFTWARE OR THE BITSTREAM CHARTER OUTLINE FONT.

*/


/**************************** O U T _ 2 _ 1 . C ******************************
 *                                                                           *
 * This is the standard output module for vector output mode.                *
 *                                                                           *
 ****************************************************************************/


#include "spdo_prv.h"               /* General definitions for Speedo     */


#define   DEBUG      0

#if DEBUG
#include <stdio.h>
#define SHOW(X) printf("X = %d\n", X)
#else
#define SHOW(X)
#endif

/* the following macro is used to limit points on the outline to the bounding box */

#define RANGECHECK(value,min,max) (((value) >= (min) ? (value) : (min)) < (max) ? (value) : (max))
/***** GLOBAL VARIABLES *****/

/***** GLOBAL FUNCTIONS *****/

/***** EXTERNAL VARIABLES *****/

/***** EXTERNAL FUNCTIONS *****/

/***** STATIC VARIABLES *****/

/***** STATIC FUNCTIONS *****/


#if INCL_OUTLINE
FUNCTION boolean init_outline(specsarg)
GDECL
specs_t GLOBALFAR *specsarg;
/*
 * init_out2() is called by sp_set_specs() to initialize the output module.
 * Returns TRUE if output module can accept requested specifications.
 * Returns FALSE otherwise.
 */
{
#if DEBUG
printf("INIT_OUT_2()\n");
#endif
if (specsarg->flags & (CLIP_LEFT + CLIP_RIGHT + CLIP_TOP + CLIP_BOTTOM))
    return FALSE;           /* Clipping not supported */
return (TRUE); 
}
#endif

#if INCL_OUTLINE
FUNCTION boolean begin_char_outline(Psw, Pmin, Pmax)
GDECL
point_t Psw;       /* End of escapement vector (sub-pixels) */            
point_t Pmin;      /* Bottom left corner of bounding box */             
point_t Pmax;      /* Top right corner of bounding box */
/*
 * If two or more output modules are included in the configuration, begin_char2()
 * is called by begin_char() to signal the start of character output data.
 * If only one output module is included in the configuration, begin_char() is 
 * called by make_simp_char() and make_comp_char().
 */
{
fix31 set_width_x;
fix31 set_width_y;
fix31  xmin;
fix31  xmax;
fix31  ymin;
fix31  ymax;

#if DEBUG
printf("BEGIN_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n", 
                    (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
                    (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
                    (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
#endif
sp_globals.poshift = 16 - sp_globals.pixshift;
set_width_x = (fix31)Psw.x << sp_globals.poshift;
set_width_y = (fix31)Psw.y << sp_globals.poshift;
xmin = (fix31)Pmin.x << sp_globals.poshift;
xmax = (fix31)Pmax.x << sp_globals.poshift;
ymin = (fix31)Pmin.y << sp_globals.poshift;
ymax = (fix31)Pmax.y << sp_globals.poshift;
sp_globals.xmin = Pmin.x;
sp_globals.xmax = Pmax.x;
sp_globals.ymin = Pmin.y;
sp_globals.ymax = Pmax.y;
open_outline(set_width_x, set_width_y, xmin, xmax, ymin, ymax);
return TRUE;
}
#endif

#if INCL_OUTLINE
FUNCTION void begin_sub_char_outline(Psw, Pmin, Pmax)
GDECL
point_t Psw;       /* End of sub-char escapement vector */            
point_t Pmin;      /* Bottom left corner of sub-char bounding box */             
point_t Pmax;      /* Top right corner of sub-char bounding box */
/*
 * If two or more output modules are included in the configuration, begin_sub_char2()
 * is called by begin_sub_char() to signal the start of sub-character output data.
 * If only one output module is included in the configuration, begin_sub_char() is 
 * called by make_comp_char().
 */
{
#if DEBUG
printf("BEGIN_SUB_CHAR_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f\n", 
                    (real)Psw.x / (real)onepix, (real)Psw.y / (real)onepix,
                    (real)Pmin.x / (real)onepix, (real)Pmin.y / (real)onepix,
                    (real)Pmax.x / (real)onepix, (real)Pmax.y / (real)onepix);
#endif
start_new_char();
}
#endif


#if INCL_OUTLINE
FUNCTION void begin_contour_outline(P1, outside)
GDECL
point_t P1;       /* Start point of contour */            
boolean outside;  /* TRUE if outside (counter-clockwise) contour */
/*
 * If two or more output modules are included in the configuration, begin_contour2()
 * is called by begin_contour() to define the start point of a new contour
 * and to indicate whether it is an outside (counter-clockwise) contour
 * or an inside (clockwise) contour.
 * If only one output module is included in the configuration, begin_sub_char() is 
 * called by proc_outl_data().
 */
{
fix15 x,y;
#if DEBUG
printf("BEGIN_CONTOUR_2(%3.1f, %3.1f, %s)\n", 
    (real)P1.x / (real)onepix, (real)P1.y / (real)onepix, outside? "outside": "inside");
#endif
x = RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
y = RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);

start_contour((fix31)x << sp_globals.poshift, (fix31)y << sp_globals.poshift, outside);
}
#endif

#if INCL_OUTLINE
FUNCTION void curve_outline(P1, P2, P3,depth)
GDECL
point_t P1;      /* First control point of Bezier curve */
point_t P2;      /* Second control point of Bezier curve */
point_t P3;      /* End point of Bezier curve */
fix15 depth;
/*
 * If two or more output modules are included in the configuration, curve2()
 * is called by curve() to output one curve segment.
 * If only one output module is included in the configuration, curve() is 
 * called by proc_outl_data().
 * This function is only called when curve output is enabled.
 */
{
fix15 x1,y1,x2,y2,x3,y3;
#if DEBUG
printf("CURVE_2(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n", 
    (real)P1.x / (real)onepix, (real)P1.y / (real)onepix,
    (real)P2.x / (real)onepix, (real)P2.y / (real)onepix,
    (real)P3.x / (real)onepix, (real)P3.y / (real)onepix);
#endif
x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);

x2= RANGECHECK(P2.x,sp_globals.xmin,sp_globals.xmax);
y2= RANGECHECK(P2.y,sp_globals.ymin,sp_globals.ymax);

x3= RANGECHECK(P3.x,sp_globals.xmin,sp_globals.xmax);
y3= RANGECHECK(P3.y,sp_globals.ymin,sp_globals.ymax);

curve_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift,
         (fix31)x2<< sp_globals.poshift, (fix31)y2 << sp_globals.poshift,
         (fix31)x3 << sp_globals.poshift, (fix31)y3 << sp_globals.poshift);
}
#endif

#if INCL_OUTLINE
FUNCTION void line_outline(P1)
GDECL
point_t P1;      /* End point of vector */             
/*
 * If two or more output modules are included in the configuration, line2()
 * is called by line() to output one vector.
 * If only one output module is included in the configuration, line() is 
 * called by proc_outl_data(). If curve output is enabled, line() is also
 * called by split_curve().
 */
{
fix15 x1,y1;
#if DEBUG
printf("LINE_2(%3.1f, %3.1f)\n", (real)P1.x / (real)onepix, (real)P1.y / (real)onepix);
#endif
x1= RANGECHECK(P1.x,sp_globals.xmin,sp_globals.xmax);
y1= RANGECHECK(P1.y,sp_globals.ymin,sp_globals.ymax);

line_to((fix31)x1 << sp_globals.poshift, (fix31)y1 << sp_globals.poshift);
}
#endif

#if INCL_OUTLINE
FUNCTION void end_contour_outline()
GDECL
/*
 * If two or more output modules are included in the configuration, end_contour2()
 * is called by end_contour() to signal the end of a contour.
 * If only one output module is included in the configuration, end_contour() is 
 * called by proc_outl_data().
 */
{
#if DEBUG
printf("END_CONTOUR_2()\n");
#endif
close_contour();
}
#endif


#if INCL_OUTLINE
FUNCTION void end_sub_char_outline()
GDECL
/*
 * If two or more output modules are included in the configuration, end_sub_char2()
 * is called by end_sub_char() to signal the end of sub-character data.
 * If only one output module is included in the configuration, end_sub_char() is 
 * called by make_comp_char().
 */
{
#if DEBUG
printf("END_SUB_CHAR_2()\n");
#endif
}
#endif


#if INCL_OUTLINE
FUNCTION boolean end_char_outline()
GDECL
/*
 * If two or more output modules are included in the configuration, end_char2()
 * is called by end_char() to signal the end of the character data.
 * If only one output module is included in the configuration, end_char() is 
 * called by make_simp_char() and make_comp_char().
 * Returns TRUE if output process is complete
 * Returns FALSE to repeat output of the transformed data beginning
 * with the first contour (of the first sub-char if compound).
 */
{
#if DEBUG
printf("END_CHAR_2()\n");
#endif
close_outline();
return TRUE;
}
#endif