polettix / ETOOBUSY

GitHub Pages with Jekyll for the impatient
https://github.polettix.it/ETOOBUSY/
Other
6 stars 1 forks source link

PDF::Builder font selection #32

Open PhilterPaper opened 7 months ago

PhilterPaper commented 7 months ago

I saw your comments in https://github.polettix.it/ETOOBUSY/2023/05/06/font-in-pdf-builder/ about selecting a font in PDF::Builder (a Perl package I maintain). Just a reminder that the font() call is not the only way to select a font to use. In both PDF::API2 and PDF::Builder you can open a specific type of font (e.g., a TTF font with ttfont(). In fact, this is the older way, and font() is just a recent convenience function. In addition, in PDF::Builder (only) there is a recently added "FontManager" subsystem to make it a bit easier to select a font, and more importantly, switch among variants (normal text to italic to normal to bold, etc.). Whereas with font() you need to know each variant file's name and explicitly open it (if not already opened), with FontManager you deal with the "face" (typeface or type family, such as Times), and "bold" and "italic" flags. Only when you change the typeface do you need to give the "face" -- the rest of the time you can just turn the bold and italic flags on and off. In addition, FontManager opens fonts as necessary and keeps track of what fonts have been opened and caches them for the whole document, minimizing the waste of repeatedly creating another font object for a given variant.

If you have any questions about PDF::Builder or want to report a problem or request a new feature, feel free to open an issue on PhilterPaper/Perl-PDF-Builder.

polettix commented 7 months ago

Hi @PhilterPaper - thanks for stopping by!

Thanks also for the hints. Reading the post now, it's clear (to me myself!) that I had hit some directory-related wall, possibly due to using the same program in Linux and Windows on different computers, so I wanted to take some notes for future me.

I think your observations are worth adding anyway, I'll try to do an update in the coming days. Thanks!

PhilterPaper commented 7 months ago

Glad to help, and happy to see someone else using PDF::Builder. You can go ahead and close this ticket if you have nothing further to add to it.