Documentation
Core WorkflowLayout Engine

Layout Engine

The layout engine is the core of CraftStage's production reliability. It measures every piece of text against your template field definitions and determines exactly how it will render — before any proof is generated or file is exported.

How layout computation works

When you assign a template to a job and have items with field values, CraftStage computes the layout for every item. For each field in each item, the engine:

  1. Loads the font specified in the template
  2. Measures the text at the base font size
  3. Checks if it fits within the field's bounding box
  4. If it doesn't fit, applies the overflow policy
  5. Stores the result (computed font size, line breaks, overflow status)

This computation is deterministic — the same text with the same template always produces the same result.

Overflow policies in detail

Shrink to fit

The engine reduces the font size in small steps (0.5pt) until the text fits within the field's bounding box. It stops at the minimum font size you've defined. If the text still doesn't fit at the minimum size, it's flagged as overflow — a preflight error.

Example: "Dr. Christopher Richardson-Montgomery III" at 14pt is too wide for a 2-inch field. The engine shrinks to 11.5pt and it fits. But the field's min font size is 8pt, so if the name were even longer, the engine would shrink down to 8pt. If it still overflows at 8pt, preflight flags it.

When to use: Names, titles, and any text where you need the complete content preserved.

Wrap

The engine breaks text into multiple lines, up to the maximum number of lines you've defined. Word boundaries are respected — text breaks between words, not in the middle of a word.

Example: "123 Main Street, Suite 400, Springfield, IL 62701" wraps to three lines if the field width can't hold the full address on one line.

When to use: Addresses, descriptions, and multi-line content.

Truncate

The engine cuts the text at the point where it would overflow and appends a suffix (default: "…"). The suffix is included in the width calculation so it never causes additional overflow.

Example: "Chief Technology and Innovation Officer" becomes "Chief Technology and…" if the field is too narrow.

When to use: Supplementary text where partial content is acceptable — like secondary titles or descriptions.

Fixed

No adjustment is made. If the text overflows the field boundary, it becomes a preflight error. This is the strictest policy.

When to use: Fields where exact sizing is critical, like serial numbers or codes that must render at a specific size.

Layout results

After computation, each item stores its layout result. This includes the computed font size, the text broken into lines, and whether overflow occurred. You can see this on the job detail page — the status column shows "Ready" for items that fit, and "Shrunk" or "Overflow" for items that needed adjustment.

Hovering over a "Shrunk" status shows details like "Font reduced from 14pt to 11pt to fit."

When layout is recomputed

Layout is automatically recomputed when:

  • You change the template assigned to a job
  • You edit an item's field values
  • You modify template field settings (position, font size, overflow policy, etc.)

You don't need to trigger it manually — the system keeps layout results up to date.

Next step

After layout is computed, run Preflight to validate all items and catch any issues before production.