Skip to content

alias FontCharacterCommands


(alias) FontCharacterCommands = any[]
command arguments type description
font 1 number select a new font from the local `fonts table
char 1 number typeset this character number from the current font, and move right by the character's width
node 1 node output this node # (list), and move right by the width of this list
slot 2 2 numbers a shortcut for the combination of a font and char command
push 0 save current position
nop 0 do nothing
pop 0 pop position
rule 2 2 numbers output a rule ht*wd, and move right.
down 1 number move down on the page
right 1 number move right on the page
special 1 string output a special command
pdf 2 2 strings output a PDF literal, the first string is one of origin, page, text, font, direct or raw; if you have one string only origin is assumed
lua 1 string, function execute a Lua script when the glyph is embedded; in case of a function it gets the font id and character code passed
image 1 image output an image (the argument can be either an <image> variable or an image_spec table)
comment any any the arguments of this command are ignored

Example:

commands = {
    { "push" },                     -- remember where we are
    { "right", 5000 },              -- move right about 0.08pt
    { "font", 3 },                  -- select the fonts[3] entry
    { "char", 97 },                 -- place character 97 (ASCII 'a')
 -- { "slot", 2, 97 },              -- an alternative for the previous two
    { "pop" },                      -- go all the way back
    { "down", -200000 },            -- move upwards by about 3pt
    { "special", "pdf: 1 0 0 rg" }  -- switch to red color
 -- { "pdf", "origin", "1 0 0 rg" } -- switch to red color (alternative)
    { "rule", 500000, 20000 }       -- draw a bar
    { "special", "pdf: 0 g" }       -- back to black
 -- { "pdf", "origin", "0 g" }      -- back to black (alternative)
}

😱 Types incomplete or incorrect? 🙏 Please contribute!