1 % the postscript header we use for our qpsprinter in uncompressed and commented form.
2 % use the makepsheader perl script to generate a compressed version of this header
3 % you can then paste into qpsprinter.cpp
5 % some compression of the code is done by the makepsheader script, so we don't need to
6 % write too criptically here.
8 /BD {bind def} bind def
15 /CM {currentmatrix} BD
19 /SC {aload pop setrgbcolor} BD
20 /CR {currentfile read pop} BD
22 /scs {setcolorspace} BD
23 /DB {dict dup begin} BD
29 % these use PDF syntax
34 /scn {3 array astore /BCol exch def} BD
35 /SCN {3 array astore /PCol exch def} BD
36 /cm {6 array astore concat} BD
46 % ENDUNCOMPRESSED: Warning: leave this line in.
47 % Everything before this line will be left untouched by the compression
49 /q {gsave 10 dict begin} BD
53 /re { % PDF re operator
71 /BT {gsave 10 dict begin /_m matrix currentmatrix def BCol SC} BD
80 /Tm {6 array astore concat} BD
82 /Tj {0 0 moveto show} BD
88 /BSt 0 def % brush style
89 /WFi false def % winding fill
91 /BCol [ 1 1 1 ] def % brush color
92 /PCol [ 0 0 0 ] def % pen color
93 /BDArr [ % Brush dense patterns
103 % -- level3 true/false
105 /languagelevel where {
112 %% image drawing routines
115 /QCIgray D0 /QCIcolor D0 /QCIindex D0
117 % this method prints color images if colorimage is available, otherwise
118 % converts the string to a grayscale image and uses the reular postscript image
119 % operator for printing.
120 % Arguments are the same as for the image operator:
122 % width height bits/sample matrix datasrc QCI -
127 }{ % the hard way, based on PD code by John Walker <kelvin@autodesk.com>
128 exec /QCIcolor exch def
129 /QCIgray QCIcolor length 3 idiv string def
130 0 1 QCIcolor length 3 idiv 1 sub
132 /_x QCIindex 3 mul def
134 QCIcolor _x get 0.30 mul
135 QCIcolor _x 1 add get 0.59 mul
136 QCIcolor _x 2 add get 0.11 mul
144 % general image drawing routine, used from the postscript driver
146 % Draws images with and without mask with 1, 8 and 24(rgb) bits depth.
148 % width height matrix image 1|8|24 mask|false x y di
150 % width and height specify the width/height of the image,
151 % matrix a transformation matrix, image a procedure holding the image data
152 % (same for mask) and x/y an additional translation.
154 % ### should move the translation into the matrix!!!
159 1 index 1 eq { % bitmap
160 pop pop % get rid of mask and depth
161 false 3 1 roll % width height false matrix image
166 % have a mask, see if we can use it
173 % languagelevel3, we can use image mask and dicts
175 % store the image mask
177 % select colorspace according to 8|24 bit depth and set the decode array /dc
182 /_dc [0 1 0 1 0 1] def
188 % transformation matrix
193 % and the combined image dict
206 % the mask dictionary
220 pop % no mask or can't use it, get rid of it
221 8 % width height image 8|24 8 matrix
236 BSt 1 eq % solid brush?
239 WFi { fill } { eofill } ifelse
241 BSt 2 ge BSt 8 le and % dense pattern?
243 BDArr BSt 2 sub get /_sc exch def
244 % the following line scales the brush color according to the pattern. the higher the pattern the lighter the color.
247 1. exch sub _sc mul 1. exch sub
251 WFi { fill } { eofill } ifelse
253 BSt 9 ge BSt 14 le and % brush pattern?
255 WFi { clip } { eoclip } ifelse
256 pathbbox % left upper right lower
257 3 index 3 index translate
258 4 2 roll % right lower left upper
259 3 2 roll % right left upper lower
260 exch % left right lower upper
266 BSt 9 eq BSt 11 eq or % horiz or cross pattern
268 { dup 0 exch moveto _w exch lineto } for
270 BSt 10 eq BSt 11 eq or % vert or cross pattern
272 { dup 0 moveto _h lineto } for
274 BSt 12 eq BSt 14 eq or % F-diag or diag cross
277 { dup 0 moveto _h sub _h lineto } for
279 { dup 0 exch moveto _w sub _w exch lineto } for
282 BSt 13 eq BSt 14 eq or % B-diag or diag cross
285 { dup _h moveto _h sub 0 lineto } for
287 { dup _w exch moveto _w sub 0 exch lineto } for
295 BSt 24 eq % TexturePattern
302 /f { /WFi true def BF newpath } bind def
303 /f* { /WFi false def BF newpath } bind def
304 /B { /WFi true def BF S newpath } bind def
305 /B* { /WFi false def BF S newpath } bind def
322 % merges one key value pair into the page device dict
326 /setpagedevice where {
335 /T1AddMapping { % basefont [glyphname ...] T1AddMapping -
339 /current fnt /NumGlyphs get def
340 /CMap fnt /CMap get def
342 0 1 glyphs length 1 sub % 0 1 (num glyphs - 1)
344 glyphs exch get /gn exch def
346 current dup % glyph_index glyph_index
347 256 mod /min exch def % glyph_index
348 256 idiv /maj exch def % -
349 CMap dup maj get dup % cmap cmap_maj cmap_maj
352 0 1 255 {1 index exch /.notdef put} for
354 dup % cmap cmap_maj cmap_maj
355 min gn put % cmap cmap_maj
358 /current current 1 add def
362 fnt /NumGlyphs current put
366 /T1AddGlyphs { % basefont [glyphname charstring ...] T1AddGlyphs -
370 /current fnt /NumGlyphs get def
371 /CMap fnt /CMap get def
372 /CharStrings fnt /CharStrings get def
374 0 1 glyphs length 2 idiv 1 sub % 0 1 (num glyphs - 1)
377 glyphs exch get /gn exch def
379 glyphs exch get /cs exch def
381 current dup % glyph_index glyph_index
382 256 mod /min exch def % glyph_index
383 256 idiv /maj exch def % -
384 CMap dup maj get dup % cmap cmap_maj cmap_maj
387 0 1 255 {1 index exch /.notdef put} for
389 dup % cmap cmap_maj cmap_maj
390 min gn put % cmap cmap_maj
393 CharStrings gn cs put
394 /current current 1 add def
397 fnt /CharStrings CharStrings put
399 fnt /NumGlyphs current put
405 /StringAdd { % string1 string2 stringadd result
406 1 index length 1 index length add
409 2 index 0 3 index putinterval
410 2 index 2 index length 2 index putinterval
415 /T1Setup { % fontname T1Setup -
417 dup /FontName exch def
418 (-Base) StringAdd cvx cvn /Font exch def
419 /MaxPage Font /NumGlyphs get 1 sub 256 idiv def
421 /FDepVector MaxPage 1 add array def
422 /Encoding MaxPage 1 add array def
425 dup Encoding exch dup put
429 FontName (-) StringAdd
431 20 string cvs StringAdd % page fontname
434 Font 0 dict copy dup dup /CMap get
436 /Encoding exch put definefont
437 FDepVector exch Page exch put
443 /FontMatrix[1 0 0 1 0 0]
445 /FDepVector FDepVector