NAME

PDF::Make::Builder::Font - Font registry and metrics for PDF::Make

SYNOPSIS

my $font = PDF::Make::Builder::Font->new(
    family => 'Helvetica',
    size   => 12,
    colour => '#333',
);

my $res = $font->ensure_loaded($xs_page);
my $w   = $font->measure_text('Hello World');  # exact width

DESCRIPTION

Manages PDF Standard 14 font loading, resource naming, and text metrics. Uses the C-level per-glyph width tables (via PDF::Make::Font) for exact text measurement. All 14 standard fonts with 4 variants each are supported.

PROPERTIES

colour (Str, default '#000') - Text colour as hex string.
size (Num, default 9) - Font size in points.
family (Str, default 'Helvetica') - Font family: Times, Helvetica, Courier, Symbol, ZapfDingbats.
line_height (Num) - Explicit line height. Defaults to size.

METHODS

measure_text($text)

Returns the exact width of $text in points using per-glyph width tables.

measure_word($word)

Returns the exact width of $word in points.

space_width()

Returns the exact width of a space character in points.

ensure_loaded($xs_page, $variant)

Registers the font on the page and returns the resource name. $variant: 'normal', 'bold', 'italic', 'bolditalic'.

resource_name($variant)

Returns the resource name string without loading.

hex_to_rgb($hex)

Converts hex colour to ($r, $g, $b) triple (0..1).

effective_line_height()

Returns line_height if set, otherwise size.

families()

Class method. Returns available font family names.

SEE ALSO

PDF::Make::Font, PDF::Make::Builder, PDF::Make::Builder::Text