[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Can any one help me on how to render non_ascii(unicode) chars on pygame screen?
This displays some unicode characters on the title bar for me:
# -*- coding: utf-8 -*-
import pygame
from pygame.locals import*
def main():
msg = u"General Punctuation: \u2020\u2021\u2030"
pygame.init()
resolution = 800, 400
screen = pygame.display.set_mode(resolution)
pygame.display.set_caption(msg.encode('utf-8'))
fg = 250, 240, 230
bg = 5, 5, 5
wincolor = 40, 40, 90
#fill background
screen.fill(wincolor)
font = pygame.font.Font(pygame.font.match_font('arial'),40)
tm = font.render(msg, False, fg, bg)
screen.blit(tm, (10, 100))
pygame.display.flip()
while 1:
#use event.wait to keep from polling 100% cpu
e=pygame.event.wait()
if e.type in (QUIT, KEYDOWN):
if(e.key==K_ESCAPE):
break
pygame.quit()
if __name__=='__main__':main()
Lenard
Quoting Marcel Rodrigues <marcelgmr@xxxxxxxxx>:
> Can anyone put non-ascii characters on the title bar of the windows of
> pygame?
> I'm having problems with it. Characters like ÁÉÓÖö are showed as "?".
> I'm using Pygame 1.8, on Windows XP.
> Thanks in advance.
>
> Marcel
>