CTS logo
hazy blue Catskill Mountains in distance

News:

PDF::Builder v3.028 Released, 31 December 2025
   Please also see the CPAN listing, the GitHub entry, and the latest changes list.


A Thought…

Three engineers were walking while discussing what kind of engineer God must be. The mechanical engineer said, “God must be a Mech E. — look at the wonderful machine that the human body is.” To this, the electrical engineer replied, “God is definitely a double-E — look what a magnificent, unequaled computer the human brain is.” Finally, the civil engineer spoke up. “God is most assuredly a CE.” The other two looked and him and asked, “Why?” “Because who else would run a hazardous waste pipeline through the middle of a recreational area!”

   — Unknown

NAME

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

Inherits from PDF::Builder::Resource

METHODS

new

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

Return a font resource object.

descrByData

    $descriptor = $font->descrByData()

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

FONT-MANAGEMENT RELATED METHODS

fontname

    $name = $font->fontname()

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

altname

    $name = $font->altname()

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

subname

    $name = $font->subname()

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

apiname

    $name = $font->apiname()

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

issymbol

    $issymbol = $font->issymbol()

Return the font's symbol flag (i.e., is this a symbol font).

iscff

    $iscff = $font->iscff()

Return the font's Compact Font Format flag.

TYPOGRAPHY-RELATED METHODS

upem

    $upem = $font->upem()

Return the font's scaling factor (Units Per em). It is typically 1000 in most fonts, but more recent TTF and OTF fonts often use 2048 units.

fontbbox

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

Return the font's bounding box.

capheight

    $capheight = $font->capheight()

Return the font's capheight value.

xheight

    $xheight = $font->xheight()

Return the font's xheight value.

missingwidth

    $missingwidth = $font->missingwidth()

Return the font's missingwidth value.

maxwidth

    $maxwidth = $font->maxwidth()

Return the font's maxwidth value.

avgwidth

    $avgwidth = $font->avgwidth()

Return the font's avgwidth (average width) value.

flags

    $flags = $font->flags()

Return the font's flags value.

stemv

    $stemv = $font->stemv()

Return the font's stemv value.

stemh

    $stemh = $font->stemh()

Return the font's stemh value.

italicangle

    $italicangle = $font->italicangle()

Return the font's italicangle (slant, obliqueness) value.

isfixedpitch

    $isfixedpitch = $font->isfixedpitch()

Return the font's isfixedpitch flag.

underlineposition

    $underlineposition = $font->underlineposition()

Return the font's underlineposition value.

underlinethickness

    $underlinethickness = $font->underlinethickness()

Return the font's underlinethickness value.

ascender

    $ascender = $font->ascender()

Return the font's ascender value.

descender

    $descender = $font->descender()

Return the font's descender value.

GLYPH-RELATED METHODS

glyphNames

    @names = $font->glyphNames()

Return the defined glyph names of the font.

glyphNum

    $glNum = $font->glyphNum()

Return the number of defined glyph names of the font.

uniByGlyph

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

Return the unicode by glyph name.

uniByEnc

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

Return the Unicode by the font's encoding map.

uniByMap

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

Return the Unicode by the font's default map.

encByGlyph

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

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

encByUni

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

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

mapByGlyph

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

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

mapByUni

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

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

glyphByUni

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

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

glyphByEnc

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

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

glyphByMap

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

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

wxByGlyph

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

Return the glyph's width. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000.

wxByUni

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

Return the Unicode character's width. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000.

wxByEnc

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

Return the character's width based on the current encoding. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000.

wxMissingByEnc

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

Return true if the character's width (based on the current encoding) is supplied by "missing width" of font.

wxByMap

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

Return the character's width based on the font's default encoding. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000.

width

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

Return the width of $text as if it were at font size 1 (unscaled). CAUTION: works correctly only if a proper Perl string is used, either in native or UTF-8 format (check utf8-flag).

width_array

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

Return (as an array) the widths of the words in $text as if they were at size 1.

utfByStr

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

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

strByUtf

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

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

textByStr

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

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

textByStrKern

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

Return a properly formatted representation of $string, with kerning, for use in the PDF.

NAVIGATION LINKS

Up (Parents)

Master Index
PDF::Builder -- Facilitates the creation and modification of PDF files
PDF::Builder::Resource -- Base class for PDF resources

Siblings

PDF::Builder::Resource::CIDFont -- Base class for CID fonts
PDF::Builder::Resource::ColorSpace -- Base class for PDF color spaces
PDF::Builder::Resource::Colors -- Translate color names into RGB settings
PDF::Builder::Resource::ExtGState -- Graphics state dictionary support
PDF::Builder::Resource::Font -- Some common support routines for font files
PDF::Builder::Resource::Glyphs -- Preparsed uniglyph.txt file information
PDF::Builder::Resource::PaperSizes -- List of standard paper sizes and their dimensions
PDF::Builder::Resource::Pattern -- Support stub for fill patterns
PDF::Builder::Resource::Shading -- Support stub for fill shading patterns
PDF::Builder::Resource::UniFont -- Unicode Font Support
PDF::Builder::Resource::XObject -- Base class for external objects

 

All content © copyright 2005 – 2026 by Catskill Technology Services, LLC.
All rights reserved.
Note that Third Party software (whether Open Source or proprietary) on this site remains under the copyright and license of its owners. Catskill Technology Services, LLC does not claim copyright over such software.

 

This page is https://www.catskilltech.com/Documentation/PDF/Builder/Resource/BaseFont.html

Search Quotations database.

Last updated Thu, 01 Jan 2026 at 7:49 PM

Valid HTML 5

Sun, 14 Jun 2026 at 10:55 AM EDT