Workarounds for certain old DVIPS-generated PostScript files

This is for the benefit of other RH9 or URW font users googling for a solution to this problem:

Valek Filippov <frob@df.ru> distributes
the URW fonts, modified to include Cyrillic characters.
The RedHat 9 and RawHide distributions are tracking his version.

The problem is some old versions of the Tex converter DVIPS generated PostScript code that depended on fonts having an executable FontBBox attribute (defined
with curly braces ‘{‘ ‘}’ not brackets ‘[‘ ‘]’).

The following PostScript code dumps the FontBBox of every font (one way to run it is to pipe it into GhostScript with the command “gs -sDEVICE=nullpage”):


%!
FontDirectory { exch == /FontBBox get == } forall

and it turns out that the fonts Times-Roman AKA NimbusRomNo9L-Regu
and Helvetica AKA NimbusSanL-Regu are not executable under the default RH9 install.

The problem PostScript code generated by the Tex converter DVIPS,
essentially:


%!
/Helvetica findfont begin FontBBox 4 array astore

One published example that demonstrates this bug is:
this TR from MIT, but there are
plenty of others.
I speculate that the idiom arose from an early (also buggy) Apple LaserPrep file.

The GhostScript error produced when these fonts are installed is like this:


Error: /stackunderflow in –astore–
Operand stack:
false FontBBox –nostringval– –nostringval–
Execution stack:
%interp_exit
.runexec2 –nostringval–
–nostringval– –nostringval–
2 %stopped_push
–nostringval– –nostringval– –nostringval–
false 1 %stopped_push
1 3 %oparray_pop
1 3 %oparray_pop
.runexec2 –nostringval–
–nostringval– –nostringval–
2 %stopped_push
–nostringval– –nostringval–
–nostringval– –nostringval– –nostringval–
Dictionary stack:
–dict:1050/1123(ro)(G)– –dict:0/20(G)–
–dict:93/200(L)– –dict:207/270(L)–
–dict:12/14(ro)(G)– –dict:12/13(L)–
Current allocation mode is local
GNU Ghostscript 7.05: Unrecoverable error, exit code 1

I have posted bug reports to Valek Filippov and to the developers of the pfaedit tool, and I hope that will result in new releases of the fonts that are more tolerant of this historical DVIPS error.
George Williams, author of pfaedit,
has pointed out
the relevant text in the PostScript Reference Manual:

In many Type 1 fonts the FontBBox array is executable, though
there is no good reason for this to be so. Programs that access
FontBBox should invoke an explicit get or load to avoid
unintended execution.

but has expressed willingness to change his pfaedit font editor to produce fonts with executable FontBBox.

In the meantime, system administrators can manually edit the fonts themselves, e.g., on RH9, edit /usr/share/fonts/default/Type1/*.pfb and make sure all FontBBox definitions uses braces not brackets.

Or, if you want to fix the incorrect code in your old dusty-deck DVIPS-generated PostScript files, you can use the following shell script:


#!/bin/sh
perl -pi.bak \
-e ‘s@(?!/)FontBBox(?= 4 array astore)@currentdict /FontBBox get aload pop@’ \
${1+”$@”}

Note that the
URW fonts distributed by the GIMP project do not tickle this problem (but they probably don’t include the Cyrillic characters either).

Leave a Reply