diff options
Diffstat (limited to 'Master/tlpkg/tlgs/lib/gslp.ps')
-rw-r--r-- | Master/tlpkg/tlgs/lib/gslp.ps | 114 |
1 files changed, 61 insertions, 53 deletions
diff --git a/Master/tlpkg/tlgs/lib/gslp.ps b/Master/tlpkg/tlgs/lib/gslp.ps index 264984af968..742e2399a83 100644 --- a/Master/tlpkg/tlgs/lib/gslp.ps +++ b/Master/tlpkg/tlgs/lib/gslp.ps @@ -1,19 +1,19 @@ % Copyright (C) 1991, 1995, 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. -% +% % This software is provided AS-IS with no warranty, either express or % implied. -% +% % This software is distributed under license and may not be copied, % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. -% +% % For more information about licensing, please refer to % http://www.ghostscript.com/licensing/. For information on % commercial licensing, go to http://www.artifex.com/licensing/ or % contact Artifex Software, Inc., 101 Lucas Valley Road #110, % San Rafael, CA 94903, U.S.A., +1(415)492-9861. -% $Id: gslp.ps 6300 2005-12-28 19:56:24Z giles $ +% $Id$ % gslp.ps - format and print text % This utility provides functionality approximately equivalent to the Unix @@ -63,7 +63,7 @@ lpdict begin %% reencode for iso latin1; from the 2nd edition red book, sec 5.6.1 dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def currentdict end - dup /FontName get 80 string cvs (-ISOLatin1) concatstrings cvn + dup /FontName get 80 string cvs (-ISOLatin1) concatstrings cvn exch definefont } def @@ -136,7 +136,7 @@ lpdict begin } def /lpmoveto { % <x> <y> lpmoveto - - % Round the coordinates for smaller output. + % Round the coordinates for smaller output. 2 { exch 100 mul round 100 div dup dup cvi eq { cvi } if @@ -146,23 +146,23 @@ lpdict begin /lpshow { % <string> lpshow - dup length 0 ne { addspace 0 ne { - addspace 0 32 + addspace 0 32 addwidth 0 ne { - addwidth 0 6 -1 roll /awidthshow 6 true lpexec + addwidth 0 6 -1 roll /awidthshow 6 true lpexec } { - 4 -1 roll /widthshow 4 true lpexec + 4 -1 roll /widthshow 4 true lpexec } ifelse } { addwidth 0 ne { - addwidth 0 3 -1 roll /ashow 3 true lpexec + addwidth 0 3 -1 roll /ashow 3 true lpexec } { - OutFile null ne { - dup dup length =string length gt { - /show 1 false lpexec - } { - (S ) ws ws (\n) ws - } ifelse - } if show + OutFile null ne { + dup dup length =string length gt { + /show 1 false lpexec + } { + (S ) ws ws (\n) ws + } ifelse + } if show } ifelse } ifelse } { @@ -183,9 +183,9 @@ lpdict begin 3 -1 roll bannerstring pop 0 4 index pwidth showline2 pop exch bannerstring pwidth exch sub 2 div 3 index pwidth showline2 pop bannerstring - % Prevent the last character of the heading from grazing - % the right margin. - % ****** WHY DOES IT REQUIRE SO MUCH PADDING? ****** + % Prevent the last character of the heading from grazing + % the right margin. + % ****** WHY DOES IT REQUIRE SO MUCH PADDING? ****** ( ) stringwidth pop 2 mul add pwidth exch sub 3 -1 roll pwidth showline2 pop @@ -258,7 +258,7 @@ lpdict begin /outfont { % <name> <font> outfont - OutFile null ne { exch wo - dup /FontName get + dup /FontName get dup wosp (-ISOLatin1) ws wosp ( RE) ws /FontMatrix get 0 get 1000 mul round cvi wosp ( scalefont def\n) ws @@ -296,7 +296,7 @@ lpdict begin /showline2 { % string x y xlimit -> leftover_string (handles tabs) 2 index exch 5 2 roll setxy { - % Stack: xinit xlimit string + % Stack: xinit xlimit string showline3 dup length 0 eq { exit } if dup 0 get CharTAB ne { exit } if tx 3 index sub tabwx div @@ -307,11 +307,11 @@ lpdict begin } def /showline3 { % xlimit string -> xlimit leftover_string - % (finds line break / tab / formfeed) + % (finds line break / tab / formfeed) 1 index tx sub cwx div 0.1 add cvi 0 .max 1 index length .min 1 index 0 3 -1 roll getinterval - % look for \f or \t + % look for \f or \t StringFF search { exch pop exch pop } if StringTAB search { exch pop exch pop } if dup length 0 ne { @@ -367,15 +367,15 @@ lpdict begin { mfile =string readline pop (EndFontMetrics) anchorsearch { pop pop exit } if (KPX ) anchorsearch { - pop token pop cvlit /char1 exch def - token pop cvlit /char2 exch def - token pop /kern exch def pop - kdict char1 .knownget not { - 5 dict kdict char1 2 index .growput - } if - char2 kern .growput + pop token pop cvlit /char1 exch def + token pop cvlit /char2 exch def + token pop /kern exch def pop + kdict char1 .knownget not { + 5 dict kdict char1 2 index .growput + } if + char2 kern .growput } { - pop + pop } ifelse } loop kdict } { @@ -402,7 +402,7 @@ lpdict begin /S {currentfile =string readline pop show} lpdef /RE { % <isoname> <fontname> RE <font> findfont - %% reencode for iso latin1; from the 2nd edition red book, sec 5.6.1 + %% reencode for iso latin1; from the 2nd edition red book, sec 5.6.1 dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def currentdict end definefont @@ -448,8 +448,8 @@ lpdict begin Footers { hheight lheight add } { 0 } ifelse /botskip exch def /pskip topskip botskip add def - % Translate the page so that (0,0) corresponds to - % the top of the topmost body line. + % Translate the page so that (0,0) corresponds to + % the top of the topmost body line. pathbbox 2 index sub MarginBottom MarginTop add sub /plength exch def 2 index sub MarginLeft MarginRight add sub /pwidth exch def @@ -469,6 +469,14 @@ lpdict begin (.\n) eprint flush } if + colines 1 lt cowidth 1 lt or + { + (Page too small, it must be large to hold at least one line of text\n) eprint + (please specify a page size using for example -sPAPERSIZE=(a4|letter)\n) eprint + /gslp.ps cvx /limitcheck signalerror + } if + + % Write the kerning table, if relevant. OutFile null ne Kern length 0 ne and { (/kproc) ws /kproc load wosp ( def\n) ws @@ -493,12 +501,12 @@ lpdict begin } { % Reached CR and/or EOF first. exch length pos add lbuf exch 0 exch getinterval - 1 index { showline } if % omit final empty line - { dup length 0 eq Truncate or { pop () exit } if - showline - } - loop - exch not { exit } if + 1 index { showline } if % omit final empty line + { dup length 0 eq Truncate or { pop () exit } if + showline + } + loop + exch not { exit } if } ifelse pindex PageLast gt { exit } if @@ -626,10 +634,10 @@ lpdict begin /lp1 % filename -> { break not { dup /HeadingLeft exch def } if Noisy - { (Printing ) eprint dup eprint (\n) eprint + { (Printing ) eprint dup eprint (\n) eprint } if (r) file - % If requested, check for a PostScript file. + % If requested, check for a PostScript file. DetectFileType { dup 2 string readstring pop dup (%!) eq { % Yes, it's a PostScript file. @@ -659,11 +667,11 @@ end dup length 2 ge { dup 0 get (-) 0 get eq } { false } ifelse { dup 0 2 getinterval exch dup length 2 sub 2 exch getinterval - doswitch + doswitch } { dup /matched false def { /matched true def /any true def lp1 } lpcstring filenameforall - matched { pop } { lp1 } ifelse % let the error happen + matched { pop } { lp1 } ifelse % let the error happen } ifelse } loop @@ -679,14 +687,14 @@ end { ] dup length 0 ne { lpcommand } { false } ifelse not { (%stderr) (w) file [ (Usage: ) - /PROGNAME where { pop PROGNAME } { (gslp) } ifelse - ( [-12BclqRr] [-b<header>] [-f<font>] [-F<hfont>]\n) - ( [-L<lines>] [-p<outfile>] [-T<tabwidth>]\n) - ( [--add-to-(space|width) <units>] [--columns <n>]\n) - ( [--detect] [--first-page <page#>] [--last-page <page#>]\n) - ( [--(heading|footing)-(left|right|center) <string>]\n) - ( [--kern <afmfile>] [--margin-(top|bottom|left|right) <inches>]\n) - ( [--no-eject-(file|formfeed)] [--spacing <n>] file1 ... filen\n) + /PROGNAME where { pop PROGNAME } { (gslp) } ifelse + ( [-12BclqRr] [-b<header>] [-f<font>] [-F<hfont>]\n) + ( [-L<lines>] [-p<outfile>] [-T<tabwidth>]\n) + ( [--add-to-(space|width) <units>] [--columns <n>]\n) + ( [--detect] [--first-page <page#>] [--last-page <page#>]\n) + ( [--(heading|footing)-(left|right|center) <string>]\n) + ( [--kern <afmfile>] [--margin-(top|bottom|left|right) <inches>]\n) + ( [--no-eject-(file|formfeed)] [--spacing <n>] file1 ... filen\n) ] { 2 copy writestring pop } forall dup flushfile closefile } if |