使用pygame2exe并在sysfont/中出现字体问题。

2024-05-19 09:47:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试了py2execxu-freeze,甚至连使用这个网站的人都一无所获,在pygame2exe上取得了一些进展。我读了两三篇其他的文章来处理这个问题,但是尽管我的设置文件和指示的一样,而且自由行粗体.ttf我仍然得到“请求运行时以异常方式终止”错误。在

我将详细介绍一些细节,但奇怪的是,如果我将我的文本设置为一个像这里建议的“Arial”这样的标准格式(Pygame Distribution - Runtime Error),它创建的应用程序也能正常工作,但问题是我的游戏是一个rpg,如果文本不是freesanbold,它会到处溢出,无法阅读,所以基本上我必须要有这个文本。在

以下是我最初的字体代码:

font=pygame.font.SysFont(None, 48)

然后我把它改成:

^{pr2}$

并在文件夹中包含了.ttf,但没有用。 同样,如果我将其更改为'Arial',那么pygame2exe将创建一个工作文件,但由于文本问题,我需要freesanbold。在

以下是我从wiki上复制的pygame2exe代码:

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"): # "sdl_ttf.dll" added by arit.
            return 0
    return origIsSystemDLL(pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one

我试过把.dll放在文件夹里,什么都没有。这可能是一个超级简单的解决办法,但我已经在这几天,我不知道它。在

同样,我在这里完全遵循了wiki(http://pygame.org/wiki/Pygame2exe),但问题是即使将.ttf文件放在文件夹中,也会出现运行时错误。在

我没办法了,谢谢你的帮助。。。在


Tags: 文件the文本文件夹return错误wikittf

热门问题