Subversion Repositories Scribus

Rev

Rev 4740 | Rev 4770 | 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
 
4740 avox 51
/cfile TraceFile (w) file def
290 Franz 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 4741 2006-02-26 04:56:39Z 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
4733 avox 507
	    (-) concatenate dup /i_basename exch def i_filecount 9 string cvs concatenate
508
		{
509
			i_filecount 1 add /i_filecount exch store
510
			dup (.dat) concatenate status not { exit } if
511
			pop pop pop pop pop
512
			i_basename i_filecount 9 string cvs concatenate
513
		} loop
4725 avox 514
		(im ) print												% im x y w h angle ...
515
		i_x i_str cvs print ( ) print
516
		i_y i_str cvs print ( ) print
517
		i_w i_str cvs print ( ) print
518
		i_h i_str cvs print ( ) print
519
		i_angle i_str cvs print ( ) print
520
		i_dict /Width get  i_str cvs print ( ) print			% ... hpix vpix ...
521
		i_dict /Height get i_str cvs print ( ) print
4717 avox 522
		currentcolorspace 0 get /DeviceRGB eq
523
			{ (tiff24nc ) print }
524
		{ currentcolorspace 0 get /DeviceCMYK eq
525
			{ (tiff32nc ) print }
526
		{ currentcolorspace 0 get /DeviceGray eq
527
			{ (tiffgray ) print }
528
			{ (tiff32nc ) print }
529
		ifelse } ifelse } ifelse
530
        dup  (.tif) concatenate print (\n) print flush        % ... dev filename
531
		(.dat) concatenate (w) file /i_file exch store
532
	currentcolorspace ==write ( setcolorspace\n) ==write
533
	(<<\n) ==write
534
	i_dict { exch
535
		  dup /DataSource eq
536
			{ pop pop (/DataSource currentfile\n) ==write }
537
		  {
538
			dup /ImageMatrix eq
539
				{ pop pop (/ImageMatrix [1 0 0 -1 0 ) ==write i_dict /Height get ==write (]\n) ==write }
540
				{ ==write ( ) ==write ==write (\n) ==write }
541
			ifelse
542
		  } ifelse
543
		} forall
544
	(>>\nimage\n) ==write i_file flushfile
545
 
546
    { %loop
547
      i_left 0 le
548
      {
549
		i_source 1 add /i_source exch def
550
        i_source i_nsources ge { exit } if
551
        i_dict /DataSource get i_source get /i_datasource exch def
552
		/i_left i_size def
553
      } if
554
      /i_datasource load exec
555
      dup type /filetype eq
556
       { i_buf 0 i_left 32 .min getinterval readstring pop
557
       } if
558
      dup i_file exch writestring
559
      i_left exch length sub /i_left exch def
560
    } loop
561
    i_file flushfile
562
 } bind def
563
 
564
/colorimage
565
{
566
      % width height bits/sample matrix datasource0..n-1 multi ncomp
567
      /tmpN exch def
4725 avox 568
	  /tmpMulti exch def
569
	  tmpMulti
4717 avox 570
      {
571
         /tmpN load array astore
572
      } if
573
      /tmpN load 6 add dict
574
      dup 7 -1 roll /Width exch put
575
      dup 6 -1 roll /Height exch put
576
      dup 5 -1 roll /BitsPerComponent exch put
577
      dup 4 -1 roll /ImageMatrix exch put
578
      dup 3 -1 roll /DataSource exch put
4725 avox 579
      tmpMulti
4717 avox 580
      {
581
         dup /MultipleDataSources true put
582
      } if
583
      dup /ImageType 1 put
584
      gsave
585
      /tmpN load
586
         dup 1 eq
587
         {
588
            1 index /Decode [0 1] /Decode put
589
            /DeviceGray setcolorspace
590
         } if
591
         dup 3 eq
592
         {
593
             1 index /Decode [0 1 0 1 0 1] put
594
            /DeviceRGB setcolorspace
595
         } if
596
         dup 4 eq
597
         {
598
            1 index /Decode [0 1 0 1 0 1 0 1]  put
599
            /DeviceCMYK setcolorspace
600
         } if
601
      pop
4725 avox 602
      i_image
4717 avox 603
	  grestore
604
} bind def
605
 
606
/image {
607
   gsave
608
   dup type /dicttype ne
609
   {
610
      % width height bits/sample matrix datasource
611
      7 dict
612
      dup 7 -1 roll /Width exch put
613
      dup 6 -1 roll /Height exch put
614
      dup 5 -1 roll /BitsPerComponent  exch put
615
      dup 4 -1 roll /ImageMatrix exch put
616
      dup 3 -1 roll /DataSource exch put
617
      dup 1 /ImageType exch put
618
      dup [0 1] /Decode exch put
619
      /DeviceGray setcolorspace
620
   } if
4725 avox 621
   i_image
4717 avox 622
   grestore
623
} bind def
624
 
625
/imagemask
626
{
627
	dup type /dicttype ne
628
	{
629
      % width height pol matrix datasource
630
      7 dict
631
      dup 7 -1 roll /Width exch put
632
      dup 6 -1 roll /Height exch put
633
      dup 5 -1 roll { [0 1] } { [1 0] } ifelse /Decode exch put
634
      dup 4 -1 roll /ImageMatrix exch put
635
      dup 3 -1 roll /DataSource exch put
636
	} if
637
    dup 1 /ImageType exch put
638
    dup 1 /BitsPerComponent exch put
639
	gsave
640
	/DeviceGray setcolorspace
4725 avox 641
	i_image
4717 avox 642
	grestore
643
 
644
	% for now only print the dict, FIXME
645
%	currentcolorspace
646
%	dup == (setcolorspace) =
647
%	dup 0 get /DeviceGray eq
648
%		{ currentcolor == (setcolor) = }
649
%	{ dup 0 get /DeviceRGB eq
650
%		{ currentcolor == == == (setcolor) = }
651
%	{ dup 0 get /DeviceCMYK eq
652
%		{ currentcolor == == == == (setcolor) = }
653
%	{ currentcolor type /dicttype eq
654
%		{ (<<) = currentcolor { exch == == } forall (>>\nsetcolor) = }
655
%		{ currentcolor == (setcolor) = }
656
%	ifelse } ifelse } ifelse } ifelse pop
657
%	(<<) =
658
%	{
659
%		exch
660
%		== ==
661
%	} forall
662
%	(>>\nimagemask) = flush
663
} bind def
664
 
665
 
666
% declare some global vars
667
 
668
/i_left 0 def
669
/i_size 0 def
670
/i_dict null def
671
/i_buf 32 string def
672
/i_nsources 1 def
673
/i_source 0 def
4725 avox 674
/i_datasource { (x) } def
4717 avox 675
/i_file null def
676
/i_filecount 1 def
677
 
678
%%%% End of traceimage code
679
 
680
 
290 Franz 681
/stateArray 500 array def
682
/stateTop 0 def
683
/gsave
684
{
685
	userdict begin
4725 avox 686
	(-gs\n) print
290 Franz 687
	stateArray stateTop gstate currentgstate put
688
	/stateTop stateTop 1 add def
689
	end
690
} bind def
691
 
692
/grestore
693
{
694
	userdict begin
695
	stateTop 1 lt
696
	{
697
	}
698
	{
4725 avox 699
		(-gr\n) print
290 Franz 700
		stateArray stateTop 1 sub get setgstate
701
		/stateTop stateTop 1 sub def
702
		stateArray stateTop 0 put
703
	}ifelse
704
	end
705
} bind def
706
 
707
% a bind def of the show operator doesn't work,
708
% so this is our way to get a charpath entry for flattening text
709
/root_charpath
710
{
711
	charpath
712
} bind def
713
 
4740 avox 714
/i_kerningI
715
{
716
	exch 1 getinterval stringwidth
717
} bind def
718
 
719
% find kerning value
720
/i_kerningII		% index string   i_kerning   dx dy
721
{
722
	% stringwidth( [n..n+1] ) - stringwidth( [n+1] )
723
	/i_pstring exch def
724
	/i_pindex exch def
725
	i_pstring i_pindex 2 getinterval stringwidth exch	% y2 x2
726
	i_pstring i_pindex 1 add 1 getinterval stringwidth		% y2 x2 x1 y1
727
	4 1 roll sub											% y1 y2 (x2-x1)
728
	3 1 roll exch sub										% (x2-x1) (y2-y1)
729
} bind def
730
 
731
 
732
/i_kerningIII		% index string   i_kerning   dx dy
733
{
734
	% stringwidth( [n..n+1] ) - stringwidth( [n+1] )
735
	/i_pstring exch def
736
	/i_pindex exch def
737
	i_pstring i_pindex 2 getinterval (l) exch concatenate stringwidth exch	% y2 x2
738
	i_pstring i_pindex 1 add 1 getinterval (l) exch concatenate stringwidth		% y2 x2 x1 y1
739
	4 1 roll sub											% y1 y2 (x2-x1)
740
	3 1 roll exch sub										% (x2-x1) (y2-y1)
741
} bind def
742
 
4741 avox 743
/i_kerning /i_kerningII load def
4740 avox 744
 
4725 avox 745
/show % string show -
746
{
290 Franz 747
	userdict begin
748
	storeMatrix
749
	currentfont /FontName known
750
	% stack: string
751
	{
386 Franz 752
		currentpoint /ycur exch def /xcur exch def
290 Franz 753
		currentpoint	% x y
754
		newpath
755
		/clipCnt 0 def
756
		moveto
4725 avox 757
		/completeString exch def
290 Franz 758
		% we process each char separately to get smaller paths
4725 avox 759
 
290 Franz 760
		{
761
			(n\n)print			% start polygon
762
			writecurrentcolor	% write color
763
			storeMatrix
4725 avox 764
			dup completeString length 1 sub eq
4740 avox 765
			{ 0 0 } { dup completeString i_kerning } ifelse
766
			/curwidthy exch def /curwidthx exch def
4725 avox 767
			completeString exch 1 getinterval dup /curstr exch def
2798 fschmid 768
			false root_charpath
290 Franz 769
			{_move} {_line} {_curve} {_close} pathforall
770
			(f\n)print			% close polygon
386 Franz 771
			newpath
4725 avox 772
			curwidthx xcur add curwidthy ycur add moveto
386 Franz 773
			currentpoint /ycur exch def /xcur exch def
774
			newpath			% clear graphic stack
775
			xcur ycur moveto
290 Franz 776
		} for
777
		currentpoint	% x y
778
		newpath				% clear graphic stack (and current point)
779
		moveto
4725 avox 780
	} {
781
		pop		% string
782
	} ifelse
290 Franz 783
	end
4740 avox 784
} bind def
290 Franz 785
 
786
/ashow
787
{
788
	% ax ay string
385 Franz 789
	exch /ydist exch def
790
	exch /xdist exch def
791
	userdict begin
792
	storeMatrix
793
	currentfont /FontName known
794
	% stack: string
795
	{
386 Franz 796
		currentpoint /ycur exch def /xcur exch def
385 Franz 797
		currentpoint	% x y
798
		newpath
799
		/clipCnt 0 def
800
		moveto
4725 avox 801
		/completeString exch def
385 Franz 802
		% we process each char separately to get smaller paths
4725 avox 803
 
385 Franz 804
		{
805
			(n\n)print			% start polygon
806
			writecurrentcolor	% write color
807
			storeMatrix
4725 avox 808
			dup completeString length 1 sub eq
4740 avox 809
			{ 0 0 } { dup completeString i_kerning } ifelse
810
			/curwidthy exch def /curwidthx exch def
4725 avox 811
			completeString exch 1 getinterval dup /curstr exch def
812
			false root_charpath
385 Franz 813
			{_move} {_line} {_curve} {_close} pathforall
814
			(f\n)print			% close polygon
386 Franz 815
			newpath
4725 avox 816
			curwidthx xcur add curwidthy ycur add
386 Franz 817
			exch xdist add exch ydist add moveto
818
			currentpoint /ycur exch def /xcur exch def
819
			newpath			% clear graphic stack
820
			xcur ycur moveto
385 Franz 821
		} for
822
		currentpoint	% x y
823
		newpath				% clear graphic stack (and current point)
824
		moveto
4725 avox 825
	} {
826
		pop
827
	} ifelse
385 Franz 828
	end
290 Franz 829
} bind def
830
 
4642 avox 831
/awidthshow		% cx cy char ax ay string
290 Franz 832
{
4642 avox 833
	% ax ay string
834
	exch /ydist exch def
835
	exch /xdist exch def
836
	% cx cy char string
837
	exch /char exch def
838
	exch /cydist exch def
839
	exch /cxdist exch def
840
	userdict begin
841
	storeMatrix
842
	currentfont /FontName known
843
	% stack: string
844
	{
845
		currentpoint /ycur exch def /xcur exch def
846
		currentpoint	% x y
847
		newpath
848
		/clipCnt 0 def
849
		moveto
4725 avox 850
		/completeString exch def
4642 avox 851
		% we process each char separately to get smaller paths
4725 avox 852
 
4642 avox 853
		{
854
			(n\n)print			% start polygon
855
			writecurrentcolor	% write color
856
			storeMatrix
4725 avox 857
			dup completeString length 1 sub eq
4740 avox 858
			{ 0 0 } { dup completeString i_kerning } ifelse
859
			/curwidthy exch def /curwidthx exch def
4725 avox 860
			completeString exch 1 getinterval dup /curstr exch def
861
			false root_charpath
4642 avox 862
			{_move} {_line} {_curve} {_close} pathforall
863
			(f\n)print			% close polygon
864
			newpath
4725 avox 865
			curwidthx xcur add curwidthy ycur add
4642 avox 866
			exch xdist add exch ydist add moveto
867
			curstr 0 get char eq
868
			{
869
				currentpoint exch cxdist add exch cydist add moveto
870
			} if
871
			currentpoint /ycur exch def /xcur exch def
872
			newpath			% clear graphic stack
873
			xcur ycur moveto
874
		} for
875
		currentpoint	% x y
876
		newpath				% clear graphic stack (and current point)
877
		moveto
4725 avox 878
	} {
879
		pop
880
	} ifelse
4642 avox 881
	end
290 Franz 882
} bind def
883
 
4642 avox 884
/widthshow	% cx cy char string
290 Franz 885
{
4642 avox 886
 
887
 
888
	awidthshow
290 Franz 889
} bind def
890
 
891
/cshow	% proc string
892
{
893
	exch pop
894
	show
895
} bind def
896
 
897
/kshow	% proc string
898
{
899
	dup length 1 sub
900
	dup 0 ne
901
	{
902
		1 index 0 1 getinterval
903
		show
904
		1 sub
905
		dup 0 ne
906
		{
907
			1 add
908
			1 exch 1 exch
909
			{
910
				dup 1 sub
911
				2 index exch get
912
				2 index 2 index get
913
				4 index exec
914
				1 index exch 1 getinterval
915
				show
916
			} for
917
		} if
918
	}
919
	{
920
		pop dup show
921
	} ifelse
922
	pop pop
923
} bind def
924
 
925
/xshow	% string array
926
{
927
	pop
928
	show
929
} bind def
930
 
931
/xyshow	% string array
932
{
933
	pop
934
	show
935
} bind def
936
 
937
/yshow	% string array
938
{
939
	pop
940
	show
941
} bind def
942
 
943
/ReEnc % newfontname reencodevector origfontdict -> ReEncode -> newfontdict
944
{
945
	userdict begin
946
 dup begin dup maxlength dict begin
947
  { 1 index /FID ne {def} {pop pop} ifelse
948
  } forall
949
  /Encoding exch def
950
  currentdict
951
  end end
952
  definefont
953
	end
954
} bind def
955
 
956
/glyphshow {
957
    save % So can reclaim VM from reencoding
958
    currentfont /Encoding get dup length array copy dup 0 5 -1 roll put
959
    /GlyphShowTempFont exch currentfont ReEnc
960
    setfont
961
    (\000) show
962
	restore
963
} bind def
964
 
292 Franz 965
/showpage
966
{
967
	(sp\n) print
968
} bind def
969