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 π
π FONT-MANAGEMENT RELATED METHODS π
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 π§
π₯ TYPOGRAPHY RELATED METHODS π₯
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 RELATED METHODS π¦
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