home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / untype.zoo / untype1 / header.ps < prev    next >
Encoding:
Text File  |  1990-11-22  |  3.3 KB  |  157 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. % The resulting paths are converted into very simple PostScript using
  16. % the pathforall operator.
  17. %
  18.  
  19. /readonly { } bind def
  20. /executeonly { } bind def
  21. /noaccess { } bind def
  22. /definefont { } bind def
  23.  
  24. /clearStack {
  25.     cleartomark mark
  26. } bind def
  27.  
  28. %
  29. % commands for starting and finishing
  30. %
  31. /endchar { clearStack } bind def
  32.  
  33. /seac {
  34.     /achar exch def
  35.     /bchar exch def
  36.     /ady exch def
  37.     /adx exch def
  38.     /asb exch def
  39.  
  40.     /xOrigin adx def /yOrigin ady def
  41.     mark Encoding achar get load exec pop clearStack
  42.     /xOrigin 0 def /yOrigin 0 def
  43.     mark Encoding bchar get load exec pop
  44. } bind def
  45.  
  46. /hsbw {
  47.     pop /xOrigin exch xOrigin add def
  48.     xOrigin yOrigin moveto clearStack
  49. } bind def
  50.  
  51. /sbw {
  52.     pop pop /yOrigin exch yOrigin add def
  53.     /xOrigin exch xOrigin add def
  54.     xOrigin yOrigin moveto clearStack
  55. } bind def
  56.  
  57. %
  58. % path construction commands
  59. %
  60. % convert the operators and operands to rmoveto, rlineto and rcurveto.
  61. % chars_closepath has different semantics from PostScript closepath.
  62. %
  63. /chars_closepath {
  64.     currentpoint closepath moveto clearStack
  65. } bind def
  66.  
  67. /hlineto { 0 rlineto clearStack } bind def
  68. /hmoveto { 0 rmoveto clearStack } bind def
  69. /chars_rlineto { rlineto clearStack } bind def
  70. /chars_rmoveto { rmoveto clearStack } bind def
  71. /vlineto { 0 exch rlineto clearStack } bind def
  72. /vmoveto { 0 exch rmoveto clearStack } bind def
  73.  
  74. /hvcurveto {
  75.     /dy3 exch def /dy2 exch def /dx2 exch def /dx1 exch def
  76.     dx1 0 dx2 dy2 0 dy3 rrcurveto
  77. } bind def
  78.  
  79. /vhcurveto {
  80.     /dx3 exch def /dy2 exch def /dx2 exch def /dy1 exch def
  81.     0 dy1 dx2 dy2 dx3 0 rrcurveto
  82. } bind def
  83.  
  84. /rrcurveto {
  85.     /dy3 exch def /dx3 exch def
  86.     /dy2 exch def /dx2 exch def
  87.     /dy1 exch def /dx1 exch def
  88.     dx1 dy1
  89.     dx1 dx2 add dy1 dy2 add
  90.     dx1 dx2 dx3 add add dy1 dy2 dy3 add add
  91.     rcurveto clearStack
  92. } bind def
  93.  
  94. %
  95. % hint commands
  96. %
  97. /dotsection { clearStack } bind def
  98. /hstem { clearStack } bind def
  99. /hstem3 { clearStack } bind def
  100. /vstem { clearStack } bind def
  101. /vstem3 { clearStack } bind def
  102.  
  103. %
  104. % Arithmetic command
  105. %
  106. /chars_div { div } bind def
  107.  
  108. %
  109. % Subroutine commands
  110. % All OtherSubr routines are hint related
  111. % For 0, 1, 2 the stack contents are left unchanged.
  112. % For 3, the trailing pop will push a 3 on the stack.
  113. % See p. 95 of the Black Book.
  114. %
  115. /callothersubr {
  116. } bind def
  117.  
  118. /callsubr {
  119.     /i exch def
  120.     i 0 eq {
  121. %        pop pop pop        % Flex height control parameter and end points
  122.         /yEnd exch def /xEnd exch def pop
  123.  
  124.         /y5 exch def /x5 exch def
  125.         /y4 exch def /x4 exch def
  126.         /y3 exch def /x3 exch def
  127.         /y2 exch def /x2 exch def
  128.         /y1 exch def /x1 exch def
  129.         /y0 exch def /x0 exch def
  130.         /yRef exch def /xRef exch def
  131.  
  132.         x0 xRef add y0 yRef add x1 y1 x2 y2 rrcurveto
  133.         x3 y3 x4 y4 x5 y5 rrcurveto
  134.  
  135. %
  136. % The Flex can be replaced by a lineto.
  137. %
  138.  
  139.         /chars_rmoveto { rmoveto clearStack } def
  140.     } if
  141.     i 1 eq {
  142.         /chars_rmoveto { } def
  143.     } if
  144.     i 2 eq { } if        % leave the arguments on the stack
  145.     i 3 eq { } if
  146.     i 3 gt {            % normal subroutines
  147.         Subrs i get exec
  148.     } if
  149. } bind def
  150.  
  151. /return { } bind def
  152. /chars_pop { 3 } bind def    % transfers from PS stack to BuildChar stack
  153.  
  154. %
  155. % setcurrentpoint shouldn't appear in a charstring program
  156. %
  157.