TextWidth returns 0

In my web app I’m creating a PDF. In order to layout some text, I need to know it’s width. PDFDocument.Graphics.TextWidth returns 0 depending on the font selected and the computer that the web server is running on.

Is there any documentation on installing fonts or other settings to make this work?

Feedback 65609 (fixed and waiting for verification as of Nov 19, 2021) is related to this.

i see only a method where you can pass a (folderitem) path with your own special fonts.
https://documentation.xojo.com/api/pdf/pdfdocument.html#pdfdocument-addfonts

i don’t know if it affects your TextWidth =0

Hi @Eric_Bloom,

Make sure that the server/computer has installed the fonts you want to user in the PDF, or use AddFonts as pointed out by @MarkusR

Thanks for the pointers. I was developing on Windows, but server is Ubuntu Linux, so I installed the Microsoft standard fonts on the server. Working as expected now.

apt install ttf-mscorefonts-installer
3 Likes