FreeType Glyph Conventions

Version 2.1

Copyright 1998-2000 David Turner (david@freetype.org)
Copyright 2000 The FreeType Development Team (devel@freetype.org)

Previous Contents Next


V. Text processing

This section demonstrates how to use the concepts previously defined to render text, whatever the layout you use.

1. Writing simple text strings

In this first example, we will generate a simple string of Roman text, i.e. with a horizontal left-to-right layout. Using exclusively pixel metrics, the process looks like:

  1. Convert the character string into a series of glyph indices.
  2. Place the pen to the cursor position.
  3. Get or load the glyph image.
  4. Translate the glyph so that its 'origin' matches the pen position.
  5. Render the glyph to the target device.
  6. Increment the pen position by the glyph's advance width in pixels.
  7. Start over at step 3 for each of the remaining glyphs.
  8. When all glyphs are done, set the text cursor to the new pen position.

Note that kerning isn't part of this algorithm.

2. Sub-pixel positioning

It is somewhat useful to use sub-pixel positioning when rendering text. This is crucial, for example, to provide semi-WYSIWYG text layouts. Text rendering is very similar to the algorithm described in subsection 1, with the following few differences: