---
name: "PDF::API2::Resource::BaseFont"
section: "3pm"
platform: "linux"
package: "perl-pdf-api2"
version: "2.048-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/PDF::API2::Resource::BaseFont"
---

# PDF::API2::Resource::BaseFont(3pm)

Base class for font resources

## NAME

PDF::API2::Resource::BaseFont - Base class for font resources

## METHODS

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

  Return a font resource object.

- $descriptor = $font-\>**descrByData()**

  Return the font's FontDescriptor key structure based on the font's data.

## FONT-MANAGEMENT RELATED METHODS

- $name = $font-\>**fontname()**

  Return the font's name (a.k.a. display name).

- $name = $font-\>**altname()**

  Return the font's alternative name (a.k.a. Windows name for a postscript font).

- $name = $font-\>**subname()**

  Return the font's subname (a.k.a. font variant, schriftschnitt).

- $name = $font-\>**apiname()**

  Return the font's name to be used internally (should be equal to `$font`-\>**name()**).

- $issymbol = $font-\>**issymbol()**

  Return the font's symbol flag.

- $iscff = $font-\>**iscff()**

  Return the font's Compact Font Format flag.

## TYPOGRAPHY RELATED METHODS

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

  Return the font's bounding box.

- $capheight = $font-\>**capheight()**

  Return the font's capheight value.

- $xheight = $font-\>**xheight()**

  Return the font's xheight value.

- $missingwidth = $font-\>**missingwidth()**

  Return the font's missingwidth value.

- $maxwidth = $font-\>**maxwidth()**

  Return the font's maxwidth value.

- $avgwidth = $font-\>**avgwidth()**

  Return the font's avgwidth value.

- $flags = $font-\>**flags()**

  Return the font's flags value.

- $stemv = $font-\>**stemv()**

  Return the font's stemv value.

- $stemh = $font-\>**stemh()**

  Return the font's stemh value.

- $italicangle = $font-\>**italicangle()**

  Return the font's italicangle value.

- $isfixedpitch = $font-\>**isfixedpitch()**

  Return the font's isfixedpitch flag.

- $underlineposition = $font-\>**underlineposition()**

  Return the font's underlineposition value.

- $underlinethickness = $font-\>**underlinethickness()**

  Return the font's underlinethickness value.

- $ascender = $font-\>**ascender()**

  Return the font's ascender value.

- $descender = $font-\>**descender()**

  Return the font's descender value.

## GLYPH RELATED METHODS

- @names = $font-\>**glyphNames()**

  Return the defined glyph names of the font.

- $glNum = $font-\>**glyphNum()**

  Return the number of defined glyph names of the font.

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

  Return the unicode by glyph name.

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

  Return the unicode by the fonts encoding map.

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

  Return the unicode by the font's default map.

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

  Return the character by the given glyph name of the font's encoding map.

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

  Return the character by the given unicode of the font's encoding map.

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

  Return the character by the given glyph name of the font's default map.

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

  Return the character by the given unicode of the fonts default map.

- $name = $font-\>glyphByUni($uni)

  Return the glyph's name by the font's unicode map. **BEWARE:** non-standard glyph-names are mapped onto the ms-symbol area (0xF000).

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

  Return the glyph's name by the font's encoding map.

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

  Return the glyph's name by the font's default map.

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

  Return the glyph's width.

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

  Return the unicode's width.

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

  Return the character's width based on the current encoding.

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

  Return the character's width based on the font's default encoding.

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

  Return the width of `$text` as if it were at size 1.

- @widths = $font-\>width\_array($text)

  Return the widths of the words in `$text` as if they were at size 1.

## STRING METHODS

- $utf8\_string = $font-\>utfByStr($string)

  Return the utf8-string from string based on the font's encoding map.

- $string = $font-\>strByUtf($utf8\_string)

  Return the encoded string from utf8-string based on the font's encoding map.

- $pdf\_string = $font-\>textByStr($text)

  Return a properly formatted representation of `$text` for use in the PDF.
