1 | Installing the fonts in Netscape Navigator |
---|
2 | |
---|
3 | by Sergey Babkin |
---|
4 | <babkin@bellatlantic.net>, <sab123@hotmail.com> |
---|
5 | |
---|
6 | This is a collection of supplements to Netscape 4.x on |
---|
7 | Unix. Probably they will also work with Netscape 3.x, |
---|
8 | possilby with minor modifications. |
---|
9 | |
---|
10 | Makefile |
---|
11 | nsfix.c |
---|
12 | psfonts.cf |
---|
13 | |
---|
14 | This is a program that allows to substitute the font metrics |
---|
15 | of any PostScript font in Netscape. |
---|
16 | |
---|
17 | When Netscape prints the files to PostScript format it uses a |
---|
18 | built-in table of character widths. It prints all the fixed-width |
---|
19 | characters in the typeface "Courier" and all the variable-width |
---|
20 | characters in the typeface "Times". And if the PostScript printer |
---|
21 | has these fonts by Adobe then everything goes fine because |
---|
22 | the tables inside Netscape are generated from the Adobe fonts. |
---|
23 | But if the fonts are different (say, those supplied with Ghostscripts |
---|
24 | or the fonts with non-latin characters) then the result is quite |
---|
25 | ugly. This program allows to replace the width tables inside |
---|
26 | the Netscape executable with the tables for any given font. |
---|
27 | The only problem is that Netscape can hold only one set of tables |
---|
28 | at once. So if you want to print with different fonts (say, |
---|
29 | for different languages or encodings) you will have to make |
---|
30 | multiple copies of the executable, tune each of them for its |
---|
31 | font and then run them separately. |
---|
32 | |
---|
33 | I tried to make the program as machine-independent as possible. |
---|
34 | But because it patches the binary files it still has the dependencies |
---|
35 | on hardware. The default version as supplied was designed for |
---|
36 | Intel x86 machines but it should work OK on any machine |
---|
37 | with 32-bit CPU and 4Kbyte (or less) page size. If it can't |
---|
38 | find the tables matching the font names on some other architecture |
---|
39 | the first thing to try would be reduce the `PAGEBITS' definition |
---|
40 | in the source code. On the machines with non-page-aligned structure |
---|
41 | of executables it won't work at all. I don't know whether would |
---|
42 | it work on the 64-bit machines. This may depend on whether the |
---|
43 | Netscape executable was compiled in 32-bit or 64-bit mode. For |
---|
44 | the 64-bit executables it may be neccessary to change the definition |
---|
45 | of the type `tptr' to an 8-byte integer type (probably `long' |
---|
46 | or `long long'). Also must be re-compiled for patching of the |
---|
47 | Netscape binary for each particular machine architecture because |
---|
48 | it assumes the byte order of the current machine. |
---|
49 | |
---|
50 | It might be possible to create a program that would patch |
---|
51 | a running Netscape binary on the fly, that would allow |
---|
52 | changing the printing fonts as neccessary when Netscape is |
---|
53 | running. But this would be even more platform-dependent, |
---|
54 | so I don't feel any enthusiasm about doing that. |
---|
55 | |
---|
56 | I have tested the program on the Intel machines, Netscape |
---|
57 | 4.08 and 4.7, OS FreeBSD (both a.out and ELF formats of the |
---|
58 | Netscape binary) and UnixWare. |
---|
59 | |
---|
60 | After all these scary issues are resolved the compiling |
---|
61 | is easy: just run `make'. |
---|
62 | |
---|
63 | To command to patch the Netscape is: |
---|
64 | ./nsfix <netscape-binary> <config-file> |
---|
65 | |
---|
66 | Please make a copy of the original Netscape binary before |
---|
67 | patching in case anything goes wrong. Patch the copy, test |
---|
68 | that it works OK and only then install it. The configuration |
---|
69 | file describes the fonts that are to be used. An example |
---|
70 | is provided in the file psfonts.cf. |
---|
71 | |
---|
72 | Each line in the configuration file consists of 4 |
---|
73 | columns: |
---|
74 | |
---|
75 | <PS_font_name> <font_base_file> <suffix_afm> <suffix_font> |
---|
76 | |
---|
77 | For example, the following line from my configuration file: |
---|
78 | |
---|
79 | Courier /usr/lib/X11/fonts/ttf/cokoi8n.koi8-r .afm .pfa |
---|
80 | |
---|
81 | says that the font `Courier' will be replaced with the |
---|
82 | font taken from the file `/usr/lib/X11/fonts/ttf/cokoi8n.koi8-r.pfa' |
---|
83 | and the metrics for that font will be taken from the file |
---|
84 | `/usr/lib/X11/fonts/ttf/cokoi8n.koi8-r.afm' . |
---|
85 | |
---|
86 | One more caveat: the new font must have a proper encoding |
---|
87 | table. Some fonts contain characters for multiple encodings |
---|
88 | hoping that the program wil re-encode them as neccessary. |
---|
89 | This won't work in this case, only the primary encoding table |
---|
90 | of the font will be used. |
---|
91 | |
---|
92 | nsfilter |
---|
93 | nsprint |
---|
94 | psfonts.cf |
---|
95 | |
---|
96 | These are the filters for printing from Netscape. |
---|
97 | |
---|
98 | Changing the metrics is not the end of the story. This will |
---|
99 | provide proper placement of the characters but not the |
---|
100 | characters themselves. There are a few ways to provide |
---|
101 | the characters: |
---|
102 | |
---|
103 | First, if you use GhostScript you may configure proper |
---|
104 | aliases in the GhostScript configuration file. We will |
---|
105 | consider this variant trivial and won't discuss it furter |
---|
106 | except for one caveat: Netscape tries to re-encode the |
---|
107 | fonts per the ISO Latin-1 encoding. If the primary encoding |
---|
108 | of the font is different this cause unexpected effects. |
---|
109 | So you still may consider using the filters (at least in a |
---|
110 | simplified form) to solve this problem. |
---|
111 | |
---|
112 | Second, load the fonts right into your printer. This is |
---|
113 | very much like configuring GhostScript. |
---|
114 | |
---|
115 | Third, use the provided filters. The script `nsfilter' |
---|
116 | reads the output of Netscape on its standard input and |
---|
117 | puts the result to its standard output. It uses the same |
---|
118 | configuration file `psfonts.cf' as `nsfix'. First it |
---|
119 | looks for the configuration file in the user's home |
---|
120 | directory ($HOME/.netscape/psfonts.cf) and if the |
---|
121 | file it not there then the second guess is the system-wide |
---|
122 | configuration file /usr/local/etc/psfonts.cf. The |
---|
123 | script inserts the fonts into the output and also |
---|
124 | removes the Netscape's experiments with the encodings. |
---|
125 | |
---|
126 | `nsfilter' is generally intended to be ran by user, not by the |
---|
127 | printing subsystem. The reason is that the user may have |
---|
128 | changed fonts in his Netscape and the printing subsystem |
---|
129 | would have no way to access user's configuration file. |
---|
130 | But if all the users are using the same fonts then it |
---|
131 | may be incorporated into the printing subsystem and use |
---|
132 | the system-wide configuration file. |
---|
133 | |
---|
134 | The script `nsprint' is purely for convenience, to type it |
---|
135 | as a printing command in the Netscape printing window. |
---|
136 | It just pipelines the data through `nsfilter' to the |
---|
137 | printing program which also gets all the arguments. Please |
---|
138 | note that the SystemV-style and BSD-style systems use different |
---|
139 | printing programs (although they commonly provide compatibility |
---|
140 | with the other style too). The script tries to guess the |
---|
141 | type of system and use its native print program, `lp' or |
---|
142 | `lpr'. But in case it guesses wrong you may want |
---|
143 | to change this in the script. Also if the printer does not support |
---|
144 | PostScript directly this script may be a good place to |
---|
145 | insert a call to GhostScript. |
---|
146 | |
---|
147 | notscape |
---|
148 | fontsz.cf |
---|
149 | |
---|
150 | Netscape on Unix has a very annoying "feature", it does |
---|
151 | not remember the desired base size of the scalable screen |
---|
152 | fonts and always resets it to 12.0 points. Even if the size |
---|
153 | is changed manually in its preferences file, Netscape |
---|
154 | forgets it after it exits. |
---|
155 | |
---|
156 | So my solution was to write a program which would change |
---|
157 | the size to my favorite one every time right before |
---|
158 | starting Netscape. `notscape' is exactly such a program, |
---|
159 | it sets the font sizes an then transparently executes |
---|
160 | netscape. It takes the font sizes from the file |
---|
161 | `$HOME/.netscape/fontsz.cf' . An example of such file |
---|
162 | is provided. The format of the file is quite self-explanatory, |
---|
163 | for example the lines |
---|
164 | |
---|
165 | fixed-koi8-r 140 |
---|
166 | prop-koi8-r 150 |
---|
167 | |
---|
168 | mean "set the size of the fixed-width screen font in the |
---|
169 | encoding koi8-r to 14.0 points; set the size of the proportional |
---|
170 | (variable-width) font in the encoding koi8-r to 15.0 points". |
---|
171 | |
---|
172 | |
---|
173 | nspr |
---|
174 | by Zvezdan Petkovic |
---|
175 | |
---|
176 | To print from Netscape, I usually print to the Postscript file first. |
---|
177 | Then I use this small script to change the names of Times and Courier fonts |
---|
178 | in the file and remove `/Encoding' lines. After that the file can be |
---|
179 | sent to printer. |
---|
180 | |
---|