使用pygame2exe并使用sysfont / .ttf的字体问题

时间:2013-08-07 20:41:40

标签: python pygame py2exe

我尝试了 py2exe cx_freeze ,即使使用此网站也无处可去,使用 pygame2exe 取得了一些进展。我阅读了其他两三个帖子,但是尽管我的设置文件与指示相同,并且还放入了freesansbold.ttf,我仍然得到' 已经请求运行时终止于不寻常的方式'错误。

我会详细介绍一些细节,但奇怪的是,如果我将文字设置为标准的东西,比如" Arial"就像这里建议的那样(Pygame Distribution - Runtime Error)和它创建的应用程序可以工作,但问题是我的游戏是一个RPG,如果文本不是freesanbold它溢出到处都是不可读的,所以基本上我必须要有那个文字。

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

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

然后我把它改为:

font=pygame.font.SysFont("freesansbold.ttf", 48)

并将.ttf包含在文件夹中,但无济于事。 如果我将此更改为“Arial'然后 pygame2exe 创建一个工作文件,但由于文本问题,我需要freesanbold。

这是 pygame2exe 代码,我完全是从wiki中复制的:

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文件放在文件夹中,我也会收到运行时错误。

我没有想法,谢谢你的帮助......

2 个答案:

答案 0 :(得分:0)

我遇到了与默认系统字体相同的问题。真的很傻。我最终使用了pygame.font.SysFont("Arial", 16),但没有我必须包含任何内容。

答案 1 :(得分:0)

我解决此问题的方法是将freesansbold.ttf复制到我的项目目录,并使用pygame.font.Font("freesansbold.ttf", 16)

相关问题