🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #570

Re: Important safety tip

#570
From: Ned Batchelder
Date: Thu, 15 Jun 1989 19:57
32 lines
2123 bytes
The Encoding is a required component of a font, as the table on page 95 of the red book points out. Even though the BuildChar procedure never uses it, the names in the encoding vector are used as the basis for finding glyphs in the font cache. Clearly, it would be nicer if leaving it out got you an error from definefont instead of crashing your printer.

If you want to save space in your font, replace these lines:

>	/Encoding 256 array def
>	StandardEncoding Encoding copy

with:

	/Encoding StandardEncoding def

There is no need to make a copy of the array; no one is going to be changing it anyway.

What should you do if you really don't need an encoding vector? For example, suppose you want to create a font which is just 256 different-sized circles, where the character code is used as the radius of the circle? If you don't have an encoding vector with 256 unique names, the font cache will give you the wrong glyphs. If you use StandardEncoding, there are duplicates in it, so you wouldn't get 256 different glyphs, either. (For example, the first 32 entries in StandardEncoding are all /.notdef, so all c





haracter codes 0-31 all map to the same entry in the font cache.)

If you try to create an explicit array of 256 distinct names, it takes up a lot of space in the PostScript file.

What I came up with was:

	/Encoding [ 0 1 255 { (_) 0  3 2 roll put cvn } for ] def

This uses a loop to create all 256 single-character strings, and turn them into one-byte names. The names are left on the stack where the square braces gather them into the array.

Any other cute tricks?

Ned Batchelder, Digital Equipment Corp., BatchelderN@Hannah.DEC.com
Technical Details
Message-ID: <2991@shlump.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shlump.dec.com!icosa.dec.com!batcheldern
References: <13-Jun-89.091841@192.41.214.2>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shlump.dec.com!icosa.dec.com!batcheldern
From: batcheldern@icosa.dec.com (Ned Batchelder)
Newsgroups: comp.lang.postscript
Subject: Re: Important safety tip
Keywords: Seabrook fonts
Message-ID: <2991@shlump.dec.com>
Date: 15 Jun 89 19:57:19 GMT
References: <13-Jun-89.091841@192.41.214.2>
Sender: news@shlump.dec.com
Lines: 27