PDFDocument.AddFonts

Hi everyone,

I’d like to take up again the topic of embedding fonts in PDFDocument (new in Xojo 2020r1)

Let’s assume I have a data structure with objects to which the font can be assigned. Using an iterator, this data structure can be processed/rendered. If an object now uses a font that is not one of the standard fonts, it must be added to the PDF using PDFDocument.AddFonts.

Does anyone have a secure approach to read the file path of the font without Plugins to add it to the PDF? On macOS and Windows you could use SpecialFolder.Fonts, but for Linux distributions?

@Javier_Menendez - Could you please list exactly which fonts are supported (only .ttf and .otf or also others)? It looks like .ttc fonts are not supported. It would be helpful if you could include this in the official Xojo documentation.

Hi @Martin_T,

Yes, that’s right. Currently only .ttf and .otf fonts are supported. If you need to use TTC fonts you can always extract them to .ttf font files using specific tools or web services (for example https://transfonter.org/ttc-unpack).

We will include that on the documentation.

Be careful here. You might find that your recommended solution breaks a font’s license agreement.

You really need to have .ttc / .otc support built in.

1 Like

Yes, of course! that advice applies always you’re dealing with font files with a proper license to do that. (thank you for clarifying that @kevin_g)

Please bear in mind that the name of the font file will in a lot of cases be different to the name of the font.

You will probably need to read the font file and parse it to extract its name information.

This is a feature that really should be part of the PDF implementation.

1 Like

Hi @Kevin, is what it does actually for .ttf and .otf files.