fontsrenderingvector-graphicstext-rendering

What basic primitives my render engine needs to support for drawing OTF fonts?


I am writing my own render engine for a very specific use case and I need to be able to draw a text. At first, I thought that it would be easier to create my own font file where I would by hand define each character using primitives that my engine supports, but after some time, I thought that maybe it is possible to use a standardized vector fonts format such as OTF.

Currently, I am able to render:

So before jumping into the coding, first I want to know what OTF is made from (What basic primitives I need to add to my project to render these fonts).


Solution

  • The OpenType spec uses vector formats to describe glyph outlines. There are two different vector formats supported:

    You need to implement scan conversion which determines the pixels that are "on" for a given size.

    You also need to process hints. For TrueType, this is like implementing a small Turing machine that interprets op codes and data from the font file and manages a stack to tune the outline before scan conversion.

    You may find the FreeType project useful in understanding what is needed. Or, you can save a lot of time and just use FreeType.