Skip to content

Font Registration

Welcome to the Font Registration Guide for aoi.canvas!

In this guide, we will walk you through the process of registering custom fonts in aoi.canvas.

In index.js Way

To register your fonts in index.js, follow these steps:

1. Setup aoi.canvas

If you already setup aoi.canvas in your project, you can skip this step. If not, check out our guide on how to set it up.

2. Use the registerFonts() function.

Once youve set up aoi.canvas in your project, use the registerFonts() function to register your custom fonts.

1
const canvas = new AoiCanvas(client); // Your aoi.canvas setup.
2
canvas.registerFonts([
3
// ...
4
]);

Registering a font

To register a single font, specify the path to the font file and, optionally, provide a name for reference.

1
const canvas = new AoiCanvas(client); // Your aoi.canvas setup.
2
canvas.registerFonts([
3
{
4
src: "./examplefont.ttf", // Your font file path.
5
name: "ExampleFont"
6
},
7
// ...
8
]);

Registering multiple fonts

You can register multiple fonts by adding a font object to the fonts array or use multiple registerFonts() functions.

1
const canvas = new AoiCanvas(client); // Your aoi.canvas setup.
2
3
// Multiple fonts in one function
4
canvas.registerFonts([
5
{
6
src: "./examplefont1.ttf",
7
name: "ExampleFont1"
8
},
9
{
10
src: "./examplefont2.ttf",
11
name: "ExampleFont2"
12
},
13
// ...
14
]);
15
16
// You can also use as much registerFonts() as you want:
17
canvas.registerFonts([
18
{
19
src: "./examplefont2.ttf",
20
name: "ExampleFont2"
21
},
22
{
23
src: "./examplefont3.ttf",
24
name: "ExampleFont3"
25
},
26
// ...
27
]);

Registering Fonts in a directory

If you don’t want to register every font manually, you can put them into a folder and register them all at once.

1
const canvas = new AoiCanvas(client); // Your aoi.canvas setup.
2
canvas.registerFonts([
3
{
4
src: "./fonts"
5
},
6
// ...
7
]);

In a command way

To register fonts in a command, please head to $registerFont.