Annwan’s Wiki

mkfont documentation

A⟩ CLI Invocation

mkfont -i ⟨input file⟩ [-o ⟨output file⟩] [-f]

where:

B⟩ The mkfont language

mkfont uses a stack based language to build a font specification. there are a number of commands available in all scopes (maths, variables, macros) and some commands available only in specific scopes

B.I⟩ Literals

String literal any character except " enclosed in ". It is a known limitation in mkfont 0.2.0.0 that " cannot be escaped in string literals
Character literal # followed by any single individual character.
Integer literal A sequence of decimal digit ([0-9]) optionally preceded by -, or a sequence of hexadecimal digits ([0-9a-fA-F]) preceeded by 0x.
Symbol ' followed by a valid identifier name (raw(“[a-zA-Z._]+”))
Token list literal any number of valid tokens enclosed in a balanced pair of square brackets ([ ]).

B.II⟩ General commands

B.II.1⟩ Maths

+ b : int, a : int → a + b : int
- b : int, a : int → a - b : int
* b : int, a : int → a × b : int
/ b : int, a : int → floor(a / b) : int
~ b : int, a : int → floor((a + b) / 2) : int

B.II.2⟩ Variables

: n : symbol, a : any → (), stores the value of a in variable n
@ n : symbol → a: any, fetches the value of variable n, errors out if n is undefined.
! m: symbol | tokenlist → (), if m is a symbol it is dereferenced ('sym ! is syntax sugar for 'sym @ !). If after desugaring, the value isn’t a tokenlist, the interpreter errors out. otherwise, the tokenlist is prepended to the list of tokens to evaluate

B.II.3⟩ Stack manipulation

swp b: any, a: any → a: any, b: any
dup a: any → a: any, a: any
kil a: any → ()

C⟩ The structure of a font specification