找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 498|回复: 4

[已解决] 关于游戏内除英语以外的字符都显示方框的问题

[复制链接]
发表于 2023-7-30 18:17:16 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 Ca清 于 2023-8-16 10:14 编辑

情况:字体gui.rpy内原没有定义,后来定义,字体文件在game下,格式正确,命名正确。原先游戏内只有英文字符正常显示,其他均为小方框,定义后依然,特来求助


游戏制作是清干净内容从零写的,代码是用到哪写到哪,字体问题从一开始就有,不过没在意,以为等以后定义一下就行了,实际不行
关于定义,define了gui.text_font//gui.name_text_font//gui.interface_text_font之后游戏没有任何变化,更换字体没有作用,最后将字体名定义成不存在的名字后,发现游戏依然运行没有报错,猜想是这些语句根本不生效,且,将SourceHanSansLite.ttf删掉后有报错,然而若是SourceHanSansLite.ttf正常的话,中文应当可以显示,然而不能,十分困惑


[RenPy] 纯文本查看 复制代码
.


define gui.text_font = "1.ttf"
define gui.name_text_font = "1.ttf"
define gui.interface_text_font = "1.ttf"


.



[RenPy] 纯文本查看 复制代码
.


I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 8, in script
    "您已创建一个新的 Ren'Py 游戏。"
  File "game/script.rpy", line 8, in script
    "您已创建一个新的 Ren'Py 游戏。"
  File "renpy/common/00placeholder.rpy", line 220, in render
    return renpy.render(child, width, height, st, at)
Exception: Could not find font 'SourceHanSansLite.ttf'.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "D:\tools\renpy-8.1.1-sdk\renpy\bootstrap.py", line 275, in bootstrap
    renpy.main.main()
  File "D:\tools\renpy-8.1.1-sdk\renpy\main.py", line 670, in main
    run(restart)
  File "D:\tools\renpy-8.1.1-sdk\renpy\main.py", line 144, in run
    renpy.execution.run_context(True)
  File "D:\tools\renpy-8.1.1-sdk\renpy\execution.py", line 953, in run_context
    context.run()
  File "game/script.rpy", line 8, in script
    "您已创建一个新的 Ren'Py 游戏。"
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/future/utils/__init__.py", line 444, in raise_
  File "game/script.rpy", line 8, in script
    "您已创建一个新的 Ren'Py 游戏。"
  File "D:\tools\renpy-8.1.1-sdk\renpy\ast.py", line 930, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "D:\tools\renpy-8.1.1-sdk\renpy\exports.py", line 1473, in say
    who(what, *args, **kwargs)
  File "D:\tools\renpy-8.1.1-sdk\renpy\character.py", line 1352, in __call__
    self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
  File "D:\tools\renpy-8.1.1-sdk\renpy\character.py", line 1003, in do_display
    display_say(who,
  File "D:\tools\renpy-8.1.1-sdk\renpy\character.py", line 693, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "D:\tools\renpy-8.1.1-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\core.py", line 3579, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\core.py", line 4172, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\core.py", line 2779, in draw_screen
    surftree = renpy.display.render.render_screen(
  File "render.pyx", line 492, in renpy.display.render.render_screen
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\transform.py", line 909, in render
    return RenderTransform(self).render(width, height, st, at)
  File "accelerator.pyx", line 979, in renpy.display.accelerator.RenderTransform.render
  File "accelerator.pyx", line 404, in renpy.display.accelerator.RenderTransform.render_child
  File "render.pyx", line 266, in renpy.display.render.render
  File "renpy/common/00placeholder.rpy", line 220, in render
    return renpy.render(child, width, height, st, at)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 266, in renpy.display.render.render
  File "D:\tools\renpy-8.1.1-sdk\renpy\text\text.py", line 2171, in render
    virtual_layout = Layout(self, width, height, renders, drawable_res=False, size_only=True)
  File "D:\tools\renpy-8.1.1-sdk\renpy\text\text.py", line 665, in __init__
    glyphs = ts.glyphs(s, self)
  File "D:\tools\renpy-8.1.1-sdk\renpy\text\text.py", line 257, in glyphs
    fo = font.get_font(self.font, self.size, self.bold, self.italic, 0, self.antialias, self.vertical, self.hinting, layout.oversample)
  File "D:\tools\renpy-8.1.1-sdk\renpy\text\font.py", line 721, in get_font
    face = load_face(fn)
  File "D:\tools\renpy-8.1.1-sdk\renpy\text\font.py", line 662, in load_face
    raise Exception("Could not find font {0!r}.".format(orig_fn))
Exception: Could not find font 'SourceHanSansLite.ttf'.

Windows-10-10.0.17763 AMD64
Ren'Py 8.1.1.23060707
test
Sun Jul 30 17:52:55 2023


.



2023.8.16问题已经解决,解决办法:
在screen.rpy中补回
style default:
    properties gui.text_properties()








 楼主| 发表于 2023-7-31 08:34:41 | 显示全部楼层
情况示例
0K3X3T47Z4@GC([0_C3V6)8.png SR~J2EQJUPK2K7%M)~90]2K.png
回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2023-8-15 10:01:47 | 显示全部楼层
后来发现common.rpym里的define gui.system_font = 'SourceHanSansLite.ttf'还起作用,这句话删掉之后SourceHanSansLite.ttf也能删,游戏没有任何变化,也不报错
现在情况就是,就是我不管写什么,只要是关于定义字体的,都不生效,游戏没有变化,也不报错,就是写了跟没写一样,哭了
回复 支持 抱歉

使用道具 举报

发表于 2023-8-15 10:25:01 | 显示全部楼层
因为原本的字体包不包括部分中文字和符号,导致那些文字会变成方块。
直接把那几个改成不存在的字体包,renpy检测不到就会改成默认的原装字体,直接删了也一样,不是说没用。

建议去100font.com下载其他的字体包,然后放在game文件夹下,之后再去把那三个地方改成替换的文件名。
[RenPy] 纯文本查看 复制代码
## 用于游戏内文本的字体。
define gui.text_font = "HarmonyOS_Sans_SC_Medium.ttf"

## 用于角色名称的字体。
define gui.name_text_font = "HarmonyOS_Sans_SC_Medium.ttf"

## 用于游戏外文本的字体。
define gui.interface_text_font = "HarmonyOS_Sans_SC_Medium.ttf"

回复 支持 抱歉

使用道具 举报

 楼主| 发表于 2023-8-16 10:12:06 | 显示全部楼层
上一楼文不对题

解决办法:
在screens.rpy里补回
[RenPy] 纯文本查看 复制代码
style default:
    properties gui.text_properties()
回复 支持 抱歉

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|RenPy中文空间 ( 苏ICP备17067825号|苏公网安备 32092302000068号 )

GMT+8, 2024-12-22 12:07 , Processed in 0.132651 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表