[comp.lang.postscript] need help with postscript interpreter

koo@orc.olivetti.com (03/23/89)

I got the postscript interpreter from an comp.sources.unix archive
site and have been trying to get it working on my sun 3/60 (which runs
X11).  I have two problems so far and would appreciate some pointers.
My problems are:

(1) How to get the interpreter to use the screen fonts that come with
X11 Release 3?

(2) The interpreter does not seem to work on postscript programs that
are generated by the tool "dvi2ps."  It usually terminates with this
message: "invalidfont in operator definefont." 

Thank you in advance.

Richard Koo 			| Internet: koo@orc.olivetti.com
Olivetti Research Center	| UUCP: {...}!ames!oliveb!orc!koo
2882 Sand Hill Road		| Voice: +1-415-496-6232
Menlo Park, CA 94025		| Fax: +1-415-496-6219
Richard Koo 			| Internet: koo@orc.olivetti.com
Olivetti Research Center	| UUCP: {...}!ames!oliveb!orc!koo
2882 Sand Hill Road		| Voice: +1-415-496-6232
Menlo Park, CA 94025		| Fax: +1-415-496-6219

opus@athena.mit.edu (David C. Jedlinsky) (03/23/89)

In article <39629@oliveb.olivetti.com> koo@orc.olivetti.com (Richard Koo) writes:
>I got the postscript interpreter from an comp.sources.unix archive
>site and have been trying to get it working on my sun 3/60 (which runs
>X11).  I have two problems so far and would appreciate some pointers.
>My problems are:
>
>(1) How to get the interpreter to use the screen fonts that come with
>X11 Release 3?

This isn't easy to do at the moment.  I am toying with this, I'll post
if I get it to work.  For now, you will have to live with the crummy
Hershey fonts, or write outlines in PostScript to replace them.

>(2) The interpreter does not seem to work on postscript programs that
>are generated by the tool "dvi2ps."  It usually terminates with this
>message: "invalidfont in operator definefont." 

Two problems here:
1) The tex.ps header file does not create "valid" fonts:  they only
have 128 entries, instead of 256.  You can modify the tex.ps to "do
the right thing", which will solve the problem.  Alternatively:

2) The PostScript manual doesn't say one way or another how many
entries the Encoding Array must have.  So modify CheckFont in font.c
to not look at lengthArray(enc), like it does now.  Or make it print a
warning message.  Your choice.  The LaserWriter, and most other
printers I've tried, allow smaller than 256 entry arrays.  So ignoring
it may be defacto correct.

One more thing: I haven't been able to get dvi2ps output to display
correctly even with this fix.  Some problem with the bitmap fonts,
which I haven't solved yet.

>Thank you in advance.
>
>Richard Koo 			| Internet: koo@orc.olivetti.com
>Olivetti Research Center	| UUCP: {...}!ames!oliveb!orc!koo
>2882 Sand Hill Road		| Voice: +1-415-496-6232
>Menlo Park, CA 94025		| Fax: +1-415-496-6219
>Richard Koo 			| Internet: koo@orc.olivetti.com
>Olivetti Research Center	| UUCP: {...}!ames!oliveb!orc!koo
>2882 Sand Hill Road		| Voice: +1-415-496-6232
>Menlo Park, CA 94025		| Fax: +1-415-496-6219

You're welcome.


-David Jedlinsky
opus@athena.mit.edu

jm36+@andrew.cmu.edu (John Gardiner Myers) (03/30/89)

First, make sure you have my bug fixes to the interpreter.  Run the
interpreter with the switches:

	-c 'version =='

and you should see "1.4 with jgm/bzs mods v3" in the printed string.
If you don't, the standard blurb follows:

There are a number of bug fixes and improvements available via
anonymous ftp to z.andrew.cmu.edu (128.2.30.8) in the subdirectory
psdiffs.  The patches should be applied to an unpacked virgin
distribution.  READ THE INSTRUCTIONS AT THE BEGINNING OF EACH FILE
BEFORE APPLYING THEM WITH PATCH.

opus@athena.mit.edu (David C. Jedlinsky) writes:
>2) The PostScript manual doesn't say one way or another how many
>entries the Encoding Array must have.  So modify CheckFont in font.c
>to not look at lengthArray(enc), like it does now.  Or make it print a
>warning message.  Your choice.  The LaserWriter, and most other
>printers I've tried, allow smaller than 256 entry arrays.  So ignoring
>it may be defacto correct.

The Red Book I have states in section 5.3 that "POSTSCRIPT requires
that the following key-value pairs exist in each font dictionary:",
followed by a table listing "Encoding" as "an array of 256 names ...
this is described in section 5.4".  Section 5.4 states that "The
encoding vector is defined by a 256-element POSTSCRIPT array object."

If you remove the check in CheckFont, you will have to add another
check elsewhere in order to make sure that the program does not access
memory outside the bounds of the encoding array when displaying a string.

>One more thing: I haven't been able to get dvi2ps output to display
>correctly even with this fix.  Some problem with the bitmap fonts,
>which I haven't solved yet.

dvi2ps does not define a correct bounding box and there are bugs in
the font cacheing code.  I'm in the process of fixing these bugs, but
haven't had any time to work on the interpreter in the last few
months.

If anyone else is interested in working on it, send me mail.  I can
give you what I have and tell you exactly what needs to be done.

-- 
_.John G. Myers		Internet: jm36+@andrew.cmu.edu
(412) 268-5655		LoseNet:  ...!seismo!ihnp4!wiscvm.wisc.edu!give!up
"Whenever faced with a problem, some people say `Lets use AWK.'
 Now, they have two problems." -- D. Tilbrook