diff --git a/ppl2psd.py b/ppl2psd.py index 649fabd..28078e6 100644 --- a/ppl2psd.py +++ b/ppl2psd.py @@ -561,16 +561,17 @@ def build_type_layer_tysh(ly: dict, font_ps: str, text_w: Optional[float] = None pass l, t, rr, bb2 = bounding_rect(ly) - # transform origin = boundingRect top-left; boundingBox from the origin. - # This keeps the text edit box aligned with the text (the previous - # center-origin version shifted the box down-right). + # transform origin = boundingRect top-left; boundingBox = the ACTUAL + # text box (0,0,tw,th) so the edit box is small and sits at the text. tysh.transform = [1.0, 0.0, 0.0, 1.0, float(l), float(t)] tysh.left, tysh.top, tysh.right, tysh.bottom = int(l), int(t), int(rr), int(bb2) + tw = text_w if text_w else (rr - l) + th = size_px * 0.9 # ~glyph height bbd = td[b"boundingBox"] bbd[b"Left"].value = 0.0 bbd[b"Top "].value = 0.0 - bbd[b"Rght"].value = float(rr - l) - bbd[b"Btom"].value = float(bb2 - t) + bbd[b"Rght"].value = float(tw) + bbd[b"Btom"].value = float(th) return tysh.tobytes()