[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Can any one help me on how to render non_ascii(unicode) chars on pygame screen?



Hi,
 
can any one help me in  rendering  trademark symbol (char) on pygame surface.
i tried the following way ,but couldn't get  result. i am using pygame 1.8 and os is  Windows xp
 
import pygame
from pygame.locals import*
def main():
    pygame.init()
    resolution = 800, 400
    screen = pygame.display.set_mode(resolution)
    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)
    test = unichr(153).encode('utf_8')
    #test = unichr(153).encode('latin_1')
   
    testp = 'Gap'+test
    tm = font.render(testp,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()
 
----------------------------------------------------------
 
Regards,
Madhubala