Advertisement
nicolas42

font dialect

Oct 26th, 2012
2,633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
REBOL 1.04 KB | None | 0 0
  1. use [f] [
  2.  
  3.     font: func [
  4.         {Font dialect. Makes font object.
  5.        
  6.         Examples
  7.         eg: font ["lucinda" 36 silver top left 5x5 10x10 1x1]
  8.         arial12: font ["arial" 12]
  9.         fixedsys: font ["fixedsys" bold]
  10.         lucinda12: font ["lucinda" 12 silver top left]
  11.        
  12.         view layout compose/deep [area font (eg: font ["lucinda" 36 silver top left 5x5 10x10 1x1])]
  13.        
  14.         possible changes
  15.         make font default to top left alignment
  16.         }
  17.         a
  18.         /local oss
  19.     ] [
  20.         f: make face/font []
  21.         do bind/copy [
  22.  
  23.             oss: copy [] ;pairs become the offset space and shadow, see [1] and [2]
  24.             foreach a a  [
  25.                 switch type?/word a [
  26.                     string!         [name: a]
  27.                     integer!        [size: a]
  28.                     block!          [style: a]
  29.                     tuple!          [color: a]
  30.                     word!           [
  31.                         switch a [
  32.                             left right center       [align: a]
  33.                             top bottom middle       [valign: a]
  34.                             bold italic underline   [style: a]
  35.                         ]
  36.                         if all [value? a tuple? get a] [color: get a]
  37.                     ]
  38.                     pair!           [append oss a] ;[1]
  39.                 ]
  40.             ]
  41.             set [offset space shadow] oss ;[2]
  42.         ] f
  43.        
  44.         return f   
  45.     ]
  46.  
  47. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement