pygame displays Chinese on the screen
There is a method in pygame called get_fonts()
, the return value of the method is a list, and the list stores the names of all font files in the system.
Use this code to output the names of all font files in the system
import pygame
lst = pygame.font.get_fonts()
# print lst
print(lst)
I found microsoftjhengheimicrosoftjhengheiui
this Microsoft Simplified Chinese from the returned font file name list , and used it in the following code:
...
info = pygame.font.SysFont("microsoftyaheimicrosoftyaheiui", 25)
info_fmt = info.render("一 等 奖", True, (255, 255, 255))
self._display_surf.blit(info_fmt, (100, 250))
# 更新屏幕
pygame.display.flip()
...