stuarth@csis.dit.csiro.au (Stuart Hungerford) (02/04/90)
I'm hoping some PostScript wizard out there can help me with this one. I'm
using a pretty-printing program called `pps' which takes source code in various
languages and produces PostScript output with reserved words, comments, body
text etc in the fonts you specify. In my case the language is C and body
text is Courier, reserved words are in Courier bold and (this is the problem)
comments in courier italic.
The problem with the comment text is that unless you use plain Courier or
New Century Schoolbook italic the code produced by pps dissapears into our
Apple LaserWriter Plus and nothing is printed.
I've included below a sample output from pps which demonstrates the problem.
(I've commented out the lines which print line and page numbers but that's OK,
it wasn't working before that either). If anybody can spot the problem please
email me the short answer before you post as I'm desperate and our newsfeed
is very slow.
Thanks in anticipation,
Stuart Hungerford
stuarth@csis.dit.csiro.au
---------------------------------Cut Here---------------------------------------
%!PS-Adobe-1.0
%%Title: test.c
%%Creator: pps ($Header: pps.sh,v 0.0 88/06/22 05:22:29 on Rel $)
%%CreationDate: Sun Feb 4 13:35:25 EST 1990
%%For: stuarth@regulus
%%EndComments
%%$Header: pps.pro,v 0.0 88/06/22 05:22:26 on Rel $
% General macros ( should be builtins :-)
/inch { 72 mul } def
/min { 2 copy gt { exch } if pop } def
/max { 2 copy lt { exch } if pop } def
/curx { currentpoint pop } def
/cury { currentpoint exch pop } def
% Show a string, right justified, and move to its beginning.
/rshow { % string
dup stringwidth pop neg % string width, negative
dup 0 rmoveto
exch show
0 rmoveto % to beginning of string
} def
% Commands
/fname { % string fname -
/filename exch def
/pageno 0 def
/lineno 1 def
1 f
} def
/fdate { % string fdate -
/date exch def
} def
/funct { % string funct -
gsave
C titlesize scalefont setfont
fbase
dontstep ( ) stringwidth pop sub cury min
moveto
90 rotate
rshow
/dontstep curx ( ) stringwidth pop sub def % Yech!
grestore
} def
/t { % ntabs t -
{
curx 1 add
tabwidth div ceiling
tabwidth mul
dup rlimit gt {
pop
lcont marshow
1 nl
} {
cury moveto
} ifelse
} repeat
} def
/nl { % nlines nl - (internal use)
{
cury dy add
dup
highth neg le {
pop
1 f
} {
0 exch
moveto
} ifelse
} repeat
} def
% Show a string in margins, if there is enough room.
/marshow { % string marshow - (internal)
cury dight add dontstep lt {
gsave
C setfont
width cury moveto
rshow
/dontstep cury def
grestore
} if
} def
/n { % nlines n -
dup lineno add
/lineno exch def
nl
% Bug: does not number blank lines!
lineres 0 gt {
lineno lineres mod 0 eq {
lineno maxline cvs marshow
} if
} if
} def
/np { % npages np - (internal)
totalpage 0 gt {
showpage
} if
/totalpage totalpage 1 add def
margin ury translate
0 0 moveto
} def
/f { % npages f -
{
np
/pageno pageno 1 add def
titleput
pageno 1 gt {
% lineno maxline cvs marshow
} if
} repeat
} def
/s { % string font s -
setfont
dup stringwidth pop
curx add
rlimit gt {
lcont marshow
1 nl
} if
show
} def
% This is a halfhearted attempt.
% The ultimate thing is a printf() like specification from argv[].
/titleput { % - titleput -
0 dy 3 mul rmoveto % space for title
C setfont
date show
C titlesize scalefont setfont
width cury moveto
% pageno maxpage cvs rshow
curx ( ) stringwidth pop sub rlimit min
cury moveto
currentdict /header known {
header
} {
filename
} ifelse rshow
/dontstep cury def
0 cury dy 2 mul add moveto
} def
% Init macro - must be called after definitions are changed.
/ppsinit { % - ppsinit -
gsave
/dy 1 inch lpi div neg def
fonts {
findfont dy neg progsize mul scalefont def
} forall
% Paper limits
initclip clippath pathbbox
/ury exch def
/urx exch 10 sub def % margin may be set wrong
/lly exch def
/llx exch def
% Line numbers are right justified to width.
% We force a newline when rlimit is exceeded by text.
/highth ury lly sub dy add def
/margin llx 1 inch add def
/width urx margin sub def
% UnderlinePosition or FontBBox may be missing...
% Measure sizes of things we print in margins.
C setfont
/rlimit width maxline stringwidth pop sub def % right limit
newpath 0 0 moveto
(670) true charpath flattenpath pathbbox
/dight exch def % digit ht
pop pop pop
C titlesize scalefont setfont
newpath 0 0 moveto
(qypfgj\(\),_) true charpath flattenpath pathbbox
pop pop exch pop width add
/fbase exch def % function base
I setfont
/tabwidth (n) stringwidth pop tabstop mul def
/totalpage 0 def
grestore
} def
/ppsdone {
showpage
} def
% Page style -- may be modified.
/tabstop 4 def % Charcters per tabstop
/lineres 1000 def % Line numbering resolution
/maxline (9999) def % Maximum lines / file
/maxpage (999) def % Maximum pages / file
/lpi 7 def % Lines per inch
/progsize 70 72 div def % Program point size / line spacing
/titlesize 1.1 def % Title point size / program point size
% Default fonts -- need not be fixed pitch.
/fonts 4 dict def
fonts begin
/C /Courier def % Comments
/K /Courier-Bold def % Keywords
/S /Courier def % Strings
/I /Courier def % The rest
end
/lcont (\274) def % Line continuation char (ellipsis)
%%EndProlog
fonts /C /Courier-Oblique put fonts /S /Courier put /tabstop 4 def /lineres 1000 def /lpi 7.5 def ppsinit
(Feb 4 13:05 1990) fdate
(test.c) fname
(/*-------------------------------------------------*/) C s 1 n
(/* This is a comment. */) C s 1 n
(/*-------------------------------------------------*/) C s 1 n
(#) I s (include) K s ( <stdio.h> ) I s (/* That was a keyword */) C s 1 n
%%Trailer
ppsdone
--
Signature out of order!
stuarth@csis.oz