Font API
The kittl.font API allows you to upload custom fonts to Kittl. Once uploaded, fonts become available for use in text elements within the design.
Creating a Font
Use createFont to upload one or more font files as a font family. Each file corresponds to a style (e.g. "Regular", "Bold", "Italic").
const fontResult = await kittl.font.createFont({
name: 'My Custom Font',
files: [regularBlob, boldBlob],
styles: ['Regular', 'Bold'],
});
if (fontResult.isOk) {
const fontFamily = fontResult.result;
console.log('Font created:', fontFamily.name);
console.log('Fonts:', fontFamily.fonts); // Array of uploaded font styles
}
See Font API Reference for full parameter and return type details.
Using an Uploaded Font
After creating a font, you can reference it in text elements:
const fontResult = await kittl.font.createFont({
name: 'My Custom Font',
files: [fontBlob],
styles: ['Regular'],
});
if (fontResult.isOk) {
// Use the font in a new text element
await kittl.design.text.addText({
text: 'Hello with custom font!',
position: { absolute: { left: 100, top: 100 } },
size: { width: 400, height: 100 },
textProperties: {
fontFamily: fontResult.result.name,
fontSize: 48,
},
});
}
Scope Required
This API requires the fonts:create scope in your extension manifest.