Anyone gotten PDFDocument.AddFonts to work?

I’ve been experimenting with .addFonts for a project and nothing I do makes it work. I copied the code the Xojo blog (Xojo’s PDFDocument Class, Beyond the Standard 14 and More – Xojo Programming Blog) and that doesn’t work. No fonts are embedded in the PDF and everything shows up as plain Helvetica.

If I install the fonts into my OS, then it works perfectly… but I thought the whole point of .addFonts was that you can point it to a folder of non-installed fonts and use them in your PDF.

I’ve tried different fonts and lots of tweaking, but nothing makes any difference. Not sure where to go from here. Has anyone gotten it to work?

I think that @Javier_Menendez is the only one able to explain what it does, in detail.

Is it possible that the fonts that you are trying to add are not authorized to be embedded?

I was curious about the embedding, and came across several “how to” articles (non-Xojo) that include the following note:

" a font can only be embedded if it contains a setting by the font vendor that permits it to be embedded."

Worth a check, at any rate.

I thought about that and checked and they are authorized. I even searched and found one of the free fonts used in the Xojo blog example just in case they were different some how and it didn’t work for me, either!

Okay. I was able to get the AddFonts to work.

I used Xojo 2021 R2.1 on Windows, and used the Xojo Example Project (PDFAnnotationsDemo).

First, I copied the verdana ttf files (4 files) from C:\Windows\Fonts to a separate folder: “C:\Tools”

Then, in the Window1.PushButton1.Action Event Handler, I added a FolderItem for the “C:\Tools” directory. I passed that FolderItem to d.AddFonts. Then, I set g.FontName = “Verdana” before any other calls.

I left the remaining example code “as is”.

The resulting PDF did get the Verdana Font embedded. Confirmed in Acrobat, via File > Properties > Fonts

Hopefully that helps.

Thanks for trying this, Arthur. But isn’t Verdana already installed on Windows? Does it work for you on a font that isn’t installed?

I’m on a Mac, but I can get addFonts example to work if I install the fonts. But the whole point of addFonts is that it is supposed to work without installing them – just by pointing it to a folder of font files. (If the fonts are installed, you don’t need addFonts as you can just call the font by name and use it.)