> For the complete documentation index, see [llms.txt](https://sparkar-community.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sparkar-community.gitbook.io/docs/fontsmodule.md).

# FontsModule

The `FontsModule` class is used for working with custom fonts in effects.

## Example

```
//==============================================================================
// The following example demonstrates how to access a font in the Assets and
// assign it to a text object.
//
// Project setup:
// - Insert text
// - Add the Custom Fonts capability
//==============================================================================

// Load in the required modules
const Fonts = require('Fonts');
const Scene = require('Scene');

// Locate the font in the Assets and the text in the Scene
const font = Fonts.get('customFont.ttf');
const text = Scene.root.find('text0');

// Set the font of the text
text.font = font;
```

## Properties

This module exposes no properties.

## Methods

| Method             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `findFirst`        | <p><code>findFirst(name: string): Promise\<FontId></code></p><p>Returns a promise that is resolved with the font identifier of a requested name or null if none was found. <strong>See Also</strong>: <code>FontsModule.findUsingPattern</code>, <code>FontsModule.getAll</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `findUsingPattern` | <p><code>findUsingPattern(namePattern: string): Promise\<Array\<FontId>> findUsingPattern(namePattern: string, config: {limit: number}): Promise\<Array\<FontId>></code></p><p>Returns a promise that is resolved with the all of the font identifiers matching the name pattern or empty array if none was found.</p><p>Pattern format: <code>*</code> matches any characters sequence. <code>\</code> can be used to include in pattern any of the control characters (including '' itself)</p><p>Examples: <code>findUsingPattern("*")</code> will retrive all of the font identifiers. <code>findUsingPattern("*A")</code> will retrieve all of the font identifiers suffixed with 'A'. <code>findUsingPattern("A*")</code> will retrieve all of the font identifiers prefixed with 'A'. <code>findUsingPattern("*A*", {limit: 10})</code> will retrieve at most 10 of the font identifiers containing 'A',</p><p><code>limit</code> parameter describes if <code>findUsingPattern</code> should finish the search if it finds specified number of results (default is no limit). Non-positive values for limit are treated as unlimited.</p><p><strong>See Also</strong>: <code>FontsModule.getAll</code>, <code>FontsModule.findFirst</code>.</p> |
| `get`              | <p><code>get(fontName: string): FontId</code></p><p>Returns a font object identified by the <code>fontName</code> argument.</p><p>Throws an exception if there is no such font in the project.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `getAll`           | <p><code>getAll(): Promise\<Array\<FontId>></code></p><p>Returns a promise that is resolved with all of the font identifiers. <strong>See Also</strong>: <code>FontsModule.findUsingPattern</code>, <code>FontsModule.findFirst</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Classes

| Class                                                                                        | Description                                         |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [`FontId`](https://sparkar.facebook.com/docs/ar-studio/reference/classes/fontsmodule.fontid) | The `FontsId` class identifies a font in an effect. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://sparkar-community.gitbook.io/docs/fontsmodule.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
