Skip to main content
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
  • 21 views

a23Marcos

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

 

3 replies

Avokadomos
  • New Participant
  • 376 replies
  • January 25, 2025

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


a23Marcos
  • Author
  • New Member
  • 2 replies
  • 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
  • Author
  • New Member
  • 2 replies
  • 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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings