font syntax for gadgets

db4
Sam Anklesaria 2009-07-31 11:41:50 -05:00
parent 92cc62de85
commit 6de5f0964b
4 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1 @@
Sam Anklesaria

View File

@ -0,0 +1 @@
Syntax for modifying gadget fonts

View File

@ -0,0 +1,6 @@
USING: help.syntax help.markup ;
IN: fonts.syntax
HELP: FONT:
{ $syntax "\"testing\" <label> FONT: 18 serif bold ... ;" }
{ $description "Used after a gadget to change font settings. Attributes can be in any order: the first number is set as the size, the style attributes like bold and italic will set the bold? and italic? slots, and font-names like serif or monospace will set the name slot." } ;

View File

@ -0,0 +1,16 @@
USING: accessors arrays classes.algebraic combinators io.styles
kernel math parser sequences fry ;
IN: fonts.syntax
DATA: fontname serif | monospace ;
: install ( object quot -- quot/? ) over [ curry ] [ 2drop [ ] ] if ;
: >>name* ( object fontname -- object ) name>> >>name ;
SYNTAX: FONT: \ ; parse-until {
[ [ number? ] find nip [ >>size ] install ]
[ [ italic = ] find nip [ >>italic? ] install ]
[ [ bold = ] find nip [ >>bold? ] install ]
[ [ fontname? ] find nip [ >>name* ] install ]
} cleave 4array concat '[ dup font>> @ drop ] over push-all ;