Sync StyleRun/ParagraphRun run lengths with new text length
Photoshop warns the text layer needs conversion / editing changes layout when the run length array (character-style/paragraph length per run) does not match the text. We changed Editor.Text but left RunLengthArray at the template's 16, so PS flagged every TypeLayer. Now set both run length arrays to len(text).
This commit is contained in:
1 parent
d322404e5a
commit
9ef308b469
1 file changed
+5
@@ -520,6 +520,11 @@ def build_type_layer_tysh(ly: dict, font_ps: str) -> bytes:
|
||||
editor["Text"] = String(text + "\r")
|
||||
# Txt (legacy text) value mirrors the engine text so readers agree
|
||||
td[b"Txt "].value = text + "\x00"
|
||||
# Style/paragraph run lengths must match the new text length, otherwise
|
||||
# Photoshop warns the text layer needs conversion / editing changes layout.
|
||||
text_len = len(text)
|
||||
eng["StyleRun"]["RunLengthArray"] = List([Integer(text_len)])
|
||||
eng["ParagraphRun"]["RunLengthArray"] = List([Integer(text_len)])
|
||||
|
||||
prof = font_profile(_font_path_for(ly))
|
||||
size_px = float(ly.get("textSize", "12") or 12) * prof["k"]
|
||||
|
||||
Reference in new issue
Block a user