🔤
Fontkit
GithubTypogram
  • Welcome
  • Quick Start
  • Reference
    • API Reference Index
    • Fontkit Object
    • Font Object
    • GlyphRun Object
    • Glyph Object
    • Path Object
    • Subset Object
Powered by GitBook
On this page
  • Fontkit Object
  • Font Object
  • GlyphRun Object
  • Glyph Object
  • Path Object
  • Subset Object

Was this helpful?

Edit on GitHub
  1. Reference

API Reference Index

PreviousQuick StartNextFontkit Object

Last updated 1 year ago

Was this helpful?

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

Fontkit Object

  • fontkit.openSync(filePath, postscriptName) Opens a font file synchronously and returns a font object.

  • fontkit.open(filePath, postscriptName, callback) Opens a font file asynchronously.

  • fontkit.create(buffer, postscriptName) Creates a new font object from a buffer.

Font Object

  • font.layout(string) Layouts the given string with the font and returns a GlyphRun object.

  • font.glyphForCodePoint(codePoint) Gets a glyph for a given Unicode code point.

  • font.hasGlyphForCodePoint(codePoint) Checks if the font has a glyph for the given code point.

  • font.characterSet Returns the set of Unicode code points supported by the font.

  • font.availableFeatures Returns the list of OpenType feature tags available in the font.

GlyphRun Object

  • glyphRun.glyphs An array of Glyph objects in the run.

  • glyphRun.positions An array of position objects for each glyph.

Glyph Object

  • glyph.path Returns a Path object representing the glyph’s outline.

  • glyph.bbox Gets the glyph’s bounding box, i.e., the rectangle that encloses the glyph’s outline.

  • glyph.cbox Gets the glyph’s control bounding box.

  • glyph.advanceWidth The advance width of the glyph.

Path Object

  • path.moveTo(x, y) Moves the pen to a new location.

  • path.lineTo(x, y) Draws a straight line to a new location.

  • path.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) Draws a cubic bezier curve.

  • path.quadraticCurveTo(cpx, cpy, x, y) Draws a quadratic bezier curve.

  • path.closePath() Closes the current path.

  • path.bbox Returns the bounding box of the path.

Subset Object

  • subset.includeGlyph(glyph) Includes the given glyph in the subset.

  • subset.encode() Encodes the subset font.

fontkit
Typogram
fontkit’s official documentation
Fontkit Object
Font Object
GlyphRun Object
Glyph Object
Path Object
Subset Object