Bug of figma rest api(incorrect font size)

Description
I created a component in one file (named syc_tab_item), then used it as an instance in another and scaled it. ‘fontSize’ in ‘testinstance’ file is 35.39, but when using figma rest api, it still returns 14.0.
(I tried creating another component with similar structure,but that case didn’t happen as i expected. It seems only happens on ‘syc_tab_item’)
it would be appreciated if someone could tell me how it happend.

rest api response(partly):
“style”: {
“fontFamily”: “PingFang SC”,
“fontPostScriptName”: “PingFangSC-Semibold”,
“fontWeight”: 600,
“textAutoResize”: “WIDTH_AND_HEIGHT”,
“fontSize”: 14.0,
“textAlignHorizontal”: “LEFT”,
“textAlignVertical”: “CENTER”,
“letterSpacing”: 0.0,
“lineHeightPx”: 20.0,
“lineHeightPercent”: 121.90476989746094,
“lineHeightPercentFontSize”: 142.85714721679688,
“lineHeightUnit”: “PIXELS”
}

Steps

  1. click ‘Assets’ in the left-top corner of the screen
  2. drop ‘syc_tab_item’ component into the center of the screen
  3. click ‘Move’ in the left-top corner of the screen and switch to ‘Scale’
  4. resize item created in step 2 (make sure fontSize value changed)
  5. request rest api: GET, the fontSize is still the same with original component node’s fontSize.

You probably scaled the instance with the Scale tool, which doesn’t actually change the scale of objects inside, but it changes the scale property of the instance (and everything inside follows it. So you need to take the scale of the instance into consideration to calculate the actual font size.

This is happening to me also. But not to every scaled instance, but maybe to the one with AutoLayout?

Did you find any sollution? Am not seing any info about the scale in the figma api data. Thx

I don’t believe the scale of an instance is returned in any responses from the API right now. You can potentially infer the scale of an instance by comparing its dimensions against the component it refers to.

const scaleX = instance.size.x / component.size.x
const scaleY = instance.size.y / component.size.y
1 Like