svs*_*svs 2 python fonts pygame
我下载了一种名为 redline.ttf 的字体,我想在 pygame 中使用它。我只想在屏幕上打印文本。我在文件夹 pygame -> lib 中找到了一种名为“freesansbold.ttf”的基本字体。我已将下载的字体放在同一个文件夹中,但是当我使用
fontObj = pygame.font.Font('redline.ttf', 16)
textSurfaceObj = fontObj.render('some text', True, (240,240,240), (115,117,117))
textRectObj = textSurfaceObj.get_rect()
textRectObj.center = (350, 30)
DISPLAYSURF.blit(textSurfaceObj, textRectObj)
pygame.display.update()
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
OSError: unable to read font file 'redline.ttf'
Run Code Online (Sandbox Code Playgroud)
可以使用redline字体吗?