100 100 moveto (Hello World) show

In the last chapter, we have learnt to run PostScript code to define fonts. In this chapter, we will use the fonts.

findfont retrieves a font we have earlier defined width definefont and puts it on a stack. scalefont sets the size and setfont makes it the current font.

The operator show creates the path for the string and fills it. It first creates a backup of the current transformation matrix. Then it multiplies the FontMatrix with the size and with the transformation matrix. Now we are in user space for the font which is 2048 times enlarged. We make the font the current dict and loop through the characters: We put the font to the stack, the character code to the stack and invoke the BuildChar operator.

The BuildChar operator is provided by the font. It looks up the glyph, creates the path and fills it. It gives a feedback on geometry with the setcachedevice. This is an array with offset x and y and also the bottom left and top right coordinates. We use it to move the transformation matrix.

We also need to implement some operators that the font uses: get for dictionary, known, copy and exec.

Javascript Editor