Revert empty TypeLayer channels (corrupt layers); center paragraph justify

Empty channels made PS report corrupted layers. Restore raster channels
(keeps layers valid). Template paragraph is justify (spreads short text
across the box, causing huge letter spacing after conversion) - set
Justification to center.
This commit is contained in:
AskaEth committed 2026-08-27 16:36:55 +08:00
1 parent 21df90209a
commit 6af94c24b4
1 file changed
+7
+7
View File
@@ -525,6 +525,13 @@ def build_type_layer_tysh(ly: dict, font_ps: str) -> bytes:
text_len = len(text)
eng["StyleRun"]["RunLengthArray"] = List([Integer(text_len)])
eng["ParagraphRun"]["RunLengthArray"] = List([Integer(text_len)])
# Template paragraph is justify (Justification=5), which spreads short
# text across the whole box. The ppl text is centered -> center align.
try:
props = eng["ParagraphRun"]["RunArray"][0]["ParagraphSheet"]["Properties"]
props["Justification"] = Integer(1) # center
except Exception:
pass
prof = font_profile(_font_path_for(ly))
size_px = float(ly.get("textSize", "12") or 12) * prof["k"]