Skip to main content
a23Marcos
New Member
Jan 24, 2025 7:09 PM UTC
Question

Text exported as PNG does not have the same width and height that text that in the figma file

Hello, I spent some time trying to find a response in existing question but wasn’t able to.

 

Here’s my problem: I have a text object that would show 593x89 (width and height) in the properties panel.

 

 

But, when I export the element to PNG, the file I get is smaller (cropped) 587x61 px

 

The exported file is used to create HTML code to replicate the figma file, so when we set the asset to the same position that in the figma file (e.g. top: 219px, leftL 56px), it’ll look off position, because of the missing “padding”. Here is the exported “cropped” asset on top of the original image:

 

 

Is there a way to export the asset with a size matching the figma object, or to find out the “cropped” top and left pixels so it can be added to the top and left position?

 

Thanks a lot in advance

 

This topic has been closed for replies.

3 replies

Avokadomos
Figma Ambassador
Figma Ambassador
Jan 25, 2025 10:31 AM UTC

Wrap the text element in a frame and then export the frame instead.

Disclosure: I’m part of Figma’s Forum Ambassador program.
a23Marcos
a23MarcosAuthor
New Member
Jan 27, 2025 12:40 PM UTC

Thanks for the reply Avokadomos, makes sense, however, I would like to solve this issue without modifying the figma file as in many cases the tool we are building needs to be used in figma files we do not own

a23Marcos
a23MarcosAuthor
New Member
Jan 27, 2025 2:25 PM UTC

Ok it was simpler that what I thought; the boundingRect property of the layer can be compared with the asset size to determine the appropriate offset.