我正在做一个项目,目前,我一直试图改变字体的标签在pyglet图书馆的字体,我发现网上,但我不能让它工作。我试着在网上搜索了一个小时,似乎什么都没用。添加了一些代码供参考:
font.add_file('ZukaDoodle.ttf')
ZukaDoodle = font.load('ZukaDoodle.ttf', 16)
PlayLabel = pyglet.text.Label('Go', font_name='ZukaDoodle', font_size=100, x=window.width // 2,
y=window.height - 450, anchor_x='center', anchor_y='center',
batch=buttons_batch,
color=(0, 0, 0, 1000), width=250, height=130)
所以这个错误很简单。加载的字体名不是
ZukaDoodle
,而是带有空格的Zuka Doodle
。下面是一个可执行的工作示例:这里的关键区别是
font_name='Zuka Doodle'
。另外,alpha通道通常不需要高于
255
,因为这是一个有色字节的最大值,所以除非每个通道使用16位颜色表示,否则255将是最大值。你知道吗相关问题 更多 >
编程相关推荐