I'm developing an app with Python 2.7 and Pygame (using Anaconda). In the app, I'm trying to draw text with Cyrillic characters, and it never displays right. I'm aware that it might be an encoding issue, so I included this line on the top of the script:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
... and then I include a 'u' in front of each string I pass. This helped, but only partially - now, instead of wrong characters I get squares!
What's interesting is that the console prints out everything just fine.
Why is this happening and how can I fix it?
This may happen because the font you are using for rendering text, is lacking Cyrillic characters. Try to find a font that is 100% Cyrillic, then render text in following way:
my_font = pygame.font.Font("path/to/cyrillic_font.ttf", 12)
text_surface = my_font.render(u"Текст", True, (255, 255, 255))