Skip to main content
a23Marcos
New Member
January 24, 2025
Question

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

  • January 24, 2025
  • 3 replies
  • 150 views

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
Active Member
January 25, 2025

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

a23Marcos
a23MarcosAuthor
New Member
January 27, 2025

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
January 27, 2025

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.