pyfpdf
pyfpdf copied to clipboard
User defined path to font is ignored
When you want to add_font from a custom path it is impossible to do, because add_font() function will get 'ttffile' from Fontfile.ttf, which is ususally ./fonts/Fontfile.ttf
Instead, you should define self.fonts[fontkey] = { ... 'ttffile': font_dict['ttffile'], ... } like in following snippet: self.fonts[fontkey] = { ... 'ttffile': ttffilename ... }, what will really refer on custom path to user font file.
Actually, even the original solution could work if you put your fonts into: ./fonts/Fontfile.ttf But it is not expected behavior (i guess) if your custom path will be redirected in further logic.
FYI, this was fixed in fpdf2: https://alexanderankin.github.io/pyfpdf/