Problem rendering Unicode characters through Pillow with DejaVuSans
See the following log output
Getting Raretoshi information for user RRizzling
Using cached data from 1647482490
Holding 89 is video/mp4 which is unsupported.
Picking another at random. Check count 1.
Holding 83 is image/gif which is unsupported.
Picking another at random. Check count 2.
Picked holding 75 titled Un₿eliever V with ipfshash QmXwt9GFbe6R8R9giVMcqeavAsrUsjnh51V5kHLS5VCPdH
The title of the work is Un₿eliever V with the bitcoin symbol.
However the generated image ends up showing the empty box for unicode characters like this.
The font in use in the vicarioustext file is /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
May need to use a different font, at least for raretoshi.
Run with the following to reproduce
./raretoshi.py RRizzling 75
Tested with the /usr/share/fonts/truetype/noto/NotoMono-Regular.ttf font but it also fails
See also from https://ourpython.com/python/does-pillow-want-my-text-parameters-to-be-unicode-or-strings
You're usually better off using explicit backslash escapes, like \u250c instead of ??, especially if you don't even know how to tell if the file is UTF-8, much less how to fix it.
Second, you almost never want to put non-ASCII characters into a str literal; use a unicode literal unless you have a good reason to do otherwise.
On top of that, if you pass draw.text a str, PIL will decode it with your default charset—which again is probably not UTF-8. So, even if everything else so far were correct, your code would be handing over some UTF-8 to be parsed as cp1252, so mojibake again. Using a unicode literal would avoid this problem entirely; otherwise, you need to pass text.decode('utf-8').
Putting that all together:
text = u"\u250c\u2500\u2510\u2502\u2514\u2518\u255e\u2550\u2561\u2564\u2567\u2558\u255b" And now the coding declaration and the actual encoding used to save the file don't matter, because the file is pure ASCII.
will try multiple fonts installed with
sudo apt-get install ttf-mscorefonts-installer