PDF::Bu...aseFont(3)

πŸ’– PDF::Builder::Resource::BaseFont β€” the glow-up edition πŸ’–

okay so bestie, this is PDF::Bu...aseFont(3), straight outta the User Contributed Perl Documentation collection, and it's literally the blueprint page for PDF::Builder::Resource::BaseFont β€” the base class for font resources. Think of it as the mother of all font objects, the one everyone else inherits their whole personality from. ✨

It Inherits from PDF::Builder::Resource 🫢 (yes it's giving legacy royalty, we love that for it)

🌸 METHODS 🌸

🌟 new

$font = PDF::Builder::Resource::BaseFont->new($pdf, $name)

Hand you back a whole font resource object. Slay. That's it, that's the job. πŸŽ€

🌟 descrByData

$descriptor = $font->descrByData()

Returns the font's FontDescriptor key structure, built off the font's own data. No cap. πŸ’…


πŸ’œ fontname

$name = $font->fontname()

Gives you the font's name β€” a.k.a. the display name, the one it goes by in public. 🌈

πŸ’œ altname

$name = $font->altname()

The font's alternative name β€” a.k.a. the Windows name for a PostScript font. It's giving secret identity, iykyk. πŸ¦‹

πŸ’œ subname

$name = $font->subname()

The font's subname β€” a.k.a. the font variant. The little flavor twist. πŸ“

πŸ’œ apiname

$name = $font->apiname()

The font's name as used internally. And bestie, it should be equal to $font->name(). If it's not… we don't talk about it. πŸ™ˆ

πŸ’œ issymbol

$issymbol = $font->issymbol()

The font's symbol flag β€” literally just answering "is this a symbol font?" ⭐

πŸ’œ iscff

$iscff = $font->iscff()

The font's Compact Font Format flag. CFF coded? Yes ma'am. πŸ’…


✨ upem

$upem = $font->upem()

The font's scaling factor β€” Units Per em. Usually it's 1000 in most fonts, but the more recent TTF and OTF fonts often be using 2048 units instead. Times change, fonts evolve, we adapt. πŸ’–

✨ fontbbox

($llx,$lly, $urx,$ury) = $font->fontbbox()

The font's bounding box. All four corners, delivered with love. πŸ“¦

✨ capheight

$capheight = $font->capheight()

The font's capheight value. Tall caps energy. πŸ‘‘

✨ xheight

$xheight = $font->xheight()

The font's xheight value. The lowercase main character. ✨

✨ missingwidth

$missingwidth = $font->missingwidth()

The font's missingwidth value. For the glyphs that ghosted us. πŸ’€

✨ maxwidth

$maxwidth = $font->maxwidth()

The font's maxwidth value. The widest one in the room. πŸ”₯

✨ avgwidth

$avgwidth = $font->avgwidth()

The font's avgwidth (average width) value. Middle of the road, but make it cute. 🌸

✨ flags

$flags = $font->flags()

The font's flags value. 🚩 (the good kind)

✨ stemv

$stemv = $font->stemv()

The font's stemv value. Vertical stems, standing tall. πŸ’œ

✨ stemh

$stemh = $font->stemh()

The font's stemh value. Horizontal stems, lying pretty. πŸ¦‹

✨ italicangle

$italicangle = $font->italicangle()

The font's italicangle value β€” a.k.a. the slant, a.k.a. the obliqueness. It's leaning, bestie, and it looks good. πŸ’…

✨ isfixedpitch

$isfixedpitch = $font->isfixedpitch()

The font's isfixedpitch flag. Monospace girlies, this one's for you. πŸŽ€

✨ underlineposition

$underlineposition = $font->underlineposition()

The font's underlineposition value. Where the lil line lives. 🫢

✨ underlinethickness

$underlinethickness = $font->underlinethickness()

The font's underlinethickness value. How thicc that lil line is. ✨

✨ ascender

$ascender = $font->ascender()

The font's ascender value. Going up, up, up. 🎈

✨ descender

$descender = $font->descender()

The font's descender value. Down bad, but on purpose. 😭


🌈 glyphNames

@names = $font->glyphNames()

Returns the defined glyph names of the font, as a whole list. Name drop incoming. πŸ’…

🌈 glyphNum

$glNum = $font->glyphNum()

Returns the number of defined glyph names of the font. The headcount. πŸ”’

🌈 uniByGlyph

$uni = $font->uniByGlyph($char)

Returns the unicode by glyph name. 🧚

🌈 uniByEnc

$uni = $font->uniByEnc($char)

Returns the Unicode by the font's encoding map. 🧚

🌈 uniByMap

$uni = $font->uniByMap($char)

Returns the Unicode by the font's default map. 🧚

🌈 encByGlyph

$char = $font->encByGlyph($glyph)

Returns the character by the given glyph name of the font's encoding map. πŸ’–

🌈 encByUni

$char = $font->encByUni($uni)

Returns the character by the given Unicode of the font's encoding map. πŸ’–

🌈 mapByGlyph

$char = $font->mapByGlyph($glyph)

Returns the character by the given glyph name of the font's default map. πŸ’–

🌈 mapByUni

$char = $font->mapByUni($uni)

Returns the character by the given Unicode of the font's default map. πŸ’–

🌈 glyphByUni

$name = $font->glyphByUni($unicode)

Returns the glyph's name by the font's Unicode map.

⚠️ CAUTION: non-standard glyph-names get mapped onto the ms-symbol area (0xF000). Not me warning you, the docs are warning you. 😭

🌈 glyphByEnc

$name = $font->glyphByEnc($char)

Returns the glyph's name by the font's encoding map. πŸ”₯

🌈 glyphByMap

$name = $font->glyphByMap($char)

Returns the glyph's name by the font's default map. πŸ”₯

🌈 wxByGlyph

$width = $font->wxByGlyph($glyph)

Returns the glyph's width. And bestie, listen: this is a value that, when divided by 1000 and multiplied by the font size (height in points), gives you the advance width to the next character's start. Typically the width will be under 1000. Math but make it fashion. πŸ“βœ¨

🌈 wxByUni

$width = $font->wxByUni($uni)

Returns the Unicode character's width. Same deal, no cap: divide it by 1000, multiply by the font size (height in points), and boom β€” that's the advance width to the next character's start. Typically the width will be under 1000. πŸ’œ

🌈 wxByEnc

$width = $font->wxByEnc($char)

Returns the character's width based on the current encoding. And yes, again: divided by 1000, multiplied by the font size (height in points) = the advance width to the next character's start. Typically the width will be under 1000. 🌸

🌈 wxMissingByEnc

$flag = $font->wxMissingByEnc($char)

Returns true if the character's width (based on the current encoding) is supplied by the "missing width" of the font. It's the fallback era. 🫢

🌈 wxByMap

$width = $font->wxByMap($char)

Returns the character's width based on the font's default encoding. And you already know the formula: divide by 1000, multiply by the font size (height in points), and that's the advance width to the next character's start. Typically the width will be under 1000. ✨

🌈 width

$wd = $font->width($text)

Returns the width of $text as if it were at font size 1 (unscaled).

⚠️ CAUTION: this only works correctly if a proper Perl string is used β€” either in native or UTF-8 format (check the utf8-flag, bestie, fr fr). πŸ’€

🌈 width_array

@widths = $font->width_array($text)

Returns (as an array) the widths of the words in $text as if they were at size 1. One number per word, cute and organized. πŸŽ€

🌈 utfByStr

$utf8string = $font->utfByStr($string)

Returns the utf8-string from string, based on the font's encoding map. 🌈

🌈 strByUtf

$string = $font->strByUtf($utf8_string)

Returns the encoded string from utf8-string, based on the font's encoding map. 🌈

🌈 textByStr

$pdf_string = $font->textByStr($string)

Returns a properly formatted representation of $string for use in the PDF. Glow-up complete. πŸ’…

🌈 textByStrKern

$pdf_string = $font->textByStrKern($string)

Returns a properly formatted representation of $string, with kerning, for use in the PDF. Kerning = the spacing is immaculate. πŸ”₯


and that's the whole page, bestie, every single method accounted for, nothing skipped, nothing invented. πŸ’–

okay so this was PDF::Bu...aseFont(3) from the User Contributed Perl Documentation, and the lil footer credits say this is from perl v5.42.0, dated 2026-01-17. periodt. πŸ’…βœ¨πŸ¦‹πŸŽ€πŸ’œ


πŸ“¦ where this page comes from