使用pygame2xe时出现字体模块错误



我使用了Pygame网站上的Pygame2exe,这解决了.dlls的问题,但仍然存在一个错误
我使用的唯一字体是标准pygame字体(freesansbold.ttf),我在游戏目录中包含了它的副本
此外,
我使用的是Font类,而不是SysFonts类,我认为它可以解决我的问题
有什么想法吗?

C:Python26apple_orcharddistappleorchard.exe:27: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygamefont.pyd
(ImportError: MemoryLoadLibrary failed loading pygamefont.pyd)
Traceback (most recent call last):
  File "appleorchard.py", line 165, in <module>
  File "appleorchard.py", line 27, in __init__
  File "pygame__init__.pyo", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: MemoryLoadLibrary failed loading pygamefont.pyd)

您的问题看起来与此问题非常相似:http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe

尝试将"sdl_ttf.dll"添加到系统dll列表中,如下所示:

origIsSystemDLL = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
def isSystemDLL(pathname):
    # checks if the freetype and ogg dll files are being included
    if os.path.basename(pathname).lower() in ("libfreetype-6.dll", "libogg-0.dll", "sdl_ttf.dll"):
            return 0
    return origIsSystemDLL(pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one

最新更新