I am writing a program that is supposed to turn a paragraph into a PDF. A lot of said paragraphs have emoji's in them and I cannot figure out how I am supposed to make them show up on the PDF.
Whenever there is an emoji in a paragraph I get the following error
File "C:\Python38\lib\site-packages\fpdf\fpdf.py", line 1449, in _putTTfontwidths
if (font['cw'][cid] == 0):
IndexError: list index out of range
Now from my understanding this basically says that an emoji was not found at this uncode location in the font. But I have looked at the font in detail and it does indeed contain emojis.
getting the length of font['cw'] reveals that it goes up to 65536 when the emoji in question is located at position 128522 which is almost twice as far.
Now if I edit the fpdf code from this
if (font['cw'][cid] == 0):
continue
to this
try:
if (font['cw'][cid] == 0):
continue
except:
continue
It prints 2 boxes instead of emojis but if I copy paste the boxes into a web browser they are displayed correctly.
I am assuming this is an encoding problem. But I haven't really meddled with encoding so i am unsure how to proceed.