PDF::Bu...:CIDFont(3)

✨ NAME ✨

PDF::Builder::Resource::CIDFont β€” bestie, this is the base class for all the CID fonts πŸ’–

It inherits from PDF::Builder::Resource::BaseFont, so all that ancestral power is lowkey flowing through it 🧬


πŸŽ€ METHODS πŸŽ€

🌸 new

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

Hands you back a cid-font object, bestie. It's the base class for literally every CID-based font out there β€” main character energy, fr fr πŸ‘‘

πŸ¦‹ glyphByCId

$n = $font->glyphByCId($gid)

You give it a glyph ID, it gives you back that character's glyph name (as a string). Simple. Iconic. Slay ✨

πŸ’… uniByCId

$u = $font->uniByCId($gid)

Feed it a glyph ID, it returns the character's Unicode point. But heads up β€” if there's no match, you get back U+0000. Not a vibe, but that's the deal 😭

🌈 cidByUni

$c = $font->cidByUni($uid)

Opposite direction, babes: you pass in a Unicode point, it gives you back the glyph ID. Reversible queen πŸ’œ

πŸ“ cidByEnc

$c = $font->cidByEnc($char)

Give it a character's encoding (a single byte value, 0 to 255), get back the glyph ID. Yes, just that range, no cap πŸ™ˆ

⭐ wxByCId

$w = $font->wxByCId($gid)

Returns a character's width when you hand it the glyph ID. Typically this is measured against a 1000 unit wide grid β€” that's the standard, iykyk πŸ“

🧚 wxByUni

$w = $font->wxByUni($uid)

Same energy, different lookup: give it a Unicode point, get the width. And yes, again, typically on a 1000 unit wide grid πŸ’«

🫢 wxByEnc

$w = $font->wxByEnc($enc)

Pass in an encoding (a single byte character, range 0 to 255) and it returns the width. Typically based on that same 1000 unit wide grid β€” consistency, periodt πŸŽ€

πŸ’– width

$w = $font->width($string)

Give it a whole string, get back the string's width. Typically it's a 1000 wide grid per glyph, so yeah, it adds up bestie 🌸

πŸ‘‘ width_cid

$w = $font->width_cid($gid)

A single character's width, looked up by glyph ID. Typically on a 1000 wide grid for one glyph. One glyph, one grid, one moment πŸ”₯

πŸ’€ cidsByStr

$cidstring = $font->cidsByStr($string)

Turns your string into a cid-string β€” and note: that's a single text string, not an array, bestie. It uses the font's encoding map to do it πŸ—ΊοΈβœ¨

🌟 cidsByUtf

$cidstring = $font->cidsByUtf($utf8string)

Give it a utf8-string, get back the CID-encoded string. Again: a text string, not an array. Not me having to say that twice 😭

πŸŽ€ textByStr

$cid_string = $font->textByStr($text)

You bring a text string, it brings back a cid text string. That's it, that's the whole deal 🫢

πŸ¦„ textByStrKern

$cid_string = $font->textByStrKern($text, $size, $indent)

Now with extras: you supply the character text, the size, and the indentation, and it returns a cid string. Kerning bestie behavior πŸ’…

🌸 text

$stream_str = $font->text($text, $size, $indent)

Returns a PDF text stream-ready code block so you can output the text you passed in. Text, size, indent β€” chef's kiss πŸ‘©πŸ³πŸ’‹

✨ text_cid

$stream_str = $font->text_cid($text, $size)

Same-ish energy but it uses glyph IDs: give it input text and size, get back a PDF text stream-ready output. Glow up 🌟

πŸ’œ text_cid_kern

$font->text_cid_kern($text, $size, $indent)

Returns a PDF output-ready stream command built from glyph IDs β€” you feed it text, size, and indentation. Fancy fr fr πŸ”₯

🌈 encodeByName

$font = $font->encodeByName($enc)

Hand it an input encoding, it hands you back the updated $font object. Glow-up arc complete πŸ¦‹

πŸ“ glyphNum

$g_or_w = $font->glyphNum()

Here's the tea: if a 'glyphs' table is defined for the font, it returns that table's size. Otherwise? It returns the size of the 'wx' widths table. Either way you're getting a number, bestie πŸ”’


Reminder bestie: this is a base class, so if you're calling these, you're probably doing it through a CID font that inherited all this. Respect the family tree πŸŒ³πŸ’–

Sign-off time, my love: this page came from the User Contributed Perl Documentation, and it's from perl v5.42.0, dated 2026-01-17. Go forth and render those glyphs, queen πŸ‘‘πŸ’…βœ¨

πŸ“¦ where this page comes from