GlyphRun Object

This documentation for fontkit is created and provided by the Typogram team. It’s a third-party documentation intended to delve deeper into the fontkit API. For the most accurate information, refer to fontkit’s official documentation.

The GlyphRun object in Fontkit represents a sequence of glyphs and their associated positions. When you layout a string using the font.layout() method, it returns a GlyphRun object.



  • Description: An array of Glyph objects representing the individual glyphs in the run.

  • Type: Array of Glyph objects


  • Description: An array of position objects, where each position corresponds to the Glyph at the same index in the glyphs array. Each position object typically contains x and y offsets and an advance width and height.

  • Type: Array of Position Objects. Each position object has properties:

    • xAdvance: The amount to move the pen in the x-direction after drawing the glyph.

    • yAdvance: The amount to move the pen in the y-direction after drawing the glyph.

    • xOffset: The x offset to apply when drawing this glyph.

    • yOffset: The y offset to apply when drawing this glyph.


  • Description: An array of OpenType feature tags applied to this run, which can affect the final set of glyphs and their positions.

  • Type: Array of Strings


  • Description: The script (or writing system) used for this run of text, as determined by the shaping engine.

  • Type: String


  • Description: The language tag for this run of text, which can affect shaping in some scripts.

  • Type: String


  • Description: The text direction for this run. Common values include 'ltr' (left-to-right) and 'rtl' (right-to-left).

  • Type: String


  • Description: The total advance width of the glyph run. This is the sum of the horizontal advances of all the glyphs in the run, and it represents the width that the glyph run would occupy if rendered.

  • Type: Number


  • Description: The total advance height of the glyph run. This is particularly relevant for vertical text layouts.

  • Type: Number


  • Description: The bounding box of the glyph run. It encompasses all the glyphs in the run and provides minX, minY, maxX, and maxY properties.

  • Type: Object


The main interaction with a GlyphRun object revolves around accessing its properties rather than calling methods. Most of the manipulation or querying one would do with the GlyphRun results involves working directly with the properties listed above. For instance, iterating over the glyphs or positions to perform certain tasks or calculations.

Last updated