home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / untype1 / part01 / README < prev    next >
Text File  |  1991-05-19  |  9KB  |  214 lines

  1. untype1 - Adobe Type 1 Font Decryption
  2.  
  3. Chris B. Sears
  4. sears@pa.dec.com
  5. Digital Equipment Corporation
  6. May 31, 1990
  7.  
  8. INTRODUCTION
  9.  
  10.     These utilities decrypt an Adobe Type 1 font and leave a raw PostScript
  11. file as a result.  Most of this procedure is documented in the Adobe Black Book,
  12. "Adobe Type 1 Font Format."  It can be ordered directly from Adobe Systems.
  13. This book is referenced here and in the code as the Black Book.
  14.  
  15.     The purpose here is both to have a tool that can be used for decrypting
  16. fonts into a format more palatable for graphics programs to ingest directly
  17. and also as a reference implementation for PostScript interpreters.  Towards
  18. that end, I try to be more clear than efficient.
  19.  
  20. POSTSCRIPT RESULTS
  21.  
  22.     The result of untype1 is a very simple PostScript file containing only:
  23.  
  24.         /name
  25.         integers
  26.         closepath
  27.         curveto
  28.         lineto
  29.         moveto
  30.         def
  31.         { }
  32.  
  33.     Each character outline becomes a single PostScript procedure:
  34.  
  35.     0. the first three definitions are the Copyright, Notice and FullName.
  36.     1. each procedure occupies a single line.  Lines can be very long.
  37.     2. the syntax is very simple PostScript, easily parsed by a yacc/lex filter.
  38.     3. all arguments directly precede the PostScript command.
  39.     4. the variable charWidth is set to the width of the character.
  40.     5. the procedure creates a path corresponding to the character.
  41.     6. the font bounding box is generally based on a 1000x1000 FontBBox.
  42.  
  43.     For example:
  44.  
  45.         /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
  46.  
  47.     The trailing moveto is hard to get rid of.  It is an artifact of the
  48. semantics of the Type 1 closepath definition which leaves the currentpoint
  49. in the path.  See page 51 of the Black Book.  It is easily ignored.
  50. Note that with GhostScript 2.0, the moveto is omitted.
  51.  
  52. USING UNTYPE1
  53.  
  54.     Converting a Type 1 font program into the outlines is done in two phases.
  55. It assumes that you have a Macintosh, a Unix system and Display Postscript.
  56. NeWS, GhostScript or a LaserWriter can be used to interpret as well.
  57. PostScript that I use is pretty simple, but the implementation limits of
  58. other systems may break this approach.
  59.  
  60.     1. Using un-adobe, which is in hqx format, convert the Type 1 font into
  61.        a eexec encoded text file.  Un-adobe.hqx was snarfed off of SUMEX.
  62.     2. Using untype1, a shell script driver, convert the results into a list
  63.        of simple PostScript programs.
  64.  
  65.     Here is a description of the files in this directory:
  66.  
  67.     untype1
  68.         a shell script that uses eexec, chars and DPStest to take
  69.         an ASCII PostScript PostScript file with an encrypted Adobe Type 1
  70.         font and generate raw PostScript for the font
  71.     Makefile
  72.         a make(1) description file for compiling exec.c and chars.c
  73.     eexec.c
  74.         decrypts a font file encrypted for the eexec operator
  75.     chars.c
  76.         decrypts a font file of encrypted CharStrings.  chars couldn't
  77.         easily be written to accept standard input because it repositions
  78.         itself with fseek() after a charstring has been decrypted.
  79.     untype1_header.ps
  80.     untype1_trailer.ps
  81.         PostScript wrappers that remove font hints, squash procedures
  82.         and transform operators and operands.
  83.     un-adobe.hqx
  84.         a Macintosh application that converts an Adobe PostScript
  85.         font into an ASCII file for transfer to a UNIX system
  86.     view_header.ps
  87.     view_trailer.ps
  88.         After converting a Type 1 file, these files can be used
  89.         for viewing the results with Display PostScript.
  90.  
  91.     To decrypt a Type 1 font first transform the Adobe font file into a text
  92. file on a Macintosh.  This can be done with the Macintosh program in unadobe.hqx
  93. written by Jerry Keough and Ted Ede at Mitre Corporation.  Next transfer the
  94. encrypted PostScript file from the Macintosh to your UNIX system with a file
  95. transfer utility like NCSA Telnet or Kermit.  Be sure to transfer this file in
  96. text mode and *not* binary mode).  Once the font file is on your UNIX system,
  97. you can perform the decryption with the shell script untype1.
  98.  
  99.     untype1 is basically three pass: it runs eexec and chars, wraps the output
  100. with untype1_header.ps and untype1_trailer.ps and then runs it through Display
  101. PostScript.  To interact with Display PostScript we use dpstest(1X) found in
  102. /usr/examples/dps/dpstest in the Ultrix release.
  103.  
  104.     view_header.ps and view_trailer.ps are useful for displaying the font
  105. using Display PostScript. Concatenate view_header.ps, the font file and
  106. view_trailer.ps together.  The results can be viewed with DPStest.
  107.  
  108. CURRENT BUGS AND LIMITATIONS
  109.  
  110.     1. I don't understand the Type 1 sbw command.  The y component of the
  111.        width vector is currently ignored.  What fonts use this, Kanji?
  112.     2. Using GhostScript as the interpreter doesn't work entirely because
  113.        GhostScript hasn't completely implemented save/restore semantics.
  114.        These are used by hybrid fonts such as Optima which have hires and
  115.        lowres dictionaries.  Non-hybrid fonts work.  The work around is to
  116.        use the hires version.  Redefining dtransform fakes the font program
  117.        into thinking that it is on a 2540 dpi device.  GhostScript is about
  118.        10 times faster than Display PostScript.
  119.     3. GhostScript omits the trailing moveto.
  120.     4. FontBBox or FontMatrix aren't parsed.  Actually, not much is.
  121.     5. Kevin O'Gorman reports that he gets VMErrors on a LaserWriter.
  122.  
  123. COPYRIGHT NOTICE
  124.  
  125. Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
  126.  
  127.                        All Rights Reserved
  128.  
  129. Permission to use, copy, modify, and distribute this software and its
  130. documentation for any purpose and without fee is hereby granted,
  131. provided that the above copyright notice appear in all copies and that
  132. both that copyright notice and this permission notice appear in
  133. supporting documentation, and that the name of Digital not be
  134. used in advertising or publicity pertaining to distribution of the
  135. software without specific, written prior permission.
  136.  
  137. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  138. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  139. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  140. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  141. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  142. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  143. SOFTWARE.
  144.  
  145. RELEASE NOTES AND CHANGES
  146.  
  147. November 9, 1990
  148.  
  149. StoneSerif used " -| " rather than " RD " to read the encrypted charstrings.
  150. There is a bug with seac where the x origin of accented characters is wrong.
  151. Renamed the shell script transform to untype1.
  152. The untype1_header.ps and untype1_trailer.ps files were substantially revised
  153. to use the pathforall operator.  This resulted in much simple code and the
  154. resulting PostScript output was much simpler still.  Used bind def.
  155.  
  156. November 15, 1990
  157.  
  158. Added charWidth definitions to the resulting procedures.
  159. Changed view_trailer.ps to underline the width on the baseline.
  160. Added flattenpath and setflat but commented it out.
  161. The setflat parameter should probably be increased to reduce the number
  162. of line segments in a flattened character outline.
  163.  
  164. November 19, 1990
  165.  
  166. Added a define for SEEK_SET.  Some people on the net didn't have this
  167. in their <stdio.h>
  168.  
  169. November 23, 1990
  170.  
  171. I tried using GhostScript instead of DPStest and ran into a bug with
  172. save/restore.  I submitted a bug report to Peter Deutsch.
  173. Added GhostScript and NeWS command lines in the untype1 shell script.
  174. Just comment out DPStest and uncomment out your favorite PostScript
  175. interpreter.  DPStest is much more useful here than dxpsview.
  176.  
  177. November 25, 1990
  178.  
  179. There are often two font programs in a Type 1 file: one suitable for a
  180. high-resolution typesetter and a simpler faster one for a LaserWriter.
  181. I added a dtransform routine to fool the font program into thinking that
  182. it is running on a high-resolution device.  This can be commented out
  183. if the low-resolution version is needed.
  184.  
  185. December 4, 1990
  186.  
  187. The differing control points problem was overcome by rounding before
  188. converting to integer in untype1_trailer.ps.  GhostScript and PostScript
  189. now generate the same results except for hash ordering and trailing moveto.
  190. The untype1 shell script was modified to be position independent.
  191. You can now run it from a directory other than the current directory.
  192. seac still doesn't work completely correctly.  It is an Adobe docubug.
  193. The hsbw IS used more than once.  In fact with a seac font, it is used
  194. 3 times.  I gave up trying to get Adobe to explain it.
  195.  
  196. December 28, 1990
  197.  
  198. The Copyright notice is retained with the decrypted font.  There is a
  199. save/restore pair in the font dictionary loop in untype1_trailer.ps.
  200. This should correct the LaserWriter VMErrors.
  201.  
  202. January 16, 1991
  203.  
  204. Added the "12 15" testadd opcode definition that Peter Deutsch mentioned
  205. in 2.1 GhostScript.  It doesn't seem to work.
  206.  
  207. April 30, 1991
  208.  
  209. For the most part untype1 is unimportant with the new releases of the
  210. Adobe PostScript interpreters.  Display PostScript release 1006.9 uses
  211. unprotected versions of the built-in fonts.  You can't get at the high
  212. resolution versions from a low-resolution interpreter but it is a LOT
  213. easier to work with.
  214.