Skip to main content

setRangeFontName

Set the fontName from characters in range start (inclusive) to end (exclusive). Requires the new font to be loaded.

Signature

setRangeFontName(start: number, end: number, value: FontNameInput): void

Remarks

Accepts a FontNameInput. Pass variationSettings to override specific axes of a variable font. Omit style to let Figma pick the named instance closest to variationSettings.

Override weight on a character range
(async () => {
const text = figma.createText()
await figma.loadFontAsync({ family: 'Inter' })
text.characters = 'Hello world'
text.setRangeFontName(0, 5, {
family: 'Inter',
style: 'Regular',
variationSettings: { wght: 700 },
})
})()