home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume19
/
untype1
/
part01
/
README
< prev
next >
Wrap
Text File
|
1991-05-19
|
9KB
|
214 lines
untype1 - Adobe Type 1 Font Decryption
Chris B. Sears
sears@pa.dec.com
Digital Equipment Corporation
May 31, 1990
INTRODUCTION
These utilities decrypt an Adobe Type 1 font and leave a raw PostScript
file as a result. Most of this procedure is documented in the Adobe Black Book,
"Adobe Type 1 Font Format." It can be ordered directly from Adobe Systems.
This book is referenced here and in the code as the Black Book.
The purpose here is both to have a tool that can be used for decrypting
fonts into a format more palatable for graphics programs to ingest directly
and also as a reference implementation for PostScript interpreters. Towards
that end, I try to be more clear than efficient.
POSTSCRIPT RESULTS
The result of untype1 is a very simple PostScript file containing only:
/name
integers
closepath
curveto
lineto
moveto
def
{ }
Each character outline becomes a single PostScript procedure:
0. the first three definitions are the Copyright, Notice and FullName.
1. each procedure occupies a single line. Lines can be very long.
2. the syntax is very simple PostScript, easily parsed by a yacc/lex filter.
3. all arguments directly precede the PostScript command.
4. the variable charWidth is set to the width of the character.
5. the procedure creates a path corresponding to the character.
6. the font bounding box is generally based on a 1000x1000 FontBBox.
For example:
/period { /charWidth 287 def 79 52 moveto 79 18 109 -12 143 -12 curveto 177 -12 207 18 207 52 curveto 207 86 177 116 143 116 curveto 109 116 79 86 79 52 curveto closepath 79 52 moveto } def
The trailing moveto is hard to get rid of. It is an artifact of the
semantics of the Type 1 closepath definition which leaves the currentpoint
in the path. See page 51 of the Black Book. It is easily ignored.
Note that with GhostScript 2.0, the moveto is omitted.
USING UNTYPE1
Converting a Type 1 font program into the outlines is done in two phases.
It assumes that you have a Macintosh, a Unix system and Display Postscript.
NeWS, GhostScript or a LaserWriter can be used to interpret as well.
PostScript that I use is pretty simple, but the implementation limits of
other systems may break this approach.
1. Using un-adobe, which is in hqx format, convert the Type 1 font into
a eexec encoded text file. Un-adobe.hqx was snarfed off of SUMEX.
2. Using untype1, a shell script driver, convert the results into a list
of simple PostScript programs.
Here is a description of the files in this directory:
untype1
a shell script that uses eexec, chars and DPStest to take
an ASCII PostScript PostScript file with an encrypted Adobe Type 1
font and generate raw PostScript for the font
Makefile
a make(1) description file for compiling exec.c and chars.c
eexec.c
decrypts a font file encrypted for the eexec operator
chars.c
decrypts a font file of encrypted CharStrings. chars couldn't
easily be written to accept standard input because it repositions
itself with fseek() after a charstring has been decrypted.
untype1_header.ps
untype1_trailer.ps
PostScript wrappers that remove font hints, squash procedures
and transform operators and operands.
un-adobe.hqx
a Macintosh application that converts an Adobe PostScript
font into an ASCII file for transfer to a UNIX system
view_header.ps
view_trailer.ps
After converting a Type 1 file, these files can be used
for viewing the results with Display PostScript.
To decrypt a Type 1 font first transform the Adobe font file into a text
file on a Macintosh. This can be done with the Macintosh program in unadobe.hqx
written by Jerry Keough and Ted Ede at Mitre Corporation. Next transfer the
encrypted PostScript file from the Macintosh to your UNIX system with a file
transfer utility like NCSA Telnet or Kermit. Be sure to transfer this file in
text mode and *not* binary mode). Once the font file is on your UNIX system,
you can perform the decryption with the shell script untype1.
untype1 is basically three pass: it runs eexec and chars, wraps the output
with untype1_header.ps and untype1_trailer.ps and then runs it through Display
PostScript. To interact with Display PostScript we use dpstest(1X) found in
/usr/examples/dps/dpstest in the Ultrix release.
view_header.ps and view_trailer.ps are useful for displaying the font
using Display PostScript. Concatenate view_header.ps, the font file and
view_trailer.ps together. The results can be viewed with DPStest.
CURRENT BUGS AND LIMITATIONS
1. I don't understand the Type 1 sbw command. The y component of the
width vector is currently ignored. What fonts use this, Kanji?
2. Using GhostScript as the interpreter doesn't work entirely because
GhostScript hasn't completely implemented save/restore semantics.
These are used by hybrid fonts such as Optima which have hires and
lowres dictionaries. Non-hybrid fonts work. The work around is to
use the hires version. Redefining dtransform fakes the font program
into thinking that it is on a 2540 dpi device. GhostScript is about
10 times faster than Display PostScript.
3. GhostScript omits the trailing moveto.
4. FontBBox or FontMatrix aren't parsed. Actually, not much is.
5. Kevin O'Gorman reports that he gets VMErrors on a LaserWriter.
COPYRIGHT NOTICE
Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
RELEASE NOTES AND CHANGES
November 9, 1990
StoneSerif used " -| " rather than " RD " to read the encrypted charstrings.
There is a bug with seac where the x origin of accented characters is wrong.
Renamed the shell script transform to untype1.
The untype1_header.ps and untype1_trailer.ps files were substantially revised
to use the pathforall operator. This resulted in much simple code and the
resulting PostScript output was much simpler still. Used bind def.
November 15, 1990
Added charWidth definitions to the resulting procedures.
Changed view_trailer.ps to underline the width on the baseline.
Added flattenpath and setflat but commented it out.
The setflat parameter should probably be increased to reduce the number
of line segments in a flattened character outline.
November 19, 1990
Added a define for SEEK_SET. Some people on the net didn't have this
in their <stdio.h>
November 23, 1990
I tried using GhostScript instead of DPStest and ran into a bug with
save/restore. I submitted a bug report to Peter Deutsch.
Added GhostScript and NeWS command lines in the untype1 shell script.
Just comment out DPStest and uncomment out your favorite PostScript
interpreter. DPStest is much more useful here than dxpsview.
November 25, 1990
There are often two font programs in a Type 1 file: one suitable for a
high-resolution typesetter and a simpler faster one for a LaserWriter.
I added a dtransform routine to fool the font program into thinking that
it is running on a high-resolution device. This can be commented out
if the low-resolution version is needed.
December 4, 1990
The differing control points problem was overcome by rounding before
converting to integer in untype1_trailer.ps. GhostScript and PostScript
now generate the same results except for hash ordering and trailing moveto.
The untype1 shell script was modified to be position independent.
You can now run it from a directory other than the current directory.
seac still doesn't work completely correctly. It is an Adobe docubug.
The hsbw IS used more than once. In fact with a seac font, it is used
3 times. I gave up trying to get Adobe to explain it.
December 28, 1990
The Copyright notice is retained with the decrypted font. There is a
save/restore pair in the font dictionary loop in untype1_trailer.ps.
This should correct the LaserWriter VMErrors.
January 16, 1991
Added the "12 15" testadd opcode definition that Peter Deutsch mentioned
in 2.1 GhostScript. It doesn't seem to work.
April 30, 1991
For the most part untype1 is unimportant with the new releases of the
Adobe PostScript interpreters. Display PostScript release 1006.9 uses
unprotected versions of the built-in fonts. You can't get at the high
resolution versions from a low-resolution interpreter but it is a LOT
easier to work with.