PDF::AP...BaseFont(3)

πŸ’– PDF::API2::Resource::BaseFont πŸ’–

okay so bestie, welcome to the PDF::AP...BaseFont(3) page, part of the User Contributed Perl Documentation situation ✨ this is the base class for font resources β€” like, the blueprint every font object in PDF::API2 is lowkey built on. she doesn't do the glamorous stuff herself, she's the mother of all font resources, and honestly? mother. πŸ‘‘


🌸 NAME 🌸

PDF::API2::Resource::BaseFont β€” the base class for font resources πŸŽ€


✨ METHODS ✨

  • $font = PDF::API2::Resource::BaseFont->new($pdf, $name) β€” bestie this is the constructor, it hands you back a font resource object, no cap 🫢
  • $descriptor = $font->descrByData() β€” gives you back the font's FontDescriptor key structure, built off the font's own data πŸ’…

these are the ones that tell you who this font is, like a font's whole government name situation 🌈

  • $name = $font->fontname() β€” the font's name (a.k.a. its display name) πŸ’–
  • $name = $font->altname() β€” the font's alternative name (a.k.a. the Windows name for a postscript font) πŸ¦‹
  • $name = $font->subname() β€” the font's subname (a.k.a. the font variant, schriftschnitt</palette>) πŸŽ€
  • $name = $font->apiname() β€” the name the font uses internally β€” and heads up, it should be equal to $font->name() πŸ‘€
  • $issymbol = $font->issymbol() β€” spits out the font's symbol flag ⭐
  • $iscff = $font->iscff() β€” spits out the font's Compact Font Format flag 🧚

the measurements era ✨ all the numbers that describe how this font actually sits on the page, fr fr

  • ($llx, $lly, $urx, $ury) = $font->fontbbox() β€” the font's bounding box πŸ¦‹
  • $capheight = $font->capheight() β€” the font's capheight value πŸ‘‘
  • $xheight = $font->xheight() β€” the font's xheight value πŸ‘‘
  • $missingwidth = $font->missingwidth() β€” the font's missingwidth value πŸ‘‘
  • $maxwidth = $font->maxwidth() β€” the font's maxwidth value πŸ‘‘
  • $avgwidth = $font->avgwidth() β€” the font's avgwidth value πŸ‘‘
  • $flags = $font->flags() β€” the font's flags value πŸ‘‘
  • $stemv = $font->stemv() β€” the font's stemv value πŸ‘‘
  • $stemh = $font->stemh() β€” the font's stemh value πŸ‘‘
  • $italicangle = $font->italicangle() β€” the font's italicangle value πŸ‘‘
  • $isfixedpitch = $font->isfixedpitch() β€” the font's isfixedpitch flag ⭐
  • $underlineposition = $font->underlineposition() β€” the font's underlineposition value πŸ‘‘
  • $underlinethickness = $font->underlinethickness() β€” the font's underlinethickness value πŸ‘‘
  • $ascender = $font->ascender() β€” the font's ascender value πŸ‘‘
  • $descender = $font->descender() β€” the font's descender value πŸ‘‘

glyph o'clock bestie, this is where we get into the individual little characters and their whole lore πŸ’…

  • @names = $font->glyphNames() β€” all the defined glyph names of the font 🌸
  • $glNum = $font->glyphNum() β€” how many defined glyph names the font has πŸ”’
  • $uni = $font->uniByGlyph($char) β€” the unicode, looked up by glyph name ✨
  • $uni = $font->uniByEnc($char) β€” the unicode, looked up by the font's encoding map πŸŽ€
  • $uni = $font->uniByMap($char) β€” the unicode, looked up by the font's default map 🧚
  • $char = $font->encByGlyph($glyph) β€” the character for a given glyph name, from the font's encoding map 🫢
  • $char = $font->encByUni($uni) β€” the character for a given unicode, from the font's encoding map 🫢
  • $char = $font->mapByGlyph($glyph) β€” the character for a given glyph name, from the font's default map 🫢
  • $char = $font->mapByUni($uni) β€” the character for a given unicode, from the font's default map 🫢
  • $name = $font->glyphByUni($uni) β€” the glyph's name, via the font's unicode map 🌈
🚨 BEWARE bestie: non-standard glyph-names get mapped onto the ms-symbol area (0xF000). like, they get yeeted into there. don't say I didn't warn you πŸ’€
  • $name = $font->glyphByEnc($char) β€” the glyph's name, via the font's encoding map 🌈
  • $name = $font->glyphByMap($char) β€” the glyph's name, via the font's default map 🌈
  • $width = $font->wxByGlyph($glyph) β€” the glyph's width πŸ“
  • $width = $font->wxByUni($uni) β€” the unicode's width πŸ“
  • $width = $font->wxByEnc($char) β€” the character's width, based on the current encoding πŸ“
  • $width = $font->wxByMap($char) β€” the character's width, based on the font's default encoding πŸ“
  • $wd = $font->width($text) β€” the width of $text, as if it were at size 1 πŸ“
  • @widths = $font->width_array($text) β€” the widths of all the words in $text, as if they were at size 1 πŸ“

πŸ’œ STRING METHODS πŸ’œ

the encoding/decoding glow-up section, where strings get translated back and forth like a bilingual icon 🌍

  • $utf8_string = $font->utfByStr($string) β€” gives you a utf8-string from $string, based on the font's encoding map ✨
  • $string = $font->strByUtf($utf8_string) β€” gives you the encoded string from a $utf8_string, based on the font's encoding map ✨
  • $pdf_string = $font->textByStr($text) β€” gives you a properly formatted representation of $text, all ready to be used in the PDF πŸ’…

and that's the whole page bestie, you ate this one πŸ“

this absolute icon of a doc was served up by perl v5.42.0, dated 2025-09-01 β€” so yeah, PDF::AP...BaseFont(3) really said "I was documented on that date and I'm not sorry" 😭 periodt. go forth and font responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from
  • fedora 43: perl-PDF-API2 2.048-1.fc43 Β· LGPL-2.1-or-later AND (GPL-1.0-or-later OR Artistic-1.0-Perl) AND (MIT OR Artistic-1.0-Perl)
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms