Search code examples
pythonfontsreportlab

reportlab.pdfbase.ttfonts.TTFError: Can't open file "Times New Roman.ttf"


I have problem in importing font times new roman in ReportLab python

pdfmetrics.registerFont(TTFont('TNR', 'Times New Roman.ttf'))
pdfmetrics.registerFont(TTFont('TNRB', 'Times New Roman Bold.ttf'))

Solution

  • You are using a wrong filename.

    pdfmetrics.registerFont(TTFont('TNR', 'times.ttf'))
    pdfmetrics.registerFont(TTFont('TNRB', 'timesbd.ttf'))