I’m working on a project where I need to fit variable-length text (e.g., addresses, labels, or descriptions) into fixed-size boxes within a grid layout. For example, I’m using boxes of a specific width and height (say, 8cm × 4.29cm) in a multi-column, multi-row setup on a custom page size. The text content varies widely in length, and I’ve been manually tweaking the font size (e.g., set text(size: 10pt)) and line spacing (set par(leading: 0.4em)) to avoid overflow or excessive empty space.
In tools like LaTeX, packages such as tcolorbox with \tcboxfit can automatically scale text to fit a box’s dimensions. Does Typst have a built-in feature or a recommended approach for auto-scaling text to fit a predefined box size? Ideally, I’d love a way to ensure the text dynamically adjusts-shrinking when it’s too long or enlarging when it’s too short- while staying legible and respecting the box boundaries.
If this isn’t natively supported, has anyone implemented a workaround (e.g., via scripting or preprocessing)? I’d appreciate any tips, code examples, or pointers to relevant documentation. This could be super helpful for layouts like labels, cards, or any design with fixed containers and dynamic content.
Thanks in advance!