From 9ef308b469727926e15ec2706e485e737d5ac97c Mon Sep 17 00:00:00 2001 From: AskaEth Date: Thu, 27 Aug 2026 16:03:42 +0800 Subject: [PATCH] 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). --- ppl2psd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ppl2psd.py b/ppl2psd.py index 589671d..5a5c216 100644 --- a/ppl2psd.py +++ b/ppl2psd.py @@ -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"]