Skip to content

Extract kerning and shaping tables from fonts? #85

Closed

Description

@mikemorris

tl;dr Can we use ICU or HarfBuzz to extract shaping and kerning tables from a font?

From discussion with @nickidlugash on adding kerning support:

FreeType only supports kerning via the (rather simple) ‘kern’ table. For the interpretation of kerning data in the (highly sophisticated) ‘GPOS’ table you need a higher-level library like ICU or HarfBuzz since it can be context dependent (this is, the kerning may vary depending on the position within a text string, for example).
http://freetype.org/freetype2/docs/glyphs/glyphs-4.html

  • FreeType has limited support for reading kerning tables and running FT_Get_Kerning for all possible glyph pairs seems like a terrible idea.
  • We'll need to integrate HarfBuzz (and a JavaScript equivalent?) into our rendering engines at some point for complex text shaping, could we handle kerning at this point too?
  • Is it possible to use ICU or HarfBuzz to extract shaping and kerning tables from a font at upload time to be stashed on S3 and used later for rendering, rather than having to load the full font file into HarfBuzz/ICU?

Activity

  1. springmeyer commented on Mar 24, 2015

    @springmeyer
    Contributor

    Good questions, I'll add this tidbit:

    FreeType can now use the HarfBuzz library to greatly improve the
          auto-hinting of  fonts that  use OpenType features:  Many glyphs
          that are part  of such features but don't have  cmap entries are
          now handled  properly, for  example small caps  or superscripts.
          Define the configuration  macro FT_CONFIG_OPTION_USE_HARFBUZZ to
          activate HarfBuzz support
    

    http://sourceforge.net/projects/freetype/files/freetype2/2.5.3/

  2. mattdesl commented on May 6, 2015

    @mattdesl
    Contributor

    Opentype.js has also been working on basic GPOS parsing:
    opentypejs/opentype.js#19

  3. mikemorris commented on May 6, 2015

    @mikemorris
    ContributorAuthor

    Current thinking is to implement something like Harfbuzz's reference_table method to extract and dump the binary SFNT table data while node-fontnik has the font open in FreeType, and write a custom backend for HarfBuzz to read this data by itself rather than needing to open up a font file at shaping time. @lbud is digging into how this will work.

    I started working on porting pomax/A-binary-parser-generator to Node.js with Browserify today to try extracting and parsing the shaping tables in JavaScript, but I think that approach will end up being slower, more difficult and result in less useful data (JavaScript objects instead of binary data HarfBuzz expects) than just doing this through FreeType.

  4. felipesanches commented on Jun 30, 2015

    @felipesanches

    I just posted a few comments here while I actually intended to post them to issue #95. I have just deleted them from here and posted them to the correct issue. Sorry.

  5. jcary741 commented on Oct 13, 2026

    @jcary741

    Closing as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions