Subversion Repositories Scribus

Rev

Rev 4717 | Rev 4733 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
290 Franz 1
%
2
% psi.prolog
3
%
4
% Copyright (C) 1996-2000 by vhf computer GmbH + vhf interservice GmbH
5
% Author:   Georg Fleischmann
6
%
7
% created:  2000-09-09
8
% modified:
9
%
4717 avox 10
 
11
%%% this file also contains a section taken from GPL Ghostscript 8.50 "traceimg.ps", see below
12
 
290 Franz 13
% this PostScript code writes a file with the structure below.
14
% # # # # l		(x0 y0 x1 y1) line
15
% # # # # # # # #c	(x0 y0 x1 y1 x2 y2 x3 y3) curve
16
% # w			(width) width
17
% # # # # # co		(c m y k a) color
18
% n			new list
19
% f			list is a filled polygon
20
% s			list is a group
21
% cl			list is a clip list (clip with old clip list and use it)
22
% gs			save current clip list and width to top of stack
23
% gr			use last clip list (on top of stack) and width
24
% # # # # # # # # # #	(x y a b c d e f text font) text
25
%
26
% Adapted for Scribus by Franz Schmid 15.05.2004
27
% Also removed the hardcoded Output Filename
28
% and changed it in a way the -sOutputFile Option of Ghostscript can be used
29
% Speeded up the flattening of Text by removing unneeded calculations.
30
% Changed the Output slightly to ease parsing
31
% m                 moveto
32
% l # # # #         (x0 y0 x1 y1) line
33
% c # # # # # # # # (x0 y0 x1 y1 x2 y2 x3 y3) curve
34
% w #               (width) Linewidth
35
% co # # # # #      (c m y k a) color
36
% n                 new list
37
% f                 list is a filled polygon
38
% s                 list is a stroke path
39
% cp                close current subpath
40
% ci                list is a clip list (clip with old clip list and use it)
292 Franz 41
% sp                end of page
42
% lj #              linejoin
43
% lc #              linecap
44
% ld # # #n         linedash count offset d1, d2, dx
4717 avox 45
% im #              image <name>
290 Franz 46
% 15.05.2004 Added the Glyphshow Operator.
47
% 17.05.2004 Made clipping working.
48
% 20.05.2004 kshow is working now.
4717 avox 49
% 22.02.2006 added image and colorimage ops
290 Franz 50
 
51
/cfile OutputFile (w) file def
52
/print { cfile exch writestring } bind def
53
 
54
% whether we have to flatten the text
55
/flattenText 1 def
56
 
57
% is a Clipping there
58
/clipCnt 0 def
59
 
60
% remember the current point
61
/currentX 0 def
62
/currentY 0 def
63
 
64
% 1st point of path to close the path
65
/beginX 0 def
66
/beginY 0 def
67
 
68
% dummy for converting strings
4725 avox 69
/i_str 50 string def
290 Franz 70
 
71
% 0 = mirror at
72
/mirror 0 def
73
 
74
% mirror a at 0
75
/mir
76
{
77
	mirror 0 ne
78
	{	0 exch sub
79
	}if
80
} bind def
81
 
82
% scale
83
/m_a 1 def
84
/m_b 0 def
85
/m_c 0 def
86
/m_d 1 def
87
/m_x 0 def
88
/m_y 0 def
89
/matrix_x	% x y
90
{
91
	% ax + cy + tx
92
	m_c mul exch m_a mul add m_x add
93
} bind def
94
/matrix_y	% x y
95
{
96
	% bx + dy + ty
97
	m_d mul exch m_b mul add m_y add
98
} bind def
99
 
100
/writecurrentcolor
101
{
102
	currentcolorspace 0 get /CIEBasedABC eq
103
	{	currentcolor setrgbcolor
104
	} if
1488 fschmid 105
	currentcolorspace 0 get /DeviceRGB eq
106
	{
107
		currentrgbcolor	% -> r g b
108
		(corgb )print
4725 avox 109
		2 index i_str cvs print
1488 fschmid 110
		( ) print
4725 avox 111
		1 index i_str cvs print
1488 fschmid 112
		( ) print
4725 avox 113
		i_str cvs print
1488 fschmid 114
		( ) print
115
		pop pop
116
		.currentopacityalpha	% a
4725 avox 117
		i_str cvs print
1488 fschmid 118
		(\n) print
119
	}
120
	{
121
		currentcmykcolor	% -> c m y k
122
		(co )print
4725 avox 123
		3 index i_str cvs print
1488 fschmid 124
		( ) print
4725 avox 125
		2 index i_str cvs print
1488 fschmid 126
		( ) print
4725 avox 127
		1 index i_str cvs print
1488 fschmid 128
		( ) print
4725 avox 129
		i_str cvs print
1488 fschmid 130
		( ) print
131
		pop pop pop
132
		.currentopacityalpha	% a
4725 avox 133
		i_str cvs print
1488 fschmid 134
		(\n) print
135
	} ifelse
290 Franz 136
 
137
} bind def
138
 
292 Franz 139
/writecurrentlinecap
140
{
141
	(lc ) print
4725 avox 142
	currentlinecap i_str cvs print
292 Franz 143
	(\n) print
144
} bind def
145
 
146
/writecurrentlinejoin
147
{
148
	(lj ) print
4725 avox 149
	currentlinejoin i_str cvs print
292 Franz 150
	(\n) print
151
} bind def
152
 
153
/writecurrentdash
154
{
155
	(ld ) print
4725 avox 156
	currentdash 1 index length i_str cvs print ( ) print i_str cvs print ( ) print
292 Franz 157
 
158
	{
4725 avox 159
		1 index exch get i_str cvs print ( ) print
292 Franz 160
	} for
161
	pop
162
	(\n) print
163
} bind def
164
 
290 Franz 165
/writecurrentlinewidth
166
{
167
	userdict begin
168
	currentlinewidth	% w
169
	storeMatrix
170
 
171
	% (wb + wd + wa + wc) / 2
172
	dup dup dup m_b abs mul exch m_d abs mul add  exch m_a abs mul add  exch m_c abs mul add  2 div  abs
173
	(w ) print
4725 avox 174
	i_str cvs print
290 Franz 175
	(\n) print
176
	end
177
} bind def
178
 
179
/_move	% x y
180
{
181
	userdict begin
182
	(m\n) print
183
	/currentY exch def
184
	/currentX exch def
185
	/beginX currentX def
186
	/beginY currentY def
187
	end
188
} bind def
189
 
190
/_line
191
{
192
	userdict begin
193
	/y1 exch def
194
	/x1 exch def
195
 
196
	% x x1 ne y y1 ne or
197
	currentX x1 sub abs 0.001 gt  currentY y1 sub abs 0.001 gt or
198
	{
199
		(l ) print
4725 avox 200
		currentX currentY matrix_x i_str cvs print
290 Franz 201
		( ) print
4725 avox 202
		currentX currentY matrix_y i_str cvs print
290 Franz 203
		( ) print
204
 
4725 avox 205
		x1 y1 matrix_x i_str cvs print
290 Franz 206
		( ) print
4725 avox 207
		x1 y1 matrix_y i_str cvs print
290 Franz 208
		(\n) print
209
		/currentX x1 def
210
		/currentY y1 def
211
	}if
212
	end
213
} bind def
214
 
215
/_curve
216
{
217
	userdict begin
218
	% x1 y1 x2 y2 x3 y3
219
	(c ) print
4725 avox 220
	currentX currentY matrix_x i_str cvs print
290 Franz 221
	( ) print
4725 avox 222
	currentX currentY matrix_y i_str cvs print
290 Franz 223
	( ) print
4725 avox 224
	5 index 5 index matrix_x i_str cvs print
290 Franz 225
	( ) print
4725 avox 226
	5 index 5 index matrix_y i_str cvs print
290 Franz 227
	( ) print
4725 avox 228
	3 index 3 index matrix_x i_str cvs print
290 Franz 229
	( ) print
4725 avox 230
	3 index 3 index matrix_y i_str cvs print
290 Franz 231
	( ) print
232
 
233
	/currentY exch def
234
	/currentX exch def
235
 
4725 avox 236
	currentX currentY matrix_x i_str cvs print
290 Franz 237
	( ) print
4725 avox 238
	currentX currentY matrix_y i_str cvs print
290 Franz 239
	(\n)print
240
	pop pop pop pop
241
	end
242
} bind def
243
 
244
% modified: 18.10.96
245
/_close
246
{
247
	(cp\n) print
248
	beginX beginY _line
249
} bind def
250
 
251
/storeMatrix
252
{
253
	userdict begin
254
	matrix currentmatrix
255
 
256
	matrix currentmatrix
257
	1 get /m_b exch def
258
	matrix currentmatrix
259
	2 get /m_c exch def
260
	matrix currentmatrix
261
	3 get /m_d exch def
262
	matrix currentmatrix
263
	4 get /m_x exch def
264
	matrix currentmatrix
265
	5 get /m_y exch def
266
	end
267
} bind def
268
 
269
/rectfill
270
{
271
	userdict begin
272
	(n\n)print			% start polygon
273
	writecurrentcolor
274
	writecurrentlinewidth
292 Franz 275
	writecurrentlinecap
276
	writecurrentlinejoin
277
	writecurrentdash
290 Franz 278
	storeMatrix
279
 
280
	% x y width height
281
	dup type /arraytype ne
282
	{
283
		/hr exch def
284
		/wr exch def
285
		/yr exch def
286
		/xr exch def
287
		xr yr _move
288
		xr wr add yr _line
289
		xr wr add yr hr add _line
290
		xr yr hr add _line
291
		xr yr _line
292
	}
293
	% numarray
294
	% numstring
295
	{
296
		/ar exch def
297
 
298
		{
299
			/n exch def
300
			ar n get /xr exch def
301
			ar n 1 add get /yr exch def
302
			ar n 2 add get /wr exch def
303
			ar n 3 add get /hr exch def
304
			xr yr _move
305
			xr wr add yr _line
306
			xr wr add yr hr add _line
307
			xr yr hr add _line
308
			xr yr _line
309
		} for
310
	}ifelse
311
 
312
	(f\n)print			% close polygon
313
	end
314
} bind def
315
 
316
/rectstroke
317
{
318
	userdict begin
319
	(n\n)print			% start rect
320
	writecurrentcolor
321
	writecurrentlinewidth
292 Franz 322
	writecurrentlinecap
323
	writecurrentlinejoin
324
	writecurrentdash
290 Franz 325
	storeMatrix
326
 
327
	% x y width height
328
	dup type /arraytype ne
329
	{
330
		/hr exch def
331
		/wr exch def
332
		/yr exch def
333
		/xr exch def
334
		xr yr _move
335
		xr wr add yr _line
336
		xr wr add yr hr add _line
337
		xr yr hr add _line
338
		xr yr _line
339
	}
340
	% numarray
341
	% numstring
342
	{
343
		/ar exch def
344
 
345
		{
346
			/n exch def
347
			ar n get /xr exch def
348
			ar n 1 add get /yr exch def
349
			ar n 2 add get /wr exch def
350
			ar n 3 add get /hr exch def
351
			xr yr _move
352
			xr wr add yr _line
353
			xr wr add yr hr add _line
354
			xr yr hr add _line
355
			xr yr _line
356
		} for
357
	}ifelse
358
	(n\n)print			% stroke rect
359
	end
360
} bind def
361
 
362
/stroke
363
{
364
	(n\n) print
365
	writecurrentcolor
366
	writecurrentlinewidth
292 Franz 367
	writecurrentlinecap
368
	writecurrentlinejoin
369
	writecurrentdash
4642 avox 370
	clipCnt 1 eq
371
		{ clipsave clip newpath clippath cliprestore } if
290 Franz 372
	storeMatrix
373
	{_move} {_line} {_curve} {_close} pathforall
374
	(s\n)print			% stroke path
375
	newpath
376
} bind def
377
 
378
/eofill
379
{
380
	(n\n) print			% start polygon
381
	writecurrentcolor	% write color
382
	writecurrentlinewidth
292 Franz 383
	writecurrentlinecap
384
	writecurrentlinejoin
385
	writecurrentdash
4642 avox 386
	clipCnt 1 eq
387
		{ clipsave clip newpath clippath cliprestore } if
290 Franz 388
	storeMatrix			% take transformation, scaling, rotation from PostScript
389
	{_move} {_line} {_curve} {_close} pathforall
390
	(f\n)print			% close polygon
391
 
392
	newpath				% clear stack
393
} bind def
394
 
395
/fill
396
{
397
	eofill
398
} bind def
399
 
400
/clip
401
{
402
	userdict begin
403
	(n\n)print			% start clip polygon
404
 
405
	storeMatrix			% take transformation, scaling, rotation from PostScript
406
	{_move} {_line} {_curve} {_close} pathforall
407
 
408
	(ci\n)print			% close clip polygon begin path
409
						% we have to close the path!!
410
	clip
411
	/clipCnt 1 def
412
	newpath				% clear stack
413
	end
414
} bind def
415
 
416
% we don't clip
417
% because this doesn't work for flattening text (show, charpath) with NeXT PostScript Code
418
/rectclip
419
{
4717 avox 420
	% let Scribus decide what to do with rci: pop pop pop pop
421
	(rci ) print
4725 avox 422
	i_str cvs print ( ) print
423
	i_str cvs print ( ) print
424
	i_str cvs print ( ) print
425
	i_str cvs print (\n) print
290 Franz 426
} bind def
427
 
4717 avox 428
 
429
%    Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
430
%
431
% This software is provided AS-IS with no warranty, either express or
432
% implied.
433
%
434
% This software is distributed under license and may not be copied,
435
% modified or distributed except as expressly authorized under the terms
436
% of the license contained in the file LICENSE in this distribution.
437
%
438
% For more information about licensing, please refer to
439
% http://www.ghostscript.com/licensing/. For information on
440
% commercial licensing, go to http://www.artifex.com/licensing/ or
441
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
442
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
443
 
444
% $Id: import.prolog 4725 2006-02-25 05:52:28Z avox $
445
% traceimg.ps
446
% Trace the data supplied to the 'image' operator.
447
 
448
% This code currently handles only the (Level 2) dictionary form of image,
449
% with a single data source and 8-bit pixels.
450
 
451
% changed for Scribus image import by Andreas Vox, 2006-2-21
452
% added support for colorimage and other image variant
453
 
454
/concatenate   % str1 str2 concatenate str12
455
{
456
	dup length 2 index length add string
457
	dup 3 index length 3 index putinterval
458
	dup 0 4 index putinterval
459
	exch pop exch pop
460
} bind def
461
 
462
/==write  % any ==write -
463
{
464
	dup type dup /arraytype eq exch /packedarraytype eq or
465
	{
466
		i_file ([) writestring
467
			{ ==write i_file ( ) writestring } forall
468
		i_file (]) writestring
469
	} {
470
	dup type /nametype eq
471
	{
4725 avox 472
		i_file (/) writestring i_file exch i_str cvs writestring
4717 avox 473
	} {
474
	dup type /dicttype eq
475
	{
476
		i_file (<<) writestring
477
		{ ==write ( ) ==write ==write (\n) ==write } forall
478
		i_file (>>) writestring
479
	} {
4725 avox 480
		i_file exch i_str cvs writestring
4717 avox 481
	} ifelse } ifelse } ifelse
482
} def
483
 
4725 avox 484
/i_image			% <dict> i_image -
4717 avox 485
{
486
	begin
487
		/i_left Width Height mul Decode length 2 idiv mul BitsPerComponent mul 8 idiv dup /i_size exch store store
488
		/i_dict currentdict store
489
		/i_nsources 1 store
490
		/i_source 0 store
491
		/i_datasource currentdict /DataSource get store
492
		currentdict /MultipleDataSources known not
493
			{ /MultipleDataSources false def } if
494
		MultipleDataSources
495
		{
496
			/i_nsources  DataSource length store
497
			/i_datasource DataSource 0 get store
498
		} if
499
	end
500
	storeMatrix
501
	i_dict /ImageMatrix get matrix invertmatrix matrix currentmatrix matrix concatmatrix /i_m exch def
502
	i_dict /Width get  0 i_m dtransform dup mul exch dup mul add sqrt /i_w exch def
503
 
504
 
505
	/i_angle 0 def  % FIXME
4725 avox 506
	/ExportFiles where { /ExportFiles get (.) search { exch pop exch pop } if } { (imagefile) } ifelse
507
	    (-) concatenate i_filecount 9 string cvs concatenate
508
		(im ) print												% im x y w h angle ...
509
		i_x i_str cvs print ( ) print
510
		i_y i_str cvs print ( ) print
511
		i_w i_str cvs print ( ) print
512
		i_h i_str cvs print ( ) print
513
		i_angle i_str cvs print ( ) print
514
		i_dict /Width get  i_str cvs print ( ) print			% ... hpix vpix ...
515
		i_dict /Height get i_str cvs print ( ) print
4717 avox 516
		currentcolorspace 0 get /DeviceRGB eq
517
			{ (tiff24nc ) print }
518
		{ currentcolorspace 0 get /DeviceCMYK eq
519
			{ (tiff32nc ) print }
520
		{ currentcolorspace 0 get /DeviceGray eq
521
			{ (tiffgray ) print }
522
			{ (tiff32nc ) print }
523
		ifelse } ifelse } ifelse
524
        dup  (.tif) concatenate print (\n) print flush        % ... dev filename
525
		(.dat) concatenate (w) file /i_file exch store
526
	i_filecount 1 add /i_filecount exch store
527
	currentcolorspace ==write ( setcolorspace\n) ==write
528
	(<<\n) ==write
529
	i_dict { exch
530
		  dup /DataSource eq
531
			{ pop pop (/DataSource currentfile\n) ==write }
532
		  {
533
			dup /ImageMatrix eq
534
				{ pop pop (/ImageMatrix [1 0 0 -1 0 ) ==write i_dict /Height get ==write (]\n) ==write }
535
				{ ==write ( ) ==write ==write (\n) ==write }
536
			ifelse
537
		  } ifelse
538
		} forall
539
	(>>\nimage\n) ==write i_file flushfile
540
 
541
    { %loop
542
      i_left 0 le
543
      {
544
		i_source 1 add /i_source exch def
545
        i_source i_nsources ge { exit } if
546
        i_dict /DataSource get i_source get /i_datasource exch def
547
		/i_left i_size def
548
      } if
549
      /i_datasource load exec
550
      dup type /filetype eq
551
       { i_buf 0 i_left 32 .min getinterval readstring pop
552
       } if
553
      dup i_file exch writestring
554
      i_left exch length sub /i_left exch def
555
    } loop
556
    i_file flushfile
557
 } bind def
558
 
559
/colorimage
560
{
561
      % width height bits/sample matrix datasource0..n-1 multi ncomp
562
      /tmpN exch def
4725 avox 563
	  /tmpMulti exch def
564
	  tmpMulti
4717 avox 565
      {
566
         /tmpN load array astore
567
      } if
568
      /tmpN load 6 add dict
569
      dup 7 -1 roll /Width exch put
570
      dup 6 -1 roll /Height exch put
571
      dup 5 -1 roll /BitsPerComponent exch put
572
      dup 4 -1 roll /ImageMatrix exch put
573
      dup 3 -1 roll /DataSource exch put
4725 avox 574
      tmpMulti
4717 avox 575
      {
576
         dup /MultipleDataSources true put
577
      } if
578
      dup /ImageType 1 put
579
      gsave
580
      /tmpN load
581
         dup 1 eq
582
         {
583
            1 index /Decode [0 1] /Decode put
584
            /DeviceGray setcolorspace
585
         } if
586
         dup 3 eq
587
         {
588
             1 index /Decode [0 1 0 1 0 1] put
589
            /DeviceRGB setcolorspace
590
         } if
591
         dup 4 eq
592
         {
593
            1 index /Decode [0 1 0 1 0 1 0 1]  put
594
            /DeviceCMYK setcolorspace
595
         } if
596
      pop
4725 avox 597
      i_image
4717 avox 598
	  grestore
599
} bind def
600
 
601
/image {
602
   gsave
603
   dup type /dicttype ne
604
   {
605
      % width height bits/sample matrix datasource
606
      7 dict
607
      dup 7 -1 roll /Width exch put
608
      dup 6 -1 roll /Height exch put
609
      dup 5 -1 roll /BitsPerComponent  exch put
610
      dup 4 -1 roll /ImageMatrix exch put
611
      dup 3 -1 roll /DataSource exch put
612
      dup 1 /ImageType exch put
613
      dup [0 1] /Decode exch put
614
      /DeviceGray setcolorspace
615
   } if
4725 avox 616
   i_image
4717 avox 617
   grestore
618
} bind def
619
 
620
/imagemask
621
{
622
	dup type /dicttype ne
623
	{
624
      % width height pol matrix datasource
625
      7 dict
626
      dup 7 -1 roll /Width exch put
627
      dup 6 -1 roll /Height exch put
628
      dup 5 -1 roll { [0 1] } { [1 0] } ifelse /Decode exch put
629
      dup 4 -1 roll /ImageMatrix exch put
630
      dup 3 -1 roll /DataSource exch put
631
	} if
632
    dup 1 /ImageType exch put
633
    dup 1 /BitsPerComponent exch put
634
	gsave
635
	/DeviceGray setcolorspace
4725 avox 636
	i_image
4717 avox 637
	grestore
638
 
639
	% for now only print the dict, FIXME
640
%	currentcolorspace
641
%	dup == (setcolorspace) =
642
%	dup 0 get /DeviceGray eq
643
%		{ currentcolor == (setcolor) = }
644
%	{ dup 0 get /DeviceRGB eq
645
%		{ currentcolor == == == (setcolor) = }
646
%	{ dup 0 get /DeviceCMYK eq
647
%		{ currentcolor == == == == (setcolor) = }
648
%	{ currentcolor type /dicttype eq
649
%		{ (<<) = currentcolor { exch == == } forall (>>\nsetcolor) = }
650
%		{ currentcolor == (setcolor) = }
651
%	ifelse } ifelse } ifelse } ifelse pop
652
%	(<<) =
653
%	{
654
%		exch
655
%		== ==
656
%	} forall
657
%	(>>\nimagemask) = flush
658
} bind def
659
 
660
 
661
% declare some global vars
662
 
663
/i_left 0 def
664
/i_size 0 def
665
/i_dict null def
666
/i_buf 32 string def
667
/i_nsources 1 def
668
/i_source 0 def
4725 avox 669
/i_datasource { (x) } def
4717 avox 670
/i_file null def
671
/i_filecount 1 def
672
 
673
%%%% End of traceimage code
674
 
675
 
290 Franz 676
/stateArray 500 array def
677
/stateTop 0 def
678
/gsave
679
{
680
	userdict begin
4725 avox 681
	(-gs\n) print
290 Franz 682
	stateArray stateTop gstate currentgstate put
683
	/stateTop stateTop 1 add def
684
	end
685
} bind def
686
 
687
/grestore
688
{
689
	userdict begin
690
	stateTop 1 lt
691
	{
692
	}
693
	{
4725 avox 694
		(-gr\n) print
290 Franz 695
		stateArray stateTop 1 sub get setgstate
696
		/stateTop stateTop 1 sub def
697
		stateArray stateTop 0 put
698
	}ifelse
699
	end
700
} bind def
701
 
702
% a bind def of the show operator doesn't work,
703
% so this is our way to get a charpath entry for flattening text
704
/root_charpath
705
{
706
	charpath
707
} bind def
708
 
4725 avox 709
/show % string show -
710
{
290 Franz 711
	userdict begin
712
	storeMatrix
713
	currentfont /FontName known
714
	% stack: string
715
	{
386 Franz 716
		currentpoint /ycur exch def /xcur exch def
290 Franz 717
		currentpoint	% x y
718
		newpath
719
		/clipCnt 0 def
720
		moveto
4725 avox 721
		/completeString exch def
290 Franz 722
		% we process each char separately to get smaller paths
4725 avox 723
 
290 Franz 724
		{
725
			(n\n)print			% start polygon
726
			writecurrentcolor	% write color
727
			storeMatrix
4725 avox 728
			dup completeString length 1 sub eq
729
			{	0 0 }
730
			{ % stringwidth( [n..n+1] ) - stringwidth( [n+1] )
731
				dup completeString exch 2 getinterval stringwidth exch	% y2 x2
732
				completeString 3 index 1 add 1 getinterval stringwidth		% y2 x2 x1 y1
733
				4 1 roll sub											% y1 y2 (x2-x1)
734
				3 1 roll exch sub										% (x2-x1) (y2-y1)
735
			} ifelse /curwidthy exch def /curwidthx exch def
736
			completeString exch 1 getinterval dup /curstr exch def
2798 fschmid 737
			false root_charpath
290 Franz 738
			{_move} {_line} {_curve} {_close} pathforall
739
			(f\n)print			% close polygon
386 Franz 740
			newpath
4725 avox 741
			curwidthx xcur add curwidthy ycur add moveto
386 Franz 742
			currentpoint /ycur exch def /xcur exch def
743
			newpath			% clear graphic stack
744
			xcur ycur moveto
290 Franz 745
		} for
746
		currentpoint	% x y
747
		newpath				% clear graphic stack (and current point)
748
		moveto
4725 avox 749
	} {
750
		pop		% string
751
	} ifelse
290 Franz 752
	end
753
} def
754
 
755
/ashow
756
{
757
	% ax ay string
385 Franz 758
	exch /ydist exch def
759
	exch /xdist exch def
760
	userdict begin
761
	storeMatrix
762
	currentfont /FontName known
763
	% stack: string
764
	{
386 Franz 765
		currentpoint /ycur exch def /xcur exch def
385 Franz 766
		currentpoint	% x y
767
		newpath
768
		/clipCnt 0 def
769
		moveto
4725 avox 770
		/completeString exch def
385 Franz 771
		% we process each char separately to get smaller paths
4725 avox 772
 
385 Franz 773
		{
774
			(n\n)print			% start polygon
775
			writecurrentcolor	% write color
776
			storeMatrix
4725 avox 777
			dup completeString length 1 sub eq
778
			{	0 0 }
779
			{ % stringwidth( [n..n+1] ) - stringwidth( [n+1] )
780
				dup completeString exch 2 getinterval stringwidth exch	% y2 x2
781
				completeString 3 index 1 add 1 getinterval stringwidth		% y2 x2 x1 y1
782
				4 1 roll sub											% y1 y2 (x2-x1)
783
				3 1 roll exch sub								% (x2-x1) (y2-y1)
784
			} ifelse /curwidthy exch def /curwidthx exch def
785
			completeString exch 1 getinterval dup /curstr exch def
786
			false root_charpath
385 Franz 787
			{_move} {_line} {_curve} {_close} pathforall
788
			(f\n)print			% close polygon
386 Franz 789
			newpath
4725 avox 790
			curwidthx xcur add curwidthy ycur add
386 Franz 791
			exch xdist add exch ydist add moveto
792
			currentpoint /ycur exch def /xcur exch def
793
			newpath			% clear graphic stack
794
			xcur ycur moveto
385 Franz 795
		} for
796
		currentpoint	% x y
797
		newpath				% clear graphic stack (and current point)
798
		moveto
4725 avox 799
	} {
800
		pop
801
	} ifelse
385 Franz 802
	end
290 Franz 803
} bind def
804
 
4642 avox 805
/awidthshow		% cx cy char ax ay string
290 Franz 806
{
4642 avox 807
	% ax ay string
808
	exch /ydist exch def
809
	exch /xdist exch def
810
	% cx cy char string
811
	exch /char exch def
812
	exch /cydist exch def
813
	exch /cxdist exch def
814
	userdict begin
815
	storeMatrix
816
	currentfont /FontName known
817
	% stack: string
818
	{
819
		currentpoint /ycur exch def /xcur exch def
820
		currentpoint	% x y
821
		newpath
822
		/clipCnt 0 def
823
		moveto
4725 avox 824
		/completeString exch def
4642 avox 825
		% we process each char separately to get smaller paths
4725 avox 826
 
4642 avox 827
		{
828
			(n\n)print			% start polygon
829
			writecurrentcolor	% write color
830
			storeMatrix
4725 avox 831
			dup completeString length 1 sub eq
832
			{	0 0 }
833
			{ % stringwidth( [n..n+1] ) - stringwidth( [n+1] )
834
				dup completeString exch 2 getinterval stringwidth exch	% y2 x2
835
				completeString 3 index 1 add 1 getinterval stringwidth		% y2 x2 x1 y1
836
				4 1 roll sub											% y1 y2 (x2-x1)
837
				3 1 roll exch sub								% (x2-x1) (y2-y1)
838
			} ifelse /curwidthy exch def /curwidthx exch def
839
			completeString exch 1 getinterval dup /curstr exch def
840
			false root_charpath
4642 avox 841
			{_move} {_line} {_curve} {_close} pathforall
842
			(f\n)print			% close polygon
843
			newpath
4725 avox 844
			curwidthx xcur add curwidthy ycur add
4642 avox 845
			exch xdist add exch ydist add moveto
846
			curstr 0 get char eq
847
			{
848
				currentpoint exch cxdist add exch cydist add moveto
849
			} if
850
			currentpoint /ycur exch def /xcur exch def
851
			newpath			% clear graphic stack
852
			xcur ycur moveto
853
		} for
854
		currentpoint	% x y
855
		newpath				% clear graphic stack (and current point)
856
		moveto
4725 avox 857
	} {
858
		pop
859
	} ifelse
4642 avox 860
	end
290 Franz 861
} bind def
862
 
4642 avox 863
/widthshow	% cx cy char string
290 Franz 864
{
4642 avox 865
 
866
 
867
	awidthshow
290 Franz 868
} bind def
869
 
870
/cshow	% proc string
871
{
872
	exch pop
873
	show
874
} bind def
875
 
876
/kshow	% proc string
877
{
878
	dup length 1 sub
879
	dup 0 ne
880
	{
881
		1 index 0 1 getinterval
882
		show
883
		1 sub
884
		dup 0 ne
885
		{
886
			1 add
887
			1 exch 1 exch
888
			{
889
				dup 1 sub
890
				2 index exch get
891
				2 index 2 index get
892
				4 index exec
893
				1 index exch 1 getinterval
894
				show
895
			} for
896
		} if
897
	}
898
	{
899
		pop dup show
900
	} ifelse
901
	pop pop
902
} bind def
903
 
904
/xshow	% string array
905
{
906
	pop
907
	show
908
} bind def
909
 
910
/xyshow	% string array
911
{
912
	pop
913
	show
914
} bind def
915
 
916
/yshow	% string array
917
{
918
	pop
919
	show
920
} bind def
921
 
922
/ReEnc % newfontname reencodevector origfontdict -> ReEncode -> newfontdict
923
{
924
	userdict begin
925
 dup begin dup maxlength dict begin
926
  { 1 index /FID ne {def} {pop pop} ifelse
927
  } forall
928
  /Encoding exch def
929
  currentdict
930
  end end
931
  definefont
932
	end
933
} bind def
934
 
935
/glyphshow {
936
    save % So can reclaim VM from reencoding
937
    currentfont /Encoding get dup length array copy dup 0 5 -1 roll put
938
    /GlyphShowTempFont exch currentfont ReEnc
939
    setfont
940
    (\000) show
941
	restore
942
} bind def
943
 
292 Franz 944
/showpage
945
{
946
	(sp\n) print
947
} bind def
948