I am not sure which one is your problem, because there are several ways to get this, so I will consider all the possibilities:
First make sure the file is actually saved as UTF-8. By default, Notepad and many other editors will save files in your system encoding, which is probably similar to cp1252. Testing that βit looks rightβ and βwhen the script writes these characters to a file, and I open this file in Notepad, it looks rightβ says nothing to you; obviously, if you save the cp1252 file and open it as cp1252, it looks right.
Just adding "coding = utf-8" to the beginning doesn't magically change the way the file is saved (with the exception of a few smart editors like emacs). He simply tells Python that βthis is a UTF-8 source file,β even if it is really something else. That way, Python finishes interpreting your cp1252 as UTF-8 and getting mojibake as a-with-circumflex instead of a line drawing character.
Usually, you'd better use explicit backtracks, like \u250c instead of ββ , especially if you donβt even know how to determine if a file is UTF-8, much less how to fix it.
Secondly, you almost never want to put non-ASCII characters in the str literal; Use the unicode literal if you have no good reason for doing this.
Also, if you go draw.text a str , PIL will decrypt it using your default encoding, which again is probably not UTF-8. That way, even if everything else has been correct so far, your code will pass some UTF-8, which will be treated as cp1252, so mojibake again. Using a unicode literal would completely fix this problem; otherwise, you need to go through text.decode('utf-8') .
Putting it all together:
text = u"\u250c\u2500\u2510\u2502\u2514\u2518\u255e\u2550\u2561\u2564\u2567\u2558\u255b"
And now the encoding declaration and the actual encoding used to save the file does not matter, since the file is pure ASCII.
But you can still get rectangles with a missing character, because many fonts do not have line drawing characters. I donβt know what your cour.ttf , but I found two of my Courier TTF fonts on my system: one from the old Mac OS and one from Windows XP, and none of them have them. If this is your problem, you obviously need to use a different font.
Another possibility: if you still get mojibake with the corrections above, cour.ttf might not be a font file ordered in Unicode, but one of the old TTF orders. The font viewer should show you the order of the TTF file. (I'm sure Windows comes with one, but I have no idea where it is in Windows 7 or how to use it.) Then you need to pass the right thing instead of 'unic' as encoding when loading the font. But most fonts that are not unic or symb will probably not have line drawing characters.