I am following the answer provided by Erik Kalkoken in this question UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' (writing to PDF). I have already installed NotoSansTC-Regular.otf in the font system folder of my m1 Mac, but run pdf.add_font("NotoSans", style="", fname="NotoSansTC-Regular.otf", uni=True) , i get this error:
RuntimeError Traceback (most recent call last)
/Users/yeung/pdf_test/pdf_test.ipynb Cell 5' in <cell line: 46>()
44 height = 20
45 pdf = PDF()
---> 46 pdf.add_font("NotoSans", style="", fname="NotoSansTC-Regular.otf", uni=True)
47 pdf.add_font("NotoSans", style="B", fname="NotoSansTC-Black.otf", uni=True)
48 pdf.add_font("NotoSans", style="T", fname="NotoSansTC-Thin.otf", uni=True)
File ~/miniforge3/envs/xgboost/lib/python3.8/site-packages/fpdf/fpdf.py:469, in FPDF.add_font(self, family, style, fname, uni)
467 **ttffilename = os.path.join(SYSTEM_TTFONTS, fname)**
468 else:
--> 469 raise RuntimeError("TTF Font file not found: %s" % fname)
470 name = ''
471 if FPDF_CACHE_MODE == 0:
RuntimeError: **TTF Font file** not found: NotoSansTC-Regular.otf
I noticed the system seems looking for ttf file, but mine is a otf file. How to fix this?