使用 pygame2exe 并在 sysfont/.ttf 中出现字体问题 [英] Using pygame2exe and having font issue with sysfont/.ttf

查看:52
本文介绍了使用 pygame2exe 并在 sysfont/.ttf 中出现字体问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了 py2execx_freeze,但即使使用该站点也无济于事,使用 pygame2exe 取得了一些进展.我阅读了其他两三个处理此问题的帖子,但尽管我的设置文件与指示相同,并且还放入了 freesansbold.ttf,但我仍然收到已请求运行时以异常方式终止'错误.

I tried py2exe, cx_freeze and got nowhere with those even using this site, made some progress with pygame2exe. I read the two or three other posts dealing with this, but despite having my setup file the same as instructed, and also putting in the freesansbold.ttf I still get the 'has requested the runtime to terminate in an unusual way' error.

我将详细介绍一些细节,但奇怪的是,如果我将文本设置为标准的东西,例如此处建议的Arial"(Pygame Distribution - 运行时错误) 和它创建的应用程序确实可以工作,但问题是我的游戏是 rpg,如果文本不是 freesanbold,它会到处溢出并且是不可读,所以基本上我必须有那个文本.

I will go into some details, but what is strange is if I set my text to a standard thing like "Arial" like was suggested here (Pygame Distribution - Runtime Error) and the app it creates DOES work, but the problem is my game is an rpg, and if the text is not the freesanbold it spills everywhere and is unreadable, so basicly I HAVE to have that text.

这是我最初获得字体代码的方式:

Here is how I had my font code initially:

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

然后我把它改成:

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

并将 .ttf 包含在文件夹中,但无济于事.再次,如果我将其更改为Arial",则 pygame2exe 会创建一个工作文件,但由于文本问题,我需要 freesanbold.

and included the .ttf in the folder, but to no avail. AGAIN if I change this to 'Arial' then the pygame2exe creates a working file, but I need the freesanbold because of text issues.

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

Here is the pygame2exe code, which i copied exactly from the 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 放在文件夹中,但没有.这可能是一个超级简单的修复,但我已经在这个问题上呆了好几天了,我无法弄清楚.

I have tried putting .dlls in the folder, nothing. It is probably a super simply fix, but I have been at this for days, and I can't figure it out.

同样,我在这里关注了 wiki (http://pygame.org/wiki/Pygame2exe)确切地说,但问题是即使将 .ttf 文件放在文件夹中,我也会收到运行时错误.

Likewise I followed the wiki (http://pygame.org/wiki/Pygame2exe) here exactly but the problem is I get the runtime error even when the .ttf file is placed in the folder.

我没有想法,感谢您的帮助...

I am out of ideas, thanks for any help...

推荐答案

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

My workaround for this problem was to copy freesansbold.ttf to my project directory, and to use pygame.font.Font("freesansbold.ttf", 16)

这篇关于使用 pygame2exe 并在 sysfont/.ttf 中出现字体问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆