getFontFamilyVariationAxes
Returns the OpenType variation axis tags a variable font family exposes, or null for a static family. These are the tags accepted by variationSettings.
Signature
getFontFamilyVariationAxes(family: string): string[] | null
Remarks
The family has to be available in the editor but does not have to be loaded, so this can be called before figma.loadFontAsync to decide what to load. Throws for an unknown family, so null always means the family is static.
Each tag is a 4-character OpenType axis tag such as "wght" (weight), "wdth" (width), "slnt" (slant), "opsz" (optical size), or a custom tag defined by the font designer.
Discovering variation axes, then applying one
(async () => {
const family = 'Inter'
const axes = figma.getFontFamilyVariationAxes(family)
if (axes === null) {
console.log(`${family} is a static font`)
return
}
await figma.loadFontAsync({ family })
const text = figma.createText()
if (axes.includes('wght')) {
text.fontName = { family, style: 'Regular', variationSettings: { wght: 550 } }
}
text.characters = 'Variable!'
})()