[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?
Quoting Madhubala <madhubalav@xxxxxxxxxxxxxx>:
> Hi,
>
> can any one help me in rendering trademark symbol (char) on pygame
> surface.
Try this. The string passed to font.render is unicode ( u'GAP\u00a9' ).
# -*- coding: utf-8 -*-
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)
testp = u'Gap\u00a9'
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()
--
Lenard Lindstrom
<len_l@xxxxxxxxx>