0

我用 python 2.5 和 pygame 制作了一个游戏。

但是,我无法完成制作。因为发生了这个错误。

C:\Python26\TypeType\src\dist\Main.exe:8: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygame\font.pyd
Traceback (most recent call last):
  File "Main.py", line 8, in <module>
  File "pygame\__init__.pyo", line 70, in __getattr__
NotImplementedError: font module not available
Traceback (most recent call last):
  File "Main.py", line 8, in <module>
  File "pygame\sysfont.pyo", line 253, in SysFont
RuntimeError: default font not found 'freesansbold.ttf'

也许我认为原因是因为它使用了一个名为 sysfont 的对象。(因为我的程序没有在执行文件上使用 sysfont 并且能够从没有安装 Python 的 PC 启动)出了什么问题。对不起,我是初学者。

编辑 我可以找到 Python2.5\Lib\site-packages\pygame\freesansbold.ttf

但是发生了同样的错误..我可以在哪里复制freesansbold.ttf

4

3 回答 3

2

一个简单的解决方案是直接加载字体而不是使用 sysfont。只需使用 pygame.font.Font 类并直接加载一个 ttf 文件。这也将使 py2exe 的使用变得更容易,并且您可以准确地选择您想要的字体。

于 2009-08-09T05:17:25.583 回答
1

您的计算机上的可访问字体文件夹中似乎没有该freesansbold.ttf文件。这个字体应该在 Pygame 的lib目录中。

检查您的 Pygame 副本的安装文件夹,如果存在,请修改 Python 安装的字体路径以包含该目录。如果没有,您需要找到一个副本或下载更新版本的 Pygame。

于 2009-05-22T01:49:52.353 回答
0

您可能找到了解决方案,但我想给其他解决方案。用 pygame 创建你的游戏。然后,解压缩库文件。去

PythonX.X\Lib\site-packages\pygame 并复制 freesansbold.ttf

返回您解压缩并转到的库文件

库\pygame

将 freesansbold.ttf 放入并压缩库。

现在,它的工作!:)

于 2015-07-19T13:20:55.190 回答