Agamnentzar / ag-psd

Javascript library for reading and writing PSD files
Other
489 stars 66 forks source link

parse font size error #159

Open vollen opened 9 months ago

vollen commented 9 months ago

main.zip in my psd, the label is 22 pixel, but while readPsd, the font size is 1.528. show as image: image image

Agamnentzar commented 9 months ago

Font size displayed in Photoshop UI is multiplied by text transform to make all the fonts in the document sizes make sense together regardless if you scaled some text boxes up or down, it won't be the same as the size saved in the document. To get the same size you need to multiply it by the transform.

vollen commented 9 months ago

Thank you very much for your response. But I have tried many methods and still haven't figured out how to calculate the font size displayed in Photoshop. Could you please help by providing example code?

Agamnentzar commented 9 months ago
"fontSize": 1.528,
"transform": [
  14.375973048409659,
  0,
  0,
  14.397948318701692,
  377.5141057351093,
  484.64813612439474
],

you have font size of 1.528 and transform [14.375973048409659, 0, 0, 14.397948318701692, 377.5141057351093, 484.64813612439474] first number in the transform is scaleX and 4th one is scaleY, if you multiply your font size by 4th number in the transform you get 22.000065031 which after rounding is exacly what you have in the UI