如何查看pygame自带的字体: 1look。py代码查看:importpygameselfzitipygame。font。getfonts()foriinselfziti:print(i)print(自带总共有:str(len(selfziti))个字体) 2效果图:总共有147个字体,其中自带cn为中文字体。 方法一:推荐myfontpygame。font。SysFont(cn,100)titlemyfont。render(方法一:系统自带字体:cn,False,(0,255,255))screen。blit(title,(50,50)) 方法二:自定义字体 特定自定义字体,ttf文件,需要自己提前下载好,放在指定目录下myfontpygame。font。Font(homexgjDesktoppygamecnhwxk。ttf,100)titlemyfont。render(方法二:自定义字体ttf文件,False,(0,255,255))screen。blit(title,(50,300)) 举例: 1完整代码:importpygamepygame。init()screencaptionpygame。display。setcaption(pygame中文设置)winwidth2000winheight1000screenpygame。display。setmode(〔winwidth,winwidth〕)screen。fill(〔0,0,0〕)黑色pygame。font。init()可要可不要方法一:系统自带中文,推荐myfontpygame。font。SysFont(cn,100)titlemyfont。render(方法一:系统自带字体:cn,False,(0,255,255))screen。blit(title,(50,50))方法二:自定义中文字体ttf,需要自己提前下载,并放在指定目录下myfontpygame。font。Font(homexgjDesktoppygamecnhwxk。ttf,100)titlemyfont。render(方法二:自定义字体ttf文件,False,(0,255,255))screen。blit(title,(50,300))pygame。display。flip()whileTrue:foreventinpygame。event。get():ifevent。typepygame。QUIT:exit() 2效果图: 当然,也可以设置自己喜欢的中文字体ttf文件。 赋诗一首: 【原创】 全民爱编程, 科技服务人, 学习不要等, 别忘主责任。