I wanted to make a program with some cyrillic text in it. I made this code that would open up a window, have a title in Russian, and would put some Russian text (meaning Rasputin) on screen.The cyrillic font file supports cyrillic text.
import pygame as pg
pg.init()
pg.font.init()
font = pg.font.Font("Cyrillic-font.ttf",24)
gameDisplay = pg.display.set_mode((600, 400))
pg.display.set_caption("Распутин")
gameExit = False
while not gameExit:
for event in pg.event.get():
if event.type == pg.QUIT:
gameExit = True
gameDisplay.fill((255,255,255))
text = font.render("Распутин",True,(255,0,0))
gameDisplay.blit(text,(200,200))
pg.display.update()
quit()
The program will display the text onto the screen. However, in the title, all that appears is "????????". I've attempted to use the font.render
into the pg.display.set_caption()
, but that wouldn't work as font.render
gives a pygame surface instead of a string, so the code would stop.