home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WW3DKit / WW3DTextWraps.psw < prev    next >
Encoding:
Text File  |  1995-03-22  |  4.3 KB  |  209 lines

  1. /* WW3DTextWraps.psw
  2.  * Fashioned by Ian Wilkinson.
  3.  * Inception was Sun Jul 17 16:32:15 BST 1994.
  4.  *
  5.  * My History:
  6.  */
  7.  
  8. /*
  9.  * invalidaccess will result if pathforall is executed on an outline
  10.  * created by charpath for a protected font. (See ``pathforall,'' p.462.)
  11.  */
  12. defineps PSWWW3DTextIsFontProtected( char *theFont; float fontSize; char *theText |
  13.     boolean *isProtected )
  14.     gsave
  15.     0.2 setflat
  16.     /theFont fontSize selectfont
  17.     newpath
  18.     0 0 moveto
  19.     (theText) true charpath closepath
  20.     flattenpath
  21.     { pop pop } { pop pop } { 4 {pop} repeat } {}
  22.     { pathforall } stopped isProtected
  23.     grestore
  24. endps
  25.  
  26. defineps PSWWW3DTextMetrics( char *theFont; float fontSize; char theText[1] | 
  27.     int *nLoops; int *outlineLen )
  28.     6 dict begin
  29.     /nCntlPts 0 def
  30.     /theOutlineLen 0 def
  31.     /numLoops 0 def
  32.     
  33.     /moveProc { % x y => -
  34.         pop pop
  35.         /nCntlPts nCntlPts 1 add store
  36.     } bind def
  37.     /lineProc { % x y => -
  38.         moveProc
  39.     } bind def
  40.     /closeProc { % - => -
  41.         nCntlPts 3 ge {
  42.         /theOutlineLen theOutlineLen nCntlPts 1 add 2 mul add store
  43.         /numLoops numLoops 1 add store
  44.         } if
  45.         /nCntlPts 0 store
  46.     } bind def
  47.     
  48.     gsave
  49.         0.2 setflat
  50.         /theFont fontSize selectfont
  51.         newpath
  52.         0 0 moveto
  53.         (theText) true charpath closepath
  54.         flattenpath
  55.         { moveProc } { lineProc } { 4 {pop} repeat } { closeProc } pathforall
  56.         theOutlineLen numLoops
  57.         nLoops outlineLen
  58.     grestore
  59.     end
  60. endps
  61.  
  62. defineps PSWWW3DTextCounters( char *theFont; float fontSize; char *theText; int numCounters | 
  63.     int theCounters[numCounters] )
  64.     14 dict begin
  65.     /currLoop 0 def
  66.     /isInitial? true def
  67.     /needAdditional? true def
  68.     /nCntlPts 0 def
  69.     /x0 0 def
  70.     /y0 0 def
  71.     /x1 0 def
  72.     /y1 0 def
  73.     /x2 0 def
  74.     /y2 0 def
  75.     
  76.     /isccw? { % - => bool
  77.         x2 x0 sub y1 y0 sub mul
  78.         x1 x0 sub y2 y0 sub mul sub
  79.         0 lt
  80.     } def
  81.     /moveProc { % x y => -
  82.         isInitial? {
  83.         /y1 exch store
  84.         /x1 exch store
  85.         /isInitial? false store
  86.         }{
  87.         pop pop
  88.         } ifelse
  89.         /nCntlPts nCntlPts 1 add store
  90.     } bind def
  91.     /lineProc { % x y => -
  92.         needAdditional? {
  93.         /y2 exch store
  94.         /x2 exch store
  95.         /needAdditional? false store
  96.         }{
  97.         /y0 exch store 
  98.         /x0 exch store
  99.         } ifelse
  100.         /nCntlPts nCntlPts 1 add store
  101.     } bind def
  102.     /closeProc { % - => -
  103.         /isInitial? true store
  104.         /needAdditional? true store
  105.         nCntlPts 3 ge {
  106.         isccw? { currLoop } if
  107.         } if
  108.         /nCntlPts 0 store
  109.         /isCounter? false store
  110.         /currLoop currLoop 1 add store
  111.     } bind def
  112.     
  113.     gsave
  114.         0.2 setflat
  115.         /theFont fontSize selectfont
  116.         newpath
  117.         0 0 moveto
  118.         (theText) true charpath closepath
  119.         flattenpath
  120.         [
  121.         { moveProc } { lineProc } { 4 {pop} repeat } { closeProc } pathforall
  122.         ] {
  123.         theCounters
  124.         } forall
  125.     grestore
  126.     end
  127. endps
  128.  
  129. defineps PSWWW3DTextLoops( char *theFont; float fontSize; char *theText; int numLoops | 
  130.     int theLoops[numLoops] )
  131.     4 dict begin
  132.     /nCntlPts 0 def
  133.     
  134.     /moveProc { % x y => -
  135.         pop pop
  136.         /nCntlPts nCntlPts 1 add store
  137.     } bind def
  138.     /lineProc { % x y => -
  139.         moveProc
  140.     } bind def
  141.     /closeProc { % - => -
  142.         nCntlPts 3 ge {
  143.         nCntlPts 1 add 2 mul
  144.         } if
  145.         /nCntlPts 0 store
  146.     } bind def
  147.     
  148.     gsave
  149.         0.2 setflat
  150.         /theFont fontSize selectfont
  151.         newpath
  152.         0 0 moveto
  153.         (theText) true charpath closepath
  154.         flattenpath
  155.         [
  156.         { moveProc } { lineProc } { 4 {pop} repeat } { closeProc } pathforall
  157.         ] {
  158.         theLoops
  159.         } forall
  160.     grestore
  161.     end
  162. endps
  163.  
  164. defineps PSWWW3DTextOutline( char *theFont; float fontSize; char *theText; int outlineLen
  165.     | float charPathOutline[outlineLen] )
  166.     7 dict begin
  167.     /nCntlPts 0 def
  168.     /isInitial? true def
  169.     /initialX 0 def
  170.     /initialY 0 def
  171.     
  172.     /moveProc { % x y => x y
  173.         /nCntlPts nCntlPts 1 add store
  174.         isInitial? {
  175.         2 copy
  176.         /initialY exch store
  177.         /initialX exch store
  178.         /isInitial? false store
  179.         } if
  180.     } bind def
  181.     /lineProc { % x y => x y
  182.         moveProc 
  183.     } bind def
  184.     /closeProc { % - => initialX initialY
  185.         nCntlPts 3 ge {
  186.         initialX initialY
  187.         }{
  188.         nCntlPts 2 mul { pop } repeat
  189.         } ifelse
  190.         /nCntlPts 0 store
  191.         /isInitial? true store
  192.     } bind def
  193.     
  194.     gsave
  195.         0.2 setflat
  196.         /theFont fontSize selectfont
  197.         newpath
  198.         0 0 moveto
  199.         (theText) true charpath closepath
  200.         flattenpath
  201.         [
  202.         { moveProc } { lineProc } { 4 {pop} repeat } { closeProc } pathforall
  203.         ] {
  204.         charPathOutline
  205.         } forall
  206.     grestore
  207.     end
  208. endps
  209.