Open quangxuagoluan opened 2 months ago
Unfortunately it seems that this information is saved in psd.engineData
field, there's no documentation of that data and it's structure is very cryptic. If you just need to read that field and don't need to update it you can try my unfinished function for decoding it and try to figure out how to use it:
const data = toByteArray(psd.engineData);
const engineData = parseEngineData(data);
const engineData2 = decodeEngineData2(engineData);
Inside engineData2
structure you'll find Kerning?
field with value 2
I think that's how it's flagging "Optical kerning"
Kerning?
It appears in multiple places, and the values are different in each case. I've done a lot of testing and finally found a place where there's a difference. I created a text layer in a PSD file and then applied different kerning to it.
const engineData = parseEngineData(data);
const engineData2 = decodeEngineData2(engineData);
const kerning = get(engineData2, 'EngineDict["Editors?"][0].Editor.StyleRun.RunArray[0].StyleSheet.StyleSheetData["Kerning?"]')
console.log(kerning, 'kerning');
// 0 - 0
// 1 - metric
// 2- optical
When kerning is set to metric, it returns 1; when set to optical, it returns 2; and when set to 0, it returns 0。
Each element in Editors?
array seem to reference different text layer, but I'm not sure which one matches which layer, I couldn't find layer ID field anywhere in there that would link both, maybe they're just in the same order as the text layers.
Yes, I found that this index is consistent with its own position.
EngineDict["Editors?"]
text.index
Optical kerning is set for spacing, but the returned value is 0. Is it possible to return a different value to distinguish between optical kerning being set and the value being set to 0? text.zip