2

I want to type Japanese characters into my pygame program. This code below is a simple pygame program to display the text "こんにちは!".

import pygame, sys, codecs

pygame.init()

screensize = (500, 400)
gameframe = pygame.display.set_mode(screensize)

text = "こんにちは!"
newtext = text.encode("utf-8").decode("utf-8")
gamefont = pygame.font.Font(None, 60)
gametext = gamefont.render(newtext, True, (225, 225, 225))
gameframe.blit(gametext, (0, 0))

ended = False
while ended == False:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
    pygame.display.update()

I did not get the result, but instead white boxes. Please advise me. I started coding in python a few months ago.

Brandon Ng
  • 21
  • 1

0 Answers0