On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

findFonts

API reference for the findFonts method.
This version of the API is deprecated. This version will soon be unsupported. You should use a stable version of the API in your app.

Returns a list of recommended fonts. The recommendations are based on a number of factors, such as the user's locale. To learn more, see Creating text.

Usage

Basic usage

import { findFonts } from "@canva/asset";
const { fonts } = await findFonts();
console.log(fonts); // => [ { name: "Arial", ... }]
TS

Filtering

import { findFonts } from "@canva/asset";
const { fonts } = await findFonts({ fontRefs: ["FONT_REF_GOES_HERE"] });
console.log(fonts); // => [ { name: "Arial", ... }]
TS

Parameters

optionsobject
OPTIONAL

Options for filtering the returned fonts.

options.fontRefsarray
OPTIONAL

An array of font references. If defined, only the fonts with the specified references will be returned.

Returns

A Promise that resolves with the following object:

responseobject
REQUIRED

The result of requesting a list of available fonts.

response.fontsarray
REQUIRED

An array of fonts.

response.fonts[0]object
REQUIRED

An individual font.

response.fonts[0].refstring
REQUIRED

A unique identifier that references a font in Canva's backend.

You should not rely on the ref remaining the same. For example, if you store it in a database and try to use it a few weeks later, an error may be thrown due to the ref being outdated.

response.fonts[0].namestring
REQUIRED

The name of the font.

response.fonts[0].weightsarray
REQUIRED

An array of font weights that the font is available in.

response.fonts[0].weights[0]object
REQUIRED

An individual font weight.

response.fonts[0].weights[0].weightobject
REQUIRED

The name of the font weight.

The possible values depend on the font, but may be any combination of the following values:

  • "normal"
  • "thin"
  • "extralight"
  • "light"
  • "medium"
  • "semibold"
  • "bold"
  • "ultrabold"
  • "heavy"
response.fonts[0].weights[0].stylesarray
REQUIRED

The styles the font weight is available in.

The possible values depend on the font, but may be any combination of the following values:

  • "normal"
  • "italic"
response.fonts[0].previewUrlstring
OPTIONAL

The URL of an image that contains a preview of the font.