Exploring our font library

We will install 12 fonts from Computer Modern: Serif, Sans Serif and Typewriter which all have four variants: Roman (or Regular), Italic (or Oblique), Bold, Bold Italic (or Bold Oblique).

We add them all as Type 3 fonts embedded in a JS-file. The font files are quite heavy. I suspect the outlines of our fonts are more complex than they should be. We add them as external Javascript files, but reading 12 font files takes some time.

Javascript Editor

Now you see the heap and the dictionary fill up. We rewrite our postScriptEditor to make the console more compact.

Javascript

Javascript Editor

What are the available letters? There are 255 code points. We make a script to create a special string with all code points. We can do this with the put operator and implementing the string operator that creates a zero byte string of a given length.

Javascript

That looks like Latin1, not Unicode

Javascript Editor

So to properly show the strings, we need to convert them to Latin1.

Javascript Editor

I like using "Genève" and "Zürich" to check encoding.

Javascript Editor

Can we write our own font. Yes we can. We use the paths of the characters TAO in the earlier chapters to build a font. We use only the minimal parameters.

Javascript Editor

Note that this code will probably not work in another PostScript interpreter. We did not really check if all parameters of the font are defined.

The codebase is 1880 lines ps20240805.js
The references to the font files are
CMUSerif-Roman.js
CMUSerif-Bold.js
CMUSerif-Italic.js
CMUSansSerif.js
CMUSansSerif-Oblique.js
CMUSansSerif-Bold.js
CMUSansSerif-BoldOblique.js
CMUTypewriter-Regular.js
CMUTypewriter-Italic.js
CMUTypewriter-Bold.js
CMUTypewriter-BoldItalic.js

My Journey to PostScript