Search code examples
fontsfreetypetext-renderingkerning

Font File Parser with GPos Kerning Table Support for rendering Glyphs


I am looking for a way to extract glyph bitmaps, glyph metrics and kerning data from font files (.ttf, .otf) with a support for GPos Kerning Tables.

I have used the FreeType Library before, but it does not support GPos Tables.


Solution

  • I solved this by using HarfBuzz. This 'hello harfbuzz' sample shows how to initialize the library setting it up with a FreeType font. To extract kerning data, I created and shaped a buffer for each combination of letters I supported ('AA', 'AB', etc) and used the positioning data from hb_buffer_get_glyph_positions to infer the kerning offsets by comparing it to the advance values from FreeType.