E.2. Instructions

The language for TrueType instructions is an assembly language; that is, a language very close to the processor (in this case, the processor for TrueType fonts). In this language, concepts such as strings do not exist: everything is done with numbers.

E.2.1. Instructions for Managing the Stack and Storage Area

The following instructions allow for managing the interpreter's stack:

  • NPUSH[], PUSHB[], NPUSHW[] et PUSHW[] take several entries from the instruction stream and place them onto the interpreter's stack.

  • DUP[] copies the element on the top of the stack.

  • POP[] deletes it.

  • CLEAR[] deletes the entire stack.

  • SWAP[] exchanges the first two elements on the stack.

  • DEPTH[] returns the depth of the stack.

  • Both CINDEX[] and MINDEX[] retrieve a number n from the top of the stack and then copy (CINDEX[]) or move (MINDEX[]) the nth element on the stack to the top position.

  • Finally, ROLL[] performs a cyclic permutation of the top three elements on the stack.

We have access to a number of places in the "storage area" (their exact number is given in the font's maxp table—more specifically, in the maxStorage entry of that table). The instruction RS[] retrieves the position number from the stack and returns the value stored at that position. The instruction WS[] retrieves a value and a position number: it places the value at the stated position. The storage area is temporary, and it lasts only as long as the glyph is being processed.

We have another way to store data: the CVT. ...

Get Fonts & Encodings now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.