On one machine, I created and tested code using FPDF in Python, generating a PDF with custom fonts.
Then I used Git to push that code to another machine which doesn't have the fonts. I changed the path to the new font (direct to the .tty file standalone)
There is no mention of that old path (it contains 'bpickering', my other machine's username) in my code now. See image:
Note that Resources_Dir is a string passed from main()
:
I did a fresh install of Conda, and all the packages FPDF included, on the new machine. When I run, the only code I run is that in the image: python3 Process_Calibration.py
and it doesn't import any other scripts authored by me.
However, it gives me an error suggesting it is still looking for the path on my old machine.
Traceback (most recent call last):
File "Process_Calibration.py", line 907, in <module>
main(
File "Process_Calibration.py", line 888, in main
Make_PDF(
File "Process_Calibration.py", line 813, in Make_PDF
pdf.output(Save_Dir+"Menapia_Calibration_Certificate_of_Conformity___ID"+str(Calibration_ID)+"___Metsensor_"+Metsensor_ID[-4:]+".pdf",'F') # Save PDF with path. F means file out. https://pyfpdf.readthedocs.io/en/latest/reference/output/index.html#output
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/fpdf.py", line 1065, in output
self.close()
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/fpdf.py", line 246, in close
self._enddoc()
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/fpdf.py", line 1637, in _enddoc
self._putresources()
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/fpdf.py", line 1584, in _putresources
self._putfonts()
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/fpdf.py", line 1288, in _putfonts
ttfontstream = ttf.makeSubset(font['ttffile'], subset)
File "/home/ben/miniconda3/envs/calibration/lib/python3.8/site-packages/fpdf/ttfonts.py", line 459, in makeSubset
self.fh = open(file ,'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/bpickering/Documents/Menapia/Code/metsensor_data_management/resources/MontserratRegular.ttf'
How can this be? Does the font file have some kind of memory as to where it was stored on the other machine?