home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / cmds / root.3 / usr / lib / lp / postscript / baseline.ps / baseline
Text File  |  1998-08-19  |  3KB  |  158 lines

  1. %ident    "@(#)baseline.ps    1.2"
  2. %
  3. % Stuff used to draw or set text along a baseline specified by parametric equations
  4. % for x and y.
  5. %
  6.  
  7. /left -1 def
  8. /center 0 def
  9. /right 1 def
  10.  
  11. /baselinedict 50 dict def
  12.  
  13. /newbaseline {
  14.     baselinedict begin
  15.         /g' exch bind def
  16.         /f' exch bind def
  17.         /g  exch bind def
  18.         /f  exch bind def
  19.  
  20.         counttomark 2 eq {/hoffset exch def} if
  21.         /res exch def
  22.  
  23.         /t 0 def
  24.         /s 0 def
  25.         /voffset false def
  26.         cleartomark
  27.     end
  28. } bind def
  29.  
  30. /drawfunnytext {
  31.     baselinedict begin
  32.         /t exch def
  33.         /mode exch def
  34.         /str exch def
  35.  
  36.         mode left eq {
  37.             /leftstring emptystring def
  38.             /rightstring str def
  39.         } if
  40.  
  41.         mode right eq {
  42.             /leftstring str reversestring def
  43.             /rightstring emptystring def
  44.         } if
  45.  
  46.         mode center eq {
  47.             str splitstring
  48.             /rightstring exch def
  49.             /leftstring exch reversestring def
  50.         } if
  51.  
  52.         gsave currentpoint translate leftstring left t baselineshow grestore
  53.         gsave currentpoint translate rightstring right t baselineshow grestore
  54.  
  55.         /t 0 def
  56.         /s 0 def
  57.         /voffset false def
  58.         cleartomark
  59.     end
  60. } bind def
  61.  
  62. /setfunnytext {
  63.     baselinedict begin
  64.         /vpos exch def
  65.         /hpos exch def
  66.         /str  exch def
  67.  
  68.         voffset vpos ne {
  69.             /voffset vpos def
  70.             /t 0 def
  71.             /s hoffset def
  72.         } if
  73.  
  74.         gsave
  75.             hoffset voffset translate
  76.             0 0 moveto
  77.             /ds hpos s sub def
  78.             /dt ds t f' dup mul t g' dup mul add sqrt res mul div def
  79.             /s s ds add def
  80.             /t t dt add def
  81.             str right t baselineshow
  82.         grestore
  83.     end
  84. } bind def
  85.  
  86. baselinedict begin
  87.  
  88. /f  {} bind def
  89. /g  {pop 0} bind def
  90. /f' {pop 1} bind def
  91. /g' {pop 0} bind def
  92.  
  93. /s 0 def
  94. /t 0 def
  95. /res 72 def
  96.  
  97. /onecharstring ( ) def
  98. /emptystring () def
  99.  
  100. /baselineshow {
  101.     /t exch def
  102.     /mode exch def
  103.     /str exch def
  104.  
  105.     gsave
  106.         t f res mul t g res mul translate
  107.         0 0 moveto
  108.         t g' t f' atan rotate
  109.         {
  110.             mode right eq {pop} if
  111.             grestore gsave
  112.             onecharstring 0 3 -1 roll put onecharstring stringwidth pop
  113.             /ds exch mode mul def
  114.             /dt ds t f' dup mul t g' dup mul add sqrt res mul div def
  115.             /t t dt add def
  116.             /s s ds add def
  117.             t f res mul t g res mul translate
  118.             0 0 moveto
  119.             t g' t f' atan rotate
  120.             mode left eq {pop} if
  121.         } str kshow
  122.     grestore
  123. } bind def
  124.  
  125. /reversestring {
  126.     /str1 exch def
  127.  
  128.     /str2 str1 length string def
  129.     /i 0 def
  130.     /n str1 length 1 sub def
  131.  
  132.     {
  133.         str1 n get str2 exch i exch put
  134.         /i i 1 add def
  135.         /n n 1 sub def
  136.         n 0 lt {exit} if
  137.     } loop
  138.     str2
  139. } bind def
  140.  
  141. /splitstring {
  142.     /str1 exch def
  143.  
  144.     /len str1 stringwidth pop def
  145.     /s 0 def
  146.     /n 0 def
  147.     str1 length {
  148.         str1 n get onecharstring exch 0 exch put
  149.         /s onecharstring stringwidth pop s add def
  150.         s len 2 div ge {exit} if
  151.         /n n 1 add def
  152.     } repeat
  153.     str1 0 n 1 add getinterval
  154.     str1 n str1 length n sub getinterval
  155. } bind def
  156.  
  157. end
  158.