home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / adobeenc.zoo / encrypt.shar / header.ps < prev    next >
Text File  |  1990-10-27  |  4KB  |  174 lines

  1. %!
  2. %
  3. % header.ps
  4. %
  5. % After interpreting a decrypted Adobe font program there are four
  6. dictionaries.
  7. %
  8. %        font (implicit)
  9. %        FontInfo
  10. %        Private
  11. %        CharStrings
  12. %
  13. % The strategy is to redefine certain operators, interpret the font and dump
  14. % the resulting dictionaries while filtering out font hint operators.
  15. %
  16.  
  17. /myString 200 string def
  18. /Helvetica findfont 20 scalefont setfont
  19.  
  20. /readonly { } def
  21. /executeonly { } def
  22. /noaccess { } def
  23. /definefont { } def
  24.  
  25. /myWriteString {
  26.     print
  27. } def
  28.  
  29. /numString 20 string def
  30.  
  31. /printNums {
  32.     /i exch def
  33.     i 1 sub -1 0 { index numString cvs print ( ) print } for
  34.     i { pop } repeat
  35. } def
  36.  
  37. /clearStack {
  38.     cleartomark mark
  39. } def
  40.  
  41. %
  42. % commands for starting and finishing
  43. %
  44. /endchar { clearStack } def
  45.  
  46. /seac {
  47.     /achar exch def
  48.     /bchar exch def
  49.     /ady exch def
  50.     /adx exch def
  51.     /asb exch def
  52.  
  53.     mark Encoding bchar get load exec pop
  54.     /xOrigin xOrigin adx add def
  55.     /yOrigin yOrigin ady add def
  56.     mark Encoding achar get load exec pop clearStack
  57. } def
  58.  
  59. /hsbw {
  60.     pop /xOrigin exch xOrigin add def xOrigin yOrigin 2 printNums
  61.     (moveto ) myWriteString clearStack
  62. } def
  63.  
  64. /sbw {
  65.     pop pop /yOrigin exch yOrigin add def /xOrigin exch xOrigin add def
  66. xOrigin yOrigin 2 printNums
  67.     (moveto ) myWriteString clearStack
  68. } def
  69.  
  70. %
  71. % path construction commands
  72. %
  73. % convert the operators and operands to rmoveto, rlineto and rcurveto.
  74. % chars_closepath has different semantics from PostScript closepath.
  75. %
  76. /chars_closepath {
  77.     (currentpoint closepath moveto ) myWriteString clearStack
  78. } def
  79.  
  80. /hlineto { 0 2 printNums (rlineto ) myWriteString clearStack } def
  81. /hmoveto { 0 2 printNums (rmoveto ) myWriteString clearStack } def
  82. /chars_rlineto { 2 printNums (rlineto ) myWriteString clearStack } def
  83. /chars_rmoveto { 2 printNums (rmoveto ) myWriteString clearStack } def
  84. /vlineto { 0 exch 2 printNums (rlineto ) myWriteString clearStack } def
  85. /vmoveto { 0 exch 2 printNums (rmoveto ) myWriteString clearStack } def
  86.  
  87. /hvcurveto {
  88.     /dy3 exch def /dy2 exch def /dx2 exch def /dx1 exch def
  89.     dx1 0 dx2 dy2 0 dy3 rrcurveto
  90. } def
  91.  
  92. /vhcurveto {
  93.     /dx3 exch def /dy2 exch def /dx2 exch def /dy1 exch def
  94.     0 dy1 dx2 dy2 dx3 0 rrcurveto
  95. } def
  96.  
  97. /rrcurveto {
  98.     /dy3 exch def /dx3 exch def
  99.     /dy2 exch def /dx2 exch def
  100.     /dy1 exch def /dx1 exch def
  101.     dx1 dy1
  102.     dx1 dx2 add dy1 dy2 add
  103.     dx1 dx2 dx3 add add dy1 dy2 dy3 add add
  104.     6 printNums (rcurveto ) myWriteString clearStack
  105. } def
  106.  
  107. %
  108. % hint commands
  109. %
  110. /dotsection { clearStack } def
  111. /hstem { clearStack } def
  112. /hstem3 { clearStack } def
  113. /vstem { clearStack } def
  114. /vstem3 { clearStack } def
  115.  
  116. %
  117. % Arithmetic command
  118. %
  119. /chars_div { div } def
  120.  
  121. %
  122. % Subroutine commands
  123. % All OtherSubr routines are hint related
  124. % For 0, 1, 2 the stack contents are left unchanged.
  125. % For 3, the trailing pop will push a 3 on the stack.
  126. % See p. 95 of the Black Book.
  127. %
  128. /callothersubr {
  129. } def
  130.  
  131. /callsubr {
  132.     /i exch def
  133.     i 3 gt { % normal subroutines
  134.         Subrs i get exec
  135.     } if
  136.     i 3 eq { } if
  137.     i 0 eq {
  138. %        pop pop pop            % Flex height control parameter and end points
  139.         /yEnd exch def /xEnd exch def pop
  140.  
  141.         /y5 exch def /x5 exch def
  142.         /y4 exch def /x4 exch def
  143.         /y3 exch def /x3 exch def
  144.         /y2 exch def /x2 exch def
  145.         /y1 exch def /x1 exch def
  146.         /y0 exch def /x0 exch def
  147.         /yRef exch def /xRef exch def
  148.  
  149.         x0 xRef add y0 yRef add x1 y1 x2 y2 rrcurveto
  150.         x3 y3 x4 y4 x5 y5 rrcurveto
  151.  
  152. %
  153. % The Flex can be replaced by a lineto.
  154. %
  155. %        xEnd yEnd 2 printNums (lineto ) myWriteString
  156. %
  157.  
  158.         /chars_rmoveto { 2 printNums (rmoveto ) myWriteString clearStack } def
  159.     } if
  160.     i 1 eq {
  161.         /chars_rmoveto { } def
  162.     } if
  163.     i 2 eq {
  164.     } if
  165. } def
  166.  
  167. /return { } def
  168. /chars_pop { 3 } def    % chars_pop transfers from PS stack to BuildChar stack
  169.  
  170. %
  171. % setcurrentpoint shouldn't appear in a charststring program
  172. %
  173.  
  174.