psd icon indicating copy to clipboard operation
psd copied to clipboard

text layer's textProperties no parsed corretly

Open overQ-N opened this issue 2 years ago • 9 comments

I try to get font style.but it parse result always same(in fact not).

The StyleSheetData like FontSize, FillColor,StrokeColor and other property are same,it seems like no parse yet?

image

overQ-N avatar Oct 26 '22 10:10 overQ-N

Hello! Could you provide sample PSD file(s) so we can debug this?

pastelmind avatar Oct 26 '22 11:10 pastelmind

Hello! Could you provide sample PSD file(s) so we can debug this?

Thank you for you reply. Just use this repository example-node/example.psd can debug this.

the text layer font size not 12px. and other property like font color property is wrong too. i am not sure if i get text properties method is wrong. i use layer.textProperties to get it (if layer's text exist).

layer.textProperties/DocumentResources/StyleSheetSet /StyleSheetData

image

overQ-N avatar Oct 27 '22 02:10 overQ-N

Hm. The funny thing is that engine data contains precisely such value:

				/Font 3
				/FontSize 12.0
				/FauxBold false
				/FauxItalic false

Maybe it's not any standard size, but instead some custom Adobe dimension?

engine_data.txt

scoiatael avatar Oct 28 '22 09:10 scoiatael

Hm. The funny thing is that engine data contains precisely such value:

				/Font 3
				/FontSize 12.0
				/FauxBold false
				/FauxItalic false

Maybe it's not any standard size, but instead some custom Adobe dimension?

engine_data.txt

Sorry, I didn't check the 'Text Layer' attribute due to my negligence,

However, you can change the font size and color of the 'Text Layer'. You will see that the resolution result is always:

FontSize: 12
FillColor: {Type:1,Values:[1,0,0,0]}
StrokeColor: {Type:1,Values:[1,0,0,0]}

overQ-N avatar Oct 31 '22 08:10 overQ-N

For any PSD that I try, the value of FontSize is always 12 when I try to get it from layer.textProperties/DocumentResources/StyleSheetSet/StyleSheetData

BrunoQuaresma avatar Nov 10 '22 13:11 BrunoQuaresma

Looking at more sample files, looks like indeed the path you are mentioning has always the same FontSize.

But the FontSize in .EngineDict.StyleRun.RunArray | map(.StyleSheet.StyleSheetData.FontSize) seems to change - could you test if one of these properties changes according to what you expect?

I don't know whether it maps to anything natural in PS UI since I don't have access to it at the moment :)

scoiatael avatar Nov 10 '22 15:11 scoiatael

i tried it. .EngineDict.StyleRun.RunArray | map(.StyleSheet.StyleSheetData.FontSize) indeed changed.

when fontsize is 24 , parse result is 100 when fontsize is 30 , parse result is 125 when fontsize is 60 , parse result is 250

The analytical result seems to be 4.166666666666667 times the actual value.This confused me. And I need other attributes of text layer like color,weight,textDecoration.But the current parsing results are not or incorrect

overQ-N avatar Nov 18 '22 17:11 overQ-N

@overQ-N If you were to have a look at .resolutionInfo.horizontal and .vertical if it was 300 then if you were to divide this by the default resolution in Photoshop 72 pixels per inch 300/72 = 4.166666666666667

jcrisp88 avatar Jul 13 '23 18:07 jcrisp88

For anyone else that might stumble across this, I was able to solve my issue with additionalLayerProperties ['TySh'] "Type tool object setting" that holds transformXX and transformYY so I was able to get the correct font size with TransformedFontSize = FontSize * ((transformXX + transformYY) / 2) e.g. 91.79625 * ((0.6806239408469619 + 0.6806239678925272) / 2) = 62.48729 62px is what I see in photoshop 👍

jcrisp88 avatar Jul 13 '23 21:07 jcrisp88