Skip to main content

fontName

The font family (e.g. "Inter"), font style (e.g. "Regular"). For variable fonts, also variationSettings. Setting this property to a different value requires the new font to be loaded.

Signature

fontName: FontName | figma.mixed

Remarks

When reading, variationSettings is populated only when the font is a variable font, and includes every axis the family defines (not just overrides). Returns figma.mixed when the text node has more than one font, or when variation settings differ across character ranges.

When writing, pass a FontName or FontNameInput. Omit style to let Figma pick the named instance closest to variationSettings. Supply variationSettings to override specific axes; keys must match the family's axis tags (see figma.getFontFamilyVariationAxes). An omitted axis keeps the named instance's default.

Set a variable font with custom weight
(async () => {
const text = figma.createText()
await figma.loadFontAsync({ family: 'Inter', style: 'Regular' })
text.fontName = {
family: 'Inter',
style: 'Regular',
variationSettings: { wght: 650 },
}
text.characters = 'Almost bold'
})()