Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optical kerning return 0. #198

Open
quangxuagoluan opened this issue Aug 22, 2024 · 4 comments
Open

Optical kerning return 0. #198

quangxuagoluan opened this issue Aug 22, 2024 · 4 comments
Assignees

Comments

@quangxuagoluan
Copy link

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?
image
text.zip

@Agamnentzar Agamnentzar self-assigned this Aug 22, 2024
@Agamnentzar
Copy link
Owner

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"

image

@quangxuagoluan
Copy link
Author

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。

@Agamnentzar
Copy link
Owner

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.

@quangxuagoluan
Copy link
Author

Yes, I found that this index is consistent with its own position.
EngineDict["Editors?"]
image
text.index
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants