[comp.lang.postscript] Fontographer font on NeXT

jacob@gore.com (Jacob Gore) (08/15/90)

I am trying to get a third-party type 3 font (generated with Fontographer)
to work on a NeXT, and I ran into this problem:

The font defines a dictionary (let's call it D) and tucks it away in
userdict.  It stores in D things such as routines that BuildChar calls and
the encoding.

If I prepend the font definition to the Postscript program that uses it,
everything prints OK.  But if I just print the program, I get "D undefined"
errors.

I suspect that userdict gets reset between the automatic sending of the
font definition to DPS and the sending of the program to DPS.  Is this
correct?

If so, is there a dictionary that can be used instead of userdict?  I tried
using nextdict, which (according to the Digital Librarian) is only
documented in Chapter 4 of the Reference Manual ("Drawing"), where it is
described as "a modifiable dictionary containing any dynamic information
common to all applications, such as downloaded packages."  Unfortunately,
that didn't work: "nextdict begin /D 40 dict def" returns an invalidaccess
error on def.

Any ideas?

Jacob
--
Jacob Gore		Jacob@Gore.Com			boulder!gore!jacob

orthlieb@adobe.COM (Carl Orthlieb) (08/21/90)

In article <650004@gore.com> you write:
>I am trying to get a third-party type 3 font (generated with Fontographer)
>to work on a NeXT, and I ran into this problem:
>
>The font defines a dictionary (let's call it D) and tucks it away in
>userdict.  It stores in D things such as routines that BuildChar calls and
>the encoding.
>If I prepend the font definition to the Postscript program that uses it,
>everything prints OK.  But if I just print the program, I get "D undefined"
>errors.
In version 1.0 software of the NeXT machine, all fonts which are 
automatically loaded into so called SharedVM (renamed GlobalVM in PostScript
Level 2). The semantics of GlobalVM are such that composite objects which
are placed into GlobalVM are not subject to save/restore. By loading fonts
into GlobalVM they are accessible to all PostScript contexts which are
running on the NeXT machine. This is a memory savings.
   Unfortunately some Type 3 fonts don't work properly when loaded into
GlobalVM. I'll describe the reason for this in just a moment but here is
a foolproof way of ensuring that your fonts will work as expected:

At the top of the Type 3 font file put:
	/currentshared where { 
		pop /oldshared currentshared def false setshared}if

	%  now comes the font definition as before
	% ....
	%  /MyType3font exch definefont pop		% typical last line

After the last line of the font file put:
	/currentshared where{ pop oldshared def }if

% End of hack

This bit of code ensures that the font gets always loaded into
LocalVM (called privateVM in Display PostScript). While the font will
not benefit from the space saving benefits of GlobalVM it will WORK
which is the critical thing.

Here is what happens when the font gets run off the disk without
the special code:

/myapplication save def
	/MyType3font findfont 	% font gets loaded off disk by findfont
				% and is loaded into GlobalVM
				% when font is loaded, key is def'ed
				% into userdict (in LocalVM)

				% Font definition is created in
				% GlobalFontDirectory.
     ... app uses font
myapplication restore		% key in userdict goes away with restore
		% entry in GlobalFontDirectory does NOT go away since font
		% is in GlobalVM

The next usage of the font will NOT cause the font to be loaded off the
disk since it will already be registered in GlobalFontDirectory. Since
the font is not loaded again, the entry in userdict is NOT created again.
This means that the place where that key is expected will result in an
undefined.

  There are a number of other ways that Type 3 fonts loaded into GlobalVM
can fail, especially 'invalidaccess' where an object created in LocalVM
is stored into a Global object which is not allowed. For that reason, 
future versions of the Display PostScript will load Type 3 fonts into
LocalVM (PrivateVM in today's DPS world).

Working in GlobalVM requires discipline. We'll be writing some
technical papers on this in the near future. For the definitive documentation
see the coming version of the PostScript language reference manual
which documents PostScript Level 2 (and Display PostScript) or you can
order the Display PostScript system reference which is available right now.

The DPS document is also available from our server.

Hope this helps,

Carl 8-}

orthlieb@adobe.COM (Carl Orthlieb) (08/23/90)

Whoops, there was a typo in this last message:

>	%  /MyType3font exch definefont pop		% typical last line
>
>After the last line of the font file put:
>	/currentshared where{ pop oldshared def }if
>
>% End of hack

This line should read
   /currentshared where {pop oldshared setshared}if

the 'def' should be replaced by 'setshared'

Sorry for the inconvenience,

Carl 8-)