Reputation: 959
i had some pygame project that i needed to include non-English letters, specifically Amharic language letters. but the thing is even though my text editor reads and writes the letters pygame doesn't seem to understand them, it just puts them as a box.
here is a simple and similar example of the code i made:
import pygame,sys
from pygame.locals import *
# R G B
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
pygame.init()
fontObj = pygame.font.Font('freesansbold.ttf', 25)
screen = pygame.display.set_mode((400,400))
screen.fill(WHITE)
pygame.display.update()
while True:
letterw= fontObj.render('በ', True, BLACK,WHITE)#this letter for example appeas as a box in the pygame screen
#------------------------?---------------------
letterwobj= letterw.get_rect()
letterwobj.center = (20, 20)
screen.blit(letterw,letterwobj)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
I would be thank full for any suggestion and help.
Upvotes: 1
Views: 550
Reputation: 959
From the comment suggested by skrx at the top, i tried to download and use a font called 'nyala.ttf' but that didn't work so i tried to import the systems nyala font as follows fontObj = pygame.font.SysFont('nyala', 25)
and it works.
Upvotes: 1
Reputation: 1389
You can try the unicode operator:
u'በ'
or the unicode function:
unicode('በ')
but quite frankly it mostly depends on if pygame can render unicode characters.
Upvotes: 0