layout
my $lines = PDF::Make::Builder::Runs->layout(
runs => [ { font => $font, text => 'Total ' }, ... ],
width => $content_w,
indent_w => $indent_w,
);
Greedy first-fit, matching the legacy single-font algorithm word for word. Returns an arrayref of lines, each a hashref of segs (each with font, text and w), the total w, is_first, and the line's size and lh - the largest font size and line height present on it, so a bold or larger run makes room for itself rather than overprinting the line above.
NAME
PDF::Make::Builder::Runs - line breaking across styled inline runs
SYNOPSIS
my $lines = PDF::Make::Builder::Runs->layout(
runs => [
{ font => $plain, text => 'Amount due: ' },
{ font => $bold, text => '£1,240.00' },
{ font => $plain, text => ' by 30 September.' },
],
width => 400,
);
for my $line (@$lines) {
for my $seg (@{ $line->{segs} }) {
# $seg->{font}, $seg->{text}, $seg->{w}
}
}
DESCRIPTION
Pure layout: no canvas, no page, no side effects. Given runs and a width it returns the lines they break into. PDF::Make::Builder::Text renders the result; keeping the two apart is what makes the breaking testable on its own, and the equality with the legacy single-font path checkable.
Adjacent segments that share a font object (compared by address, not by value) are measured as one string. Callers that build a font per run should reuse one object per distinct style, or the coalescing - and with it the guarantee that single-run text breaks exactly as it did before runs existed - will not happen.