简体   繁体   中英

How to add non-english characters on a screen title in pygame?

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.

In my opinion, it is an operative system design failure.

In windows 10 Pro I just changed "Region Settings" to Russian. Find it in "Region, Administrative". All keep old language and text Russian text has Cyrillic letters.

Maybe is not the best solution, but it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM