mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-27 19:48:14 -06:00
Auto-size fields (`0 Tf`, often inherited from the AcroForm /DA) fit their value to the box in the page appearance, but the in-place editor and the preview shown before the page re-renders ignored it: they used a fixed guess from the box height, never shrank to the width and never wrapped multiline text, so long values ran past the box and were clipped. The fit now lives in one place, `appearance::auto_text_size_by` (re-exported as `field_auto_text_size_by`). The page appearance measures with Helvetica; the screen measures with the interface font it draws in, which is wider and breaks lines differently, so the text stays inside the box on screen too. The editor wraps at the same scaled width the size was fitted to. Explicit sizes are unchanged and still clip, as in Acrobat. Tests: forms auto_text_size_fits_single_and_multiline_text (incl. NaN/inf/ negative boxes and a NaN measurer); ui-egui auto_size_fields_shrink_and_wrap_typed_text_to_fit_their_box (fails with the old on-screen sizing restored). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>