Tom E
Tom E

Reputation: 421

Difficulty Importing Fonts in Python FPDF package

I'm having a tough time trying to get something working which I think should be straightforward.

I'm new to python and learning via projects which in this case is a simple PDF generator. I want to add custom fonts to my program (Poppins) and I can get it to work if I include the fonts in the exact location as main.py, but ideally, I want these stored in a separate folder.

I've tried numerous suggestions but nothing has worked for me yet. Such as:

    import sys
    sys.path.insert(1, '.')

I've attached a screenshot of my code below along with the error message. Thanks in advance for any support. My python code

Upvotes: 0

Views: 625

Answers (1)

David
David

Reputation: 467

From the add_font documentation of FPDF:

Note: the font source files must be accessible. They are searched successively in (if these constants are defined):

FPDF_FONTPATH (by default, the font folder in the fpdf package directory)

SYSTEM_TTFONTS (e.g. C:\WINDOWS\FONTS)

Upvotes: 1

Related Questions