1
我想将.woff格式的字体文件加载到我的pygame中。我已经看到其他职位谈论这个问题,但他们的答案无助于回答我的问题。我尝试使用这样的:Pygame从外部字体文件加载字体
fontObj = py.font.Font('brandon_blk-webfont.woff', 16)
textSurfaceObj = fontObj.render(self.fact, True, black, None)
textRectObj = textSurfaceObj.get_rect()
textRectObj.center = (x * 1.5, y * 1.5)
gameDisplay.blit(textSurfaceObj, textRectObj)
这是我的错误:
Traceback (most recent call last):
File "C:\Users\Sruthi\Desktop\Python\Pygame\Memorization Game\main.py", line 111, in <module>
gameLoop()
File "C:\Users\Sruthi\Desktop\Python\Pygame\Memorization Game\main.py", line 108, in gameLoop
create_button(mouse, 50, 50)
File "C:\Users\Sruthi\Desktop\Python\Pygame\Memorization Game\main.py", line 84, in create_button
fontObj = py.font.Font('Memorization Game/brandon_blk-webfont.woff', 16)
OSError: unable to read font file 'Memorization Game/brandon_blk-webfont.woff'
我已经把这个字体文件在我目前的python文件的目录,你可以在这个图片中看到:
Shows that the font files are in the same directory
另外我知道字体文件没有损坏,因为我看到一个问题可以。