Text::...:TTFont(3pm)

πŸ“¦
version 0.31 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

okay so bestie, meet Text::PDF::TTFont πŸ’– β€” she inherits from Text::PDF::Dict, and she represents a TrueType font inside a PDF file. that's it, that's the girl. πŸ‘‘


🌸 DESCRIPTION 🌸

fr fr, a font in a PDF is made of two primary parts: the header and the font descriptor. and here's the tea β˜• β€” two different fonts can totally share the same font descriptors, but they each get their own header dictionaries. those header dicts are where the encoding and width info lives. sharing is caring, but headers are personal. πŸ’…


πŸ¦‹ INSTANCE VARIABLES πŸ¦‹

literally nothing extra here, bestie. there are no instance variables beyond the ones that directly correspond to entries in the appropriate PDF dictionaries. that's the whole vibe. ✨


πŸ’– METHODS πŸ’–

Text::PDF::TTFont->new($parent, $fontfname, $pdfname, %opts)

makes a whole new font resource for the given fontfile πŸŽ€ β€” and when I say whole, I mean it: this includes the font descriptor and the font stream. the $pdfname is the name this font resource will be known by throughout one particular PDF file. like, her government name. 🫢

heads up: all font resources are full PDF objects. no halfsies. ⭐

$t->width($text)

measures the width of the given text, using the widths stored in the font. it's giving ruler energy. πŸ“

$t->trim($text, $len)

trims the given text down to the given length (in per mille em) and hands you back the trimmed text. βœ‚οΈ

$t->out_text($text)

tells the font that this text is about to be output, and returns the text to be output. it's a heads-up text, basically. πŸ”₯

$f->copy

copies the font object β€” but excluding the name, widths and encoding, etc. so like, the aesthetic, not the identity. πŸ™ˆ


πŸ‘‘ TITLE πŸ‘‘

okay so this part is about Text::PDF::TTIOString β€” an internal IO type handle for string output for font embedding 🧚. and ngl, this code is ripped out of IO::Scalar, literally just to save the direct dependence for so little. so if you want the details, go see IO::Scalar. iykyk. πŸ’œ


and that's the whole page, bestie!! 🌈 this was Text::PDF::TTFont(3pm) from the User Contributed Perl Documentation, running on perl v5.36.0, dated 2022-10-22. slay, go forth and embed some fonts πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from