Text flow within a bounded region, and across several of them.
flow_text/7 fills one box and reports what did not fit. flow_across_boxes/4
threads a single body of text through a list of boxes in order, which is how
multi-column layouts work: each column is a box, and text continues into the
next when one fills.
columns = [{50, 700, 240, 600}, {310, 700, 240, 600}]
{pdf, result} = Box.flow_across_boxes(pdf, rich_text, columns, line_height: 14)
if result.overflow? do
# result.spill_text is what did not fit in any box
endBoxes are {x, y, width, height} in PDF user space, with y at the box's
top edge — text flows downward from there.
Tagging
In a tagged document the flowed text is marked up as a /P. Two options
control that:
:tag—:auto(the default) tags only when the document is already being tagged,truealways,falsenever:tag_as— the structure element,:pby default. Pass:artifactfor decoration.
:artifact matters more than it looks. A watermark, a running strapline or a
repeated sidebar label is text a reader should skip, and marking it /P
means it is announced on every page — worse than not tagging at all. Structure
that is well-formed but wrong is the failure a conformance checker cannot see
for you.
# Announced as content.
Box.flow_text(pdf, x, y, w, h, body)
# Skipped, correctly.
Box.flow_text(pdf, x, y, w, h, watermark, tag_as: :artifact)
Summary
Types
Functions
@spec flow_across_boxes(Tincture.PDF.t(), Tincture.Typography.RichText.t(), [box()], [ option() ]) :: {Tincture.PDF.t(), Tincture.Layout.Box.FlowResult.t()}
@spec flow_text( Tincture.PDF.t(), number(), number(), number(), number(), Tincture.Typography.RichText.t(), [option()] ) :: {Tincture.PDF.t(), Tincture.Typography.LayoutResult.t()}