Hey everyone! So I have this code,
(async function()
{
const fontName =
{
family: genText.font,
style: 'Regular'
};
await figma.loadFontAsync(fontName);
figText.fontName = fontName;
figText.fontSize = Math.max(1, genText.size);
figText.characters = genText.text;
if ( genText.width == 0
&& genText.height == 0) figText.textAutoResize = 'WIDTH_AND_HEIGHT';
else if (genText.height == 0) figText.textAutoResize = 'HEIGHT';
else figText.textAutoResize = 'NONE';
setObjectTransform(figText, genText);
setObjectProps (figText, genText);
})();
setObjectTransform()
further does a resizeWithoutConstraints()
.
So I was trying to be clever and have width==0 && height==0 in my generated objects mean auto-size in the final Figma text object, but it’s not working. Setting .textAutoResize
doesn’t work whether I do the resizeWithoutConstraints()
or not.
Lol chatgpt suggested listening to the auto resize property change in the document, and sure, that’s doable, but compared to the way the rest of this API works that seems like incredible overkill.
What am I doing wrong?