# API Reference Index

{% hint style="info" %}
This documentation for [fontkit](https://github.com/foliojs/fontkit) is created and provided by the [Typogram](https://typogram.co/) 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](https://github.com/foliojs/fontkit#readme).
{% endhint %}

## **Fontkit Object**

{% content-ref url="/pages/vttesg905hu1e2ApYKJG" %}
[Fontkit Object](/reference/fontkit-object.md)
{% endcontent-ref %}

* `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**

{% content-ref url="/pages/Z4tdcUzZTzUPsG5YQFpg" %}
[Font Object](/reference/font-object.md)
{% endcontent-ref %}

* `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**

{% content-ref url="/pages/rvCYR99tjI9JaTfra4Eu" %}
[GlyphRun Object](/reference/glyphrun-object.md)
{% endcontent-ref %}

* `glyphRun.glyphs` An array of Glyph objects in the run.
* `glyphRun.positions` An array of position objects for each glyph.

## **Glyph Object**

{% content-ref url="/pages/5Y8se3j3lAm5aqjvrz8e" %}
[Glyph Object](/reference/glyph-object.md)
{% endcontent-ref %}

* `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**

{% content-ref url="/pages/QwnyEBegGFZsR4nqLHJe" %}
[Path Object](/reference/path-object.md)
{% endcontent-ref %}

* `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

{% content-ref url="/pages/z1zI5WG3INcAh2VWfo2S" %}
[Subset Object](/reference/subset-object.md)
{% endcontent-ref %}

* `subset.includeGlyph(glyph)` Includes the given glyph in the subset.
* `subset.encode()` Encodes the subset font.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fontkit.typogram.co/reference/api-reference-index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
