How can I access the value of a variable font axis.
I’m writing a plugin and trying to extract the font from a TextNode
.
It’s possible in Figma to set the font axes to a custom value for variable fonts(e.g. the weight of the font).
When I do this in Figma the input for the font style changes from e.g. ‘Regular’ to ‘Weight: 357’. My approach to accessing this property was to read the fontName
value of the text segment and then read its style
property.
But, and that’s the problem I’m currently facing, instead of giving me that value of ‘Weight: 357’ I just get the style ‘Regular’. After further testing I noted that the font weight gets rounded to the nearest style that has a text value.
For example, 120 becomes ‘Thin’ and 170 becomes ‘Extra light’. This is a problem because I am unable to get the exact weight, only a rounded value.
Is there something I missed? Another way of accessing the weight to get the exact value?
PS: I tried the ‘Oswald’ and ‘Syne’ fonts, both give me the same problem.