PDF::Bu...oreFont(3)

πŸ’– PDF::Builder::Resource::Font::CoreFont β€” the manual page (aka PDF::Bu...oreFont(3)) πŸ’–

okay bestie, sit down, hydrate, because this is the page all about the module that lets you use the 14 standard PDF built-in Fonts (plus 15 Windows Fonts) πŸŽ€βœ¨

It inherits from PDF::Builder::Resource::Font, so it's getting all that good good from its parent. Family business, periodt.


✨ SYNOPSIS ✨

#
use PDF::Builder;
#
my $pdf = PDF::Builder->new();
my $cft = $pdf->font('Times-Roman');
#my $cft = $pdf->corefont('Times-Roman');
#
my $page = $pdf->page();
my $text = $page->text();
$text->font($cft, 20);
$text->translate(200, 700);
$text->text("Hello, World!");

literally the classic "Hello, World!" but make it typography πŸ’…


🌸 METHODS 🌸

🫢 new

$font = PDF::Builder::Resource::Font::CoreFont->new($pdf, $fontname, %options)

Returns a corefont object. that's it, that's the whole vibe β€” you hand it a $pdf, a $fontname, some %options, and it hands you back a shiny font object ✨


πŸ‘‘ Supported typefaces

Standard PDF types

See examples/020_corefonts for a list of each font's glyphs.

  • Helvetica, Helvetica-Oblique, Helvetica-Bold, Helvetia-BoldOblique β€” sans-serif, and ngl it may have Arial substituted on some systems (e.g., Windows).
  • Courier, Courier-Oblique, Courier-Bold, Courier-BoldOblique β€” fixed pitch, and it may have Courier New substituted on some systems (e.g., Windows).
  • Times-Roman, Times-Italic, Times-Bold, Times-BoldItalic β€” serif, and yes it may have Times New Roman substituted on some systems (e.g., Windows).
  • Symbol, ZapfDingbats β€” various symbols, including the Greek alphabet (in Symbol). iconic tbh πŸ”₯

Primarily Windows typefaces

See examples/022_truefonts /Windows/Fonts/<name>.ttf for a list of each font's glyphs. examples/020_corefonts can also be used.

  • Georgia, Georgia-Italic, Georgia-Bold, Georgia-BoldItalic β€” serif proportional.
  • Trebuchet, Trebuchet-Italic, Trebuchet-Bold, Trebuchet-BoldItalic β€” sans-serif proportional with simple strokes.
  • Verdana, Verdana-Italic, Verdana-Bold, Verdana-BoldItalic β€” sans-serif proportional with simple strokes.
  • BankGothic, BankGothic-Italic, BankGothic-Bold, BankGothic-BoldItalic β€” sans-serif proportional with simple strokes. Free versions of Bank Gothic are often only medium weight Roman (BankGothic), and this is all that usually comes with Windows.
  • Webdings, Wingdings β€” various symbols, in the vein of Zapf Dingbats.

🚨 important bestie moment 🚨 Keep in mind that only font metrics (widths) are provided with PDF::Builder; the fonts themselves are provided by the reader's machine (often packaged with the operating system, or obtained separately by the user). To use a specific font may require you to obtain one or more files from some source.

If a font (typeface and variant) is not available on a given reader's machine, a substitution may be automatically made. For example, Helvetica is usually not shipped with Windows machines, and Arial might be substituted. For most characters, the glyph widths will be the same, but this can not be guaranteed! 😭

PDF::Builder currently uses the [typeface].pm files to map glyph names to code points (single byte encodings only) and to look up the glyph widths for character positioning. There is no guarantee that a given font file includes all the desired glyphs, nor that the widths will be absolutely the same, even in different releases of the same font. (so like… don't come for us if your glyphs ghost you πŸ™ˆ)


πŸ’… Options

  • encode β€” changes the encoding of the font from its default. Notice that the encoding (not the entire font's glyph list) is shown in a PDF object (record), listing 256 glyphs associated with this encoding (and that are available in this font).

See Perl's Encode for the supported values.

Warning: only single byte encodings are permitted. Multibyte encodings such as 'utf8' are forbidden. 🚫
  • dokern β€” enables kerning if data is available.

"kerning" is an older name for this option, and is still available as an alternative to "dokern".

  • pdfname β€” changes the reference-name of the font from its default. The reference-name is normally generated automatically and can be retrieved via $pdfname=$font->name().
  • metrics β€” if given, it is expected to be an anonymous hash of font file data. This is to be used instead of looking up the $fontname.pm file for width and other data. You may need to use this option if your installed font happens to be out of sync with the PDF::Builder built-in core font metrics file (e.g., helveticabold.pm). (sync check, bestie 🧚)

⭐ is_standard

$bool = $class->is_standard($name)

$bool = $class->is_standard($name, $win_flag)

Returns true if $name is an exact, case-sensitive match for one of the standard font names shown above. If $win_flag is given, and is true (1), check against not only the basic 14 fonts, but also against the additional 15 Windows core font extensions. πŸ‘‘


🌈 names

my @font_names = PDF::Builder::Resource::Font::CoreFont->names($flag);

my $array_ref  = PDF::Builder::Resource::Font::CoreFont->names($flag);

Returns an array or a reference to an array containing the names of the built-in core (standard) fonts.

If called with an optional $flag of "true" value (1), the additional 15 Windows core fonts are included. πŸ¦‹


πŸ“ loadallfonts

PDF::Builder::Resource::Font::CoreFont->loadallfonts($flag)

"Requires in" all fonts available as corefonts, including Windows extensions if the optional $flag is given and is "true" (1).

πŸ’€ Warning: "dies" if any requested font is not found! πŸ’€

πŸŽ€ AUTHOR πŸŽ€

Alfred Reibenschuh


okay that's the whole page, you ate it, no crumbs πŸ’…βœ¨ this was PDF::Bu...oreFont(3) from perl v5.42.0, dated 2026-01-17 β€” love u, go kern something pretty πŸ«ΆπŸŒΈπŸ’–

πŸ“¦ where this page comes from