Name Last modified Size Description
Parent Directory - psfonts.cf 2000-04-19 22:51 554 nsprint 2000-04-19 22:51 100 nsfix.c 2000-04-19 22:51 11K nsfilter 2000-04-19 22:51 435 notscape 2000-04-19 22:51 555 fontsz.cf 2000-04-19 22:51 164 Makefile 2000-04-19 22:51 60
This is a collection of supplements to Netscape 4.x on Unix. Probably they will also work with Netscape 3.x, possilby with minor modifications.
This is a program that allows to substitute the font metrics of any PostScript font in Netscape.
When Netscape prints the files to PostScript format it uses a built-in table of character widths. It prints all the fixed-width characters in the typeface "Courier" and all the variable-width characters in the typeface "Times". And if the PostScript printer has these fonts by Adobe then everything goes fine because the tables inside Netscape are generated from the Adobe fonts. But if the fonts are different (say, those supplied with Ghostscripts or the fonts with non-latin characters) then the result is quite ugly. This program allows to replace the width tables inside the Netscape executable with the tables for any given font. The only problem is that Netscape can hold only one set of tables at once. So if you want to print with different fonts (say, for different languages or encodings) you will have to make multiple copies of the executable, tune each of them for its font and then run them separately.
I tried to make the program as machine-independent as possible. But because it patches the binary files it still has the dependencies on hardware. The default version as supplied was designed for Intel x86 machines but it should work OK on any machine with 32-bit CPU and 4Kbyte (or less) page size. If it can't find the tables matching the font names on some other architecture the first thing to try would be reduce the `PAGEBITS' definition in the source code. On the machines with non-page-aligned structure of executables it won't work at all. I don't know whether would it work on the 64-bit machines. This may depend on whether the Netscape executable was compiled in 32-bit or 64-bit mode. For the 64-bit executables it may be neccessary to change the definition of the type `tptr' to an 8-byte integer type (probably `long' or `long long'). Also must be re-compiled for patching of the Netscape binary for each particular machine architecture because it assumes the byte order of the current machine.
It might be possible to create a program that would patch a running Netscape binary on the fly, that would allow changing the printing fonts as neccessary when Netscape is running. But this would be even more platform-dependent, so I don't feel any enthusiasm about doing that.
I have tested the program on the Intel machines, Netscape 4.08 and 4.7, OS FreeBSD (both a.out and ELF formats of the Netscape binary) and UnixWare.
After all these scary issues are resolved the compiling is easy: just run `make'.
To command to patch the Netscape is:
./nsfix <netscape-binary> <config-file>
Please make a copy of the original Netscape binary before patching in case anything goes wrong. Patch the copy, test that it works OK and only then install it. The configuration file describes the fonts that are to be used. An example is provided in the file psfonts.cf.
Each line in the configuration file consists of 4 columns:
<PS_font_name> <font_base_file> <suffix_afm> <suffix_font>
For example, the following line from my configuration file:
Courier /usr/lib/X11/fonts/ttf/cokoi8n.koi8-r .afm .pfa
says that the font `Courier' will be replaced with the font taken from the file `/usr/lib/X11/fonts/ttf/cokoi8n.koi8-r.pfa' and the metrics for that font will be taken from the file `/usr/lib/X11/fonts/ttf/cokoi8n.koi8-r.afm' .
One more caveat: the new font must have a proper encoding table. Some fonts contain characters for multiple encodings hoping that the program wil re-encode them as neccessary. This won't work in this case, only the primary encoding table of the font will be used.
These are the filters for printing from Netscape.
Changing the metrics is not the end of the story. This will provide proper placement of the characters but not the characters themselves. There are a few ways to provide the characters:
First, if you use GhostScript you may configure proper aliases in the GhostScript configuration file. We will consider this variant trivial and won't discuss it furter except for one caveat: Netscape tries to re-encode the fonts per the ISO Latin-1 encoding. If the primary encoding of the font is different this cause unexpected effects. So you still may consider using the filters (at least in a simplified form) to solve this problem.
Second, load the fonts right into your printer. This is very much like configuring GhostScript.
Third, use the provided filters. The script `nsfilter' reads the output of Netscape on its standard input and puts the result to its standard output. It uses the same configuration file `psfonts.cf' as `nsfix'. First it looks for the configuration file in the user's home directory ($HOME/.netscape/psfonts.cf) and if the file it not there then the second guess is the system-wide configuration file /usr/local/etc/psfonts.cf. The script inserts the fonts into the output and also removes the Netscape's experiments with the encodings.
`nsfilter' is generally intended to be ran by user, not by the printing subsystem. The reason is that the user may have changed fonts in his Netscape and the printing subsystem would have no way to access user's configuration file. But if all the users are using the same fonts then it may be incorporated into the printing subsystem and use the system-wide configuration file.
The script `nsprint' is purely for convenience, to type it as a printing command in the Netscape printing window. It just pipelines the data through `nsfilter' to the printing program which also gets all the arguments. Please note that the SystemV-style and BSD-style systems use different printing programs (although they commonly provide compatibility with the other style too). The script tries to guess the type of system and use its native print program, `lp' or `lpr'. But in case it guesses wrong you may want to change this in the script. Also if the printer does not support PostScript directly this script may be a good place to insert a call to GhostScript.
Netscape on Unix has a very annoying "feature", it does not remember the desired base size of the scalable screen fonts and always resets it to 12.0 points. Even if the size is changed manually in its preferences file, Netscape forgets it after it exits.
So my solution was to write a program which would change the size to my favorite one every time right before starting Netscape. `notscape' is exactly such a program, it sets the font sizes an then transparently executes netscape. It takes the font sizes from the file `$HOME/.netscape/fontsz.cf' . An example of such file is provided. The format of the file is quite self-explanatory, for example the lines
fixed-koi8-r 140
prop-koi8-r 150
mean "set the size of the fixed-width screen font in the encoding koi8-r to 14.0 points; set the size of the proportional (variable-width) font in the encoding koi8-r to 15.0 points".