Skip to main content
qurle
New Participant
April 24, 2024
Solved

Set bound variable for Typography

  • April 24, 2024
  • 12 replies
  • 678 views

Hi 👋 Using variables for setting fonts are cool and helps our design system a lot.
But is there any way to set bound variables for text properties via Plugin API?

It’s complex read-only property and simple setBoundVariable() does not work. We don’t have known methods like setBoundVariableForFont().

Can we wait for Plugin API to support typography variables any time soon?

List of properties I can’t manage to set:
fontFamily, letterSpacing, fontSize, paragraphSpacing, paragraphIndent, fontWeight, lineHeight and unexpectedly stroke for sections 😀

This topic has been closed for replies.
Best answer by James_Yang

We have a guide for typography variables in the plugin API here: Working with Variables | Plugin API

12 replies

James_Yang
Figmate
Figmate
November 27, 2024

textRangeFills in boundVariables covers variables in paints applied to substrings of text.

To programmatically use a color variable for a range of text, you can use textNode.setRangeFills() with a paint that references a variable.

figma.com
Michal_Kovacik1
New Participant
January 22, 2025

@James_Yang ok, let’s say there is a variable 1 bound to paint applied to a substring in a text node, but there is also a fill style applied to a substring of the same node, which contains paint that is bound to variable 2. To use textRangeFills to exchange a variable for another one properly in this case, I need to get the fills text segments to know exactly to which characters is the variable bound. How would I know which variable is bound through the style and which one directly, since there is no information about it in obtained text segments, nor in boundVariables property?