Debian Codegraph @

T1lib/t1lib/t1outline.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*--------------------------------------------------------------------------
2 ----- File: t1outline.c
3 ----- Author: Rainer Menzner ([email protected])
•4 ----- Date: 2005-05-01
5 ----- Description: This file is part of the t1-library. It contains
6 functions for getting glyph outline descriptions of
7 strings and characters.
•8 ----- Copyright: t1lib is copyrighted (c) Rainer Menzner, 1996-2005.
9 As of version 0.5, t1lib is distributed under the
10 GNU General Public Library Lincense. The
11 conditions can be found in the files LICENSE and
12 LGPL, which should reside in the toplevel
13 directory of the distribution. Please note that
14 there are parts of t1lib that are subject to
15 other licenses:
16 The parseAFM-package is copyrighted by Adobe Systems
17 Inc.
18 The type1 rasterizer is copyrighted by IBM and the
19 X11-consortium.
20 ----- Warranties: Of course, there's NO WARRANTY OF ANY KIND :-)
21 ----- Credits: I want to thank IBM and the X11-consortium for making
22 their rasterizer freely available.
23 Also thanks to Piet Tutelaers for his ps2pk, from
24 which I took the rasterizer sources in a format
25 independent from X11.
26 Thanks to all people who make free software living!
27 --------------------------------------------------------------------------*/
28
29 #define T1OUTLINE_C
30
31
32 #include <stdio.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <fcntl.h>
36 #if defined(_MSC_VER)
37 # include <io.h>
38 # include <sys/types.h>
39 # include <sys/stat.h>
40 #else
41 # include <unistd.h>
42 #endif
43 #include <stdlib.h>
44 #include <math.h>
45 #include <string.h>
46 #include <setjmp.h>
47
48 #include "../type1/ffilest.h"
49 #include "../type1/types.h"
50 #include "parseAFM.h"
51 #include "../type1/objects.h"
52 #include "../type1/spaces.h"
53 #include "../type1/util.h"
54 #include "../type1/fontfcn.h"
55 #include "../type1/paths.h"
•56 #include "../type1/regions.h"
57
58
59 #include "t1types.h"
60 #include "t1extern.h"
61 #include "t1set.h"
62 #include "t1load.h"
63 #include "t1finfo.h"
64 #include "t1misc.h"
65 #include "t1base.h"
66 #include "t1outline.h"
67
68
69 /* As a fall back */
70 #ifndef T1_AA_TYPE16
71 #define T1_AA_TYPE16 short
72 #endif
73 #ifndef T1_AA_TYPE32
74 #define T1_AA_TYPE32 int
75 #endif
76
77
78 extern char *t1_get_abort_message( int number);
79 extern struct segment *Type1Line(psfont *env, struct XYspace *S,
80 float line_position,
81 float line_thickness,
82 float line_length);
83 extern struct segment *t1_Join( struct segment *path1,
84 struct segment *path2);
85 extern struct segment *CopyPath( struct segment *p);
86 extern void KillPath( struct segment *p);
87
88
89
90
91 /* T1_SetChar(...): Generate the bitmap for a character */
92 T1_OUTLINE *T1_GetCharOutline( int FontID, char charcode, float size,
93 T1_TMATRIX *transform)
94 {
95 int i;
96 int mode;
97 T1_PATHSEGMENT *charpath;
98 struct XYspace *Current_S;
99 unsigned char ucharcode;
100
101
102 FONTSIZEDEPS *font_ptr;
103 FONTPRIVATE *fontarrayP;
104
105 /* We don't implement underlining for characters, but the rasterer
106 implements it. Thus, we use a modflag of constant 0 */
107 int modflag=0;
108
109
110 /* We return to this if something goes wrong deep in the rasterizer */
111 if ((i=setjmp( stck_state))!=0) {
112 T1_errno=T1ERR_TYPE1_ABORT;
113 sprintf( err_warn_msg_buf, "t1_abort: Reason: %s",
114 t1_get_abort_message( i));
115 T1_PrintLog( "T1_GetCharOutline()", err_warn_msg_buf,
116 T1LOG_ERROR);
117 return( NULL);
118 }
119
120 ucharcode=(unsigned char)charcode;
121
122
123 /* First, check for a correct ID */
•124 i=T1_CheckForFontID(FontID);
125 if (i==-1){
126 T1_errno=T1ERR_INVALID_FONTID;
127 return(NULL);
128 }
129 /* if necessary load font into memory */
130 if (i==0)
131 if (T1_LoadFont(FontID))
132 return(NULL);
133
134 /* Check for valid size */
135 if (size<=0.0){
136 T1_errno=T1ERR_INVALID_PARAMETER;
137 return(NULL);
138 }
139
140 fontarrayP=&(pFontBase->pFontArray[FontID]);
141
142 /* font is now loaded into memory =>
143 Check for size: */
•144 if ((font_ptr=T1int_QueryFontSize( FontID, size, NO_ANTIALIAS))==NULL){
145 font_ptr=T1int_CreateNewFontSize( FontID, size, NO_ANTIALIAS);
146 if (font_ptr==NULL){
147 T1_errno=T1ERR_ALLOC_MEM;
148 return(NULL);
149 }
150 }
151
152 /* Setup an appropriate charspace matrix. Note that the rasterizer
153 assumes vertical values with inverted sign! Transformation should
154 create a copy of the local charspace matrix which then still has
155 to be made permanent. */
156 if (transform!=NULL) {
157 Current_S=(struct XYspace *)
158 Permanent(Scale(Transform (font_ptr->pCharSpaceLocal,
159 transform->cxx, - transform->cxy,
160 transform->cyx, - transform->cyy),
161 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
162 }
163 else{
164 Current_S=(struct XYspace *)
165 Permanent(Scale(Transform(font_ptr->pCharSpaceLocal,
166 1.0, 0.0, 0.0, -1.0),
167 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
168 }
169
170
171 /* fnt_ptr now points to the correct FontSizeDeps-struct =>
172 lets now raster the character */
173 mode=0;
174 charpath=(T1_PATHSEGMENT *)fontfcnB( FontID, modflag, Current_S,
175 fontarrayP->pFontEnc,
176 ucharcode, &mode,
177 fontarrayP->pType1Data,
•178 DO_NOT_RASTER,0.0f);
179 KillSpace (Current_S);
180
181 return((T1_OUTLINE *)charpath);
182 }
183
184
185
186 /* T1_GetStringOutline(...): Generate the outline for a string of
187 characters */
188 T1_OUTLINE *T1_GetStringOutline( int FontID, char *string, int len,
189 long spaceoff, int modflag, float size,
190 T1_TMATRIX *transform)
191 {
192 int i;
193 int mode;
194 /* initialize this to NULL just to be on the safe side */
195 T1_PATHSEGMENT *charpath = NULL;
196 struct XYspace *Current_S;
197 int *kern_pairs; /* use for accessing the kern pairs if kerning is
198 requested */
199 int no_chars=0; /* The number of characters in the string */
200 static int lastno_chars=0;
201 long spacewidth; /* This is given to fontfcnb_string() */
202
203
204 FONTSIZEDEPS *font_ptr;
205 FONTPRIVATE *fontarrayP;
206
207 static int *pixel_h_anchor_corr=NULL;
208 static int *flags=NULL;
209
210 unsigned char *ustring;
211
212
213 /* We return to this if something goes wrong deep in the rasterizer */
214 if ((i=setjmp( stck_state))!=0) {
215 T1_errno=T1ERR_TYPE1_ABORT;
216 sprintf( err_warn_msg_buf, "t1_abort: Reason: %s",
217 t1_get_abort_message( i));
218 T1_PrintLog( "T1_GetStringOutline()", err_warn_msg_buf,
219 T1LOG_ERROR);
220 return( NULL);
221 }
222
223 /* force string elements into unsigned */
224 ustring=(unsigned char*)string;
225
226 /* First, check for a correct ID */
•227 i=T1_CheckForFontID(FontID);
228 if (i==-1){
229 T1_errno=T1ERR_INVALID_FONTID;
230 return(NULL);
231 }
232 /* if necessary load font into memory */
233 if (i==0)
234 if (T1_LoadFont(FontID))
235 return(NULL);
236
237 /* If no AFM info is present, we return an error */
238 if (pFontBase->pFontArray[FontID].pAFMData==NULL) {
239 T1_errno=T1ERR_NO_AFM_DATA;
240 return(NULL);
241 }
242
243 /* Check for valid size */
244 if (size<=0.0){
245 T1_errno=T1ERR_INVALID_PARAMETER;
246 return(NULL);
247 }
248
249 fontarrayP=&(pFontBase->pFontArray[FontID]);
250
251 /* font is now loaded into memory =>
252 Check for size: */
•253 if ((font_ptr=T1int_QueryFontSize( FontID, size, NO_ANTIALIAS))==NULL){
254 font_ptr=T1int_CreateNewFontSize( FontID, size, NO_ANTIALIAS);
255 if (font_ptr==NULL){
256 T1_errno=T1ERR_ALLOC_MEM;
257 return(NULL);
258 }
259 }
260
261 /* Now comes string specific stuff: Get length of string and create an
262 array of integers where to store the bitmap positioning dimens: */
263 if (len<0){ /* invalid length */
264 T1_errno=T1ERR_INVALID_PARAMETER;
265 return(NULL);
266 }
267
268 if (len==0) /* should be computed assuming "normal" 0-terminated string */
269 no_chars=strlen(string);
270 else /* use value given on command line */
271 no_chars=len;
272
273 /* If necessary, allocate memory */
274 if (no_chars>lastno_chars){
275 if (pixel_h_anchor_corr!=NULL){
276 free(pixel_h_anchor_corr);
277 }
278 if (flags!=NULL){
279 free(flags);
280 }
281
282 pixel_h_anchor_corr=(int *)calloc(no_chars, sizeof(int));
283 flags=(int *)calloc(no_chars, sizeof(int));
284 lastno_chars=no_chars;
285 }
286 else{
287 /* Reset flags and position array */
288 for (i=0; i<no_chars; i++){
289 flags[i]=0;
290 pixel_h_anchor_corr[i]=0;
291 }
292 }
293
294 /* Setup an appropriate charspace matrix. Note that the rasterizer
295 assumes vertical values with inverted sign! Transformation should
296 create a copy of the local charspace matrix which then still has
297 to be made permanent. */
298 if (transform!=NULL){
299 Current_S=(struct XYspace *)
300 Permanent(Scale(Transform (font_ptr->pCharSpaceLocal,
301 transform->cxx, - transform->cxy,
302 transform->cyx, - transform->cyy),
303 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
304 }
305 else{
306 Current_S=(struct XYspace *)
307 Permanent(Scale(Transform(font_ptr->pCharSpaceLocal,
308 1.0, 0.0, 0.0, -1.0),
309 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
310 }
311
312 /* Compute the correct spacewidth value (in charspace units). The
313 value supplied by the user is interpreted as an offset in
314 char space units:
315 */
316 spacewidth=T1_GetCharWidth(FontID,fontarrayP->space_position)+spaceoff;
317
318 mode=0;
319 kern_pairs=(int *)calloc(no_chars, sizeof(int));
320 if ((modflag & T1_KERNING))
321 for (i=0; i<no_chars -1; i++)
322 kern_pairs[i]=T1_GetKerning( FontID, ustring[i], ustring[i+1]);
323 charpath=(T1_PATHSEGMENT *) fontfcnB_string( FontID, modflag, Current_S,
324 fontarrayP->pFontEnc,
325 (unsigned char *)string,
326 no_chars, &mode,
327 fontarrayP->pType1Data,
328 kern_pairs, spacewidth,
•329 DO_NOT_RASTER,0.0f);
330 KillSpace (Current_S);
331
332 /* In all cases, free memory for kerning pairs */
333 free(kern_pairs);
334
335 /* fill the string_glyph-structure */
336 if (mode != 0) {
337 sprintf( err_warn_msg_buf, "fontfcnB_string() set mode=%d", mode);
338 T1_PrintLog( "T1_GetStringOutline()", err_warn_msg_buf, T1LOG_WARNING);
339 T1_errno=mode;
340 /* make sure to get rid of path if it's there */
341 if (charpath){
342 KillRegion (charpath);
343 }
344 return(NULL);
345 }
346 if (charpath == NULL){
347 T1_PrintLog( "T1_GetStringOutline()", "path=NULL returned by fontfcnB_string()", T1LOG_WARNING);
348 T1_errno=mode;
349 return(NULL);
350 }
351
352 return( (T1_OUTLINE *)charpath);
353 }
354
355
356 /* T1_GetMoveOutline(...): Generate the "outline" for a movement
357 */
358 T1_OUTLINE *T1_GetMoveOutline( int FontID, int deltax, int deltay, int modflag,
359 float size, T1_TMATRIX *transform)
360 {
361 int i;
362 FONTSIZEDEPS *font_ptr;
363 struct segment *path, *tmppath;
364 struct XYspace *Current_S;
365 psfont *FontP;
366 float length;
367
368
369 /* We return to this if something goes wrong deep in the rasterizer */
370 if ((i=setjmp( stck_state))!=0) {
371 T1_errno=T1ERR_TYPE1_ABORT;
372 sprintf( err_warn_msg_buf, "t1_abort: Reason: %s",
373 t1_get_abort_message( i));
374 T1_PrintLog( "T1_GetMoveOutline()", err_warn_msg_buf,
375 T1LOG_ERROR);
376 return( NULL);
377 }
378
379
380 /* First, check for a correct ID */
•381 i=T1_CheckForFontID(FontID);
382 if (i==-1){
383 T1_errno=T1ERR_INVALID_FONTID;
384 return(NULL);
385 }
386 /* if necessary load font into memory */
387 if (i==0)
388 if (T1_LoadFont(FontID))
389 return(NULL);
390
391 /* Check for valid size */
392 if (size<=0.0){
393 T1_errno=T1ERR_INVALID_PARAMETER;
394 return(NULL);
395 }
396
397 FontP=pFontBase->pFontArray[i].pType1Data;
398
399 /* font is now loaded into memory =>
400 Check for size: */
•401 if ((font_ptr=T1int_QueryFontSize( FontID, size, NO_ANTIALIAS))==NULL){
402 font_ptr=T1int_CreateNewFontSize( FontID, size, NO_ANTIALIAS);
403 if (font_ptr==NULL){
404 T1_errno=T1ERR_ALLOC_MEM;
405 return(NULL);
406 }
407 }
408
409 /* Setup an appropriate charspace matrix. Note that the rasterizer
410 assumes vertical values with inverted sign! Transformation should
411 create a copy of the local charspace matrix which then still has
412 to be made permanent. */
413 if (transform!=NULL){
414 Current_S=(struct XYspace *)
415 Permanent(Scale(Transform (font_ptr->pCharSpaceLocal,
416 transform->cxx, - transform->cxy,
417 transform->cyx, - transform->cyy),
418 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
419 }
420 else{
421 Current_S=(struct XYspace *)
422 Permanent(Scale(Transform(font_ptr->pCharSpaceLocal,
423 1.0, 0.0, 0.0, -1.0),
424 DeviceSpecifics.scale_x, DeviceSpecifics.scale_y));
425 }
426
427
428 path=(struct segment *)ILoc( Current_S, deltax, deltay);
429
430 /* Take care for underlining and such */
431 length=(float) deltax;
432 if (modflag & T1_UNDERLINE){
433 tmppath=(struct segment *)Type1Line(FontP,Current_S,
434 pFontBase->pFontArray[FontID].UndrLnPos,
435 pFontBase->pFontArray[FontID].UndrLnThick,
436 length);
437 path=(struct segment *)Join(path,tmppath);
438 }
439 if (modflag & T1_OVERLINE){
440 tmppath=(struct segment *)Type1Line(FontP,Current_S,
441 pFontBase->pFontArray[FontID].OvrLnPos,
442 pFontBase->pFontArray[FontID].OvrLnThick,
443 length);
444 path=(struct segment *)Join(path,tmppath);
445 }
446 if (modflag & T1_OVERSTRIKE){
447 tmppath=(struct segment *)Type1Line(FontP,Current_S,
448 pFontBase->pFontArray[FontID].OvrStrkPos,
449 pFontBase->pFontArray[FontID].OvrStrkThick,
450 length);
451 path=(struct segment *)Join(path,tmppath);
452 }
453
454 KillSpace( Current_S);
455
456 return( (T1_OUTLINE *)path);
457
458 }
459
460
461 /* T1_ConcatOutlines(): Concatenate two outline to one path */
462 T1_OUTLINE *T1_ConcatOutlines( T1_OUTLINE *path1, T1_OUTLINE *path2)
463 {
464
465 return( (T1_OUTLINE *) t1_Join( (struct segment *) path1,
466 (struct segment *) path2));
467
468 }
469
470
471 /* T1_ScaleOutline(): Scale an outline */
472 T1_OUTLINE *T1_ScaleOutline( T1_OUTLINE *path, float scale)
473 {
474 struct segment *ipath;
475
476 /* Step through the path list */
477 ipath=(struct segment *)path;
478
479 do {
480 if (ipath->type==LINETYPE){
481 ipath->dest.x = (fractpel) (ipath->dest.x * scale);
482 ipath->dest.y = (fractpel) (ipath->dest.y * scale);
483 }
484 if (ipath->type==CONICTYPE){
485 ((struct conicsegment *)ipath)->dest.x =
486 (fractpel) ((struct conicsegment *)ipath)->dest.x * scale;
487 ((struct conicsegment *)ipath)->dest.y =
488 (fractpel) ((struct conicsegment *)ipath)->dest.y * scale;
489 ((struct conicsegment *)ipath)->M.x =
490 (fractpel) ((struct conicsegment *)ipath)->M.x * scale;
491 ((struct conicsegment *)ipath)->M.y =
492 (fractpel) ((struct conicsegment *)ipath)->M.y * scale;
493 }
494 if (ipath->type==MOVETYPE){
495 ipath->dest.x = (fractpel) (ipath->dest.x * scale);
496 ipath->dest.y = (fractpel) (ipath->dest.y * scale);
497 }
498 if (ipath->type==BEZIERTYPE){
499 ((struct beziersegment *)ipath)->B.x =
500 (fractpel) (((struct beziersegment *)ipath)->B.x * scale);
501 ((struct beziersegment *)ipath)->B.y =
502 (fractpel) (((struct beziersegment *)ipath)->B.y * scale);
503 ((struct beziersegment *)ipath)->C.x =
504 (fractpel) (((struct beziersegment *)ipath)->C.x * scale);
505 ((struct beziersegment *)ipath)->C.y =
506 (fractpel) (((struct beziersegment *)ipath)->C.y * scale);
507 ((struct beziersegment *)ipath)->dest.x =
508 (fractpel) (((struct beziersegment *)ipath)->dest.x * scale);
509 ((struct beziersegment *)ipath)->dest.y =
510 (fractpel) (((struct beziersegment *)ipath)->dest.y * scale);
511 }
512 if (ipath->type==HINTTYPE){
513 ((struct hintsegment *)ipath)->dest.x =
514 (fractpel) (((struct hintsegment *)ipath)->dest.x * scale);
515 ((struct hintsegment *)ipath)->dest.y =
516 (fractpel) (((struct hintsegment *)ipath)->dest.y * scale);
517 ((struct hintsegment *)ipath)->ref.x =
518 (fractpel) (((struct hintsegment *)ipath)->ref.x * scale);
519 ((struct hintsegment *)ipath)->ref.y =
520 (fractpel) (((struct hintsegment *)ipath)->ref.y * scale);
521 ((struct hintsegment *)ipath)->width.x =
522 (fractpel) (((struct hintsegment *)ipath)->width.x * scale);
523 ((struct hintsegment *)ipath)->width.y =
524 (fractpel) (((struct hintsegment *)ipath)->width.y * scale);
525 }
526 if (ipath->type==TEXTTYPE)
527 ;
528 ipath=ipath->link;
529
530 } while (ipath!=NULL);
531
532 return( path);
533
534 }
535
536
537 /* dump a description of path elements to stdout */
538 void T1_DumpPath( T1_OUTLINE *path)
539 {
540
541 struct segment *ipath;
542
543 /* Step through the path list */
544 ipath=(struct segment *)path;
545
546 do {
547 if (ipath->type==LINETYPE){
548 printf("Line-Segment: -> (%f,%f)\n",
549 (ipath->dest.x)/(double)(0xFFFF),
550 -(ipath->dest.y)/(double)(0xFFFF));
551 }
552 if (ipath->type==MOVETYPE){
553 printf("Move-Segment: -> (%f,%f)\n",
554 (ipath->dest.x)/(double)(0xFFFF),
555 -(ipath->dest.y)/(double)(0xFFFF));
556 }
557 if (ipath->type==BEZIERTYPE){
558 printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n",
559 (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF),
560 -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF),
561 (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF),
562 -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF),
563 (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF),
564 -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));
565 }
566 ipath=ipath->link;
567 } while (ipath!=NULL);
568
569 }
570
571
572 /* convert a relative path to an absolute path */
573 void T1_AbsolutePath( T1_OUTLINE *rpath)
574 {
575
576 struct segment *ipath;
577 fractpel xcurr=0, ycurr=0;
578
579 /* Step through the path list */
580 ipath=(struct segment *)rpath;
581
582 do {
583 if (ipath->type==LINETYPE){
584 ipath->dest.x +=xcurr;
585 ipath->dest.y +=ycurr;
586 #ifdef PRINT_PATHS_TO_STDOUT
587 printf("Line-Segment: -> (%f,%f)\n",
588 (ipath->dest.x)/(double)(0xFFFF),
589 -(ipath->dest.y)/(double)(0xFFFF));
590 #endif
591 xcurr=ipath->dest.x;
592 ycurr=ipath->dest.y;
593 }
594 if (ipath->type==MOVETYPE){
595 ipath->dest.x +=xcurr;
596 ipath->dest.y +=ycurr;
597 #ifdef PRINT_PATHS_TO_STDOUT
598 printf("Move-Segment: -> (%f,%f)\n",
599 (ipath->dest.x)/(double)(0xFFFF),
600 -(ipath->dest.y)/(double)(0xFFFF));
601 #endif
602 xcurr=ipath->dest.x;
603 ycurr=ipath->dest.y;
604 }
605 if (ipath->type==BEZIERTYPE){
606 ((struct beziersegment *)ipath)->B.x +=xcurr;
607 ((struct beziersegment *)ipath)->B.y +=ycurr;
608 ((struct beziersegment *)ipath)->C.x +=xcurr;
609 ((struct beziersegment *)ipath)->C.y +=ycurr;
610 ipath->dest.x +=xcurr;
611 ipath->dest.y +=ycurr;
612 #ifdef PRINT_PATHS_TO_STDOUT
613 printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n",
614 (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF),
615 -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF),
616 (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF),
617 -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF),
618 (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF),
619 -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));
620 #endif
621 xcurr=ipath->dest.x;
622 ycurr=ipath->dest.y;
623 }
624 ipath=ipath->link;
625 } while (ipath!=NULL);
626
627 }
628
629
630
631 /* convert path into a relative path as needed by the rasterizer */
632 void T1_RelativePath( T1_OUTLINE *apath)
633 {
634
635 struct segment *ipath;
636 fractpel xcurr=0, ycurr=0;
637
638
639 /* Step through the path list */
640 ipath=(struct segment *)apath;
641
642 do {
643 if (ipath->type==LINETYPE){
644 ipath->dest.x -=xcurr;
645 ipath->dest.y -=ycurr;
646 xcurr +=ipath->dest.x;
647 ycurr +=ipath->dest.y;
648 #ifdef PRINT_PATHS_TO_STDOUT
649 printf("Line-Segment: -> (%f,%f), curr=(%f,%f)\n",
650 (ipath->dest.x)/(double)(0xFFFF),
651 -(ipath->dest.y)/(double)(0xFFFF),
652 xcurr/(double)(0xFFFF), -ycurr/(double)(0xFFFF));
653 #endif
654 }
655 if (ipath->type==MOVETYPE){
656 ipath->dest.x -=xcurr;
657 ipath->dest.y -=ycurr;
658 xcurr +=ipath->dest.x;
659 ycurr +=ipath->dest.y;
660 #ifdef PRINT_PATHS_TO_STDOUT
661 printf("Move-Segment: -> (%f,%f), curr=(%f,%f)\n",
662 (ipath->dest.x)/(double)(0xFFFF),
663 -(ipath->dest.y)/(double)(0xFFFF),
664 xcurr/(double)(0xFFFF), -ycurr/(double)(0xFFFF));
665 #endif
666 }
667 if (ipath->type==BEZIERTYPE){
668 ipath->dest.x -=xcurr;
669 ipath->dest.y -=ycurr;
670 ((struct beziersegment *)ipath)->C.x -=xcurr;
671 ((struct beziersegment *)ipath)->C.y -=ycurr;
672 ((struct beziersegment *)ipath)->B.x -=xcurr;
673 ((struct beziersegment *)ipath)->B.y -=ycurr;
674 xcurr +=ipath->dest.x;
675 ycurr +=ipath->dest.y;
676 #ifdef PRINT_PATHS_TO_STDOUT
677 printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n",
678 (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF),
679 -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF),
680 (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF),
681 -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF),
682 (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF),
683 -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));
684 #endif
685 }
686 ipath=ipath->link;
687 } while (ipath!=NULL);
688
689 }
690
691
692 /* maniuplate the coordinata points of a path */
693 void T1_ManipulatePath( T1_OUTLINE *path,
694 void (*manipulate)(fractpel *x,fractpel *y,int type))
695 {
696
697 struct segment *ipath;
698
699
700 /* Step through the path list */
701 ipath=(struct segment *)path;
702
703 do {
704 if (ipath->type==LINETYPE){
705 manipulate( &(ipath->dest.x), &ipath->dest.y, LINETYPE);
706 #ifdef PRINT_PATHS_TO_STDOUT
707 printf("Line-Segment: -> (%f,%f)\n",
708 (ipath->dest.x)/(double)(0xFFFF),
709 -(ipath->dest.y)/(double)(0xFFFF));
710 #endif
711 }
712 if (ipath->type==MOVETYPE){
713 manipulate( &(ipath->dest.x), &ipath->dest.y, MOVETYPE);
714 #ifdef PRINT_PATHS_TO_STDOUT
715 printf("Move-Segment: -> (%f,%f)\n",
716 (ipath->dest.x)/(double)(0xFFFF),
717 -(ipath->dest.y)/(double)(0xFFFF));
718 #endif
719 }
720 if (ipath->type==BEZIERTYPE){
721 manipulate( &((struct beziersegment *)ipath)->B.x,
722 &((struct beziersegment *)ipath)->B.y,
723 BEZIERTYPE);
724 manipulate( &((struct beziersegment *)ipath)->C.x,
725 &((struct beziersegment *)ipath)->C.y,
726 BEZIERTYPE);
727 manipulate( &((struct beziersegment *)ipath)->dest.x,
728 &((struct beziersegment *)ipath)->dest.y,
729 BEZIERTYPE);
730 #ifdef PRINT_PATHS_TO_STDOUT
731 printf("Bezier-Segment: ... (%f,%f) ... (%f,%f) -> (%f,%f)\n",
732 (((struct beziersegment *)ipath)->B.x)/(double)(0xFFFF),
733 -(((struct beziersegment *)ipath)->B.y)/(double)(0xFFFF),
734 (((struct beziersegment *)ipath)->C.x)/(double)(0xFFFF),
735 -(((struct beziersegment *)ipath)->C.y)/(double)(0xFFFF),
736 (((struct beziersegment *)ipath)->dest.x)/(double)(0xFFFF),
737 -(((struct beziersegment *)ipath)->dest.y)/(double)(0xFFFF));
738 #endif
739 }
740 ipath=ipath->link;
741 } while (ipath!=NULL);
742
743 }
744
745
746
747 /* T1_CopyOutline(): Copy an outline physically.
748 Returns a pointer to the path or NULL */
749 T1_OUTLINE *T1_CopyOutline( T1_OUTLINE *path)
750 {
751
752 return( (T1_OUTLINE *) CopyPath( (struct segment *)path));
753
754 }
755
756
757
758 /* T1_FreeOutline(): Free an outline. */
759 void T1_FreeOutline( T1_OUTLINE *path)
760 {
761
762 KillPath( (struct segment *)path);
763 return;
764
765 }
766