gpt4 book ai didi

python - 如何在 pygame 上使用字体系列?

转载 作者:行者123 更新时间:2023-12-01 01:39:37 25 4
gpt4 key购买 nike

我不久前安装了“Raleway”,但似乎无法使其适用于 pygame。我的程序似乎只能显示常规版本的字体,但不能显示粗体、斜体等。这是我所拥有的:

import pygame

pygame.init()
pygame.font.init()
myfont = pygame.font.SysFont('Raleway Bold', 72)

screen = pygame.display.set_mode((850, 600))
done = False

while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

screen.fill((8, 8, 8))
textsurface = myfont.render('WELCOME', False, (205, 92, 92))
screen.blit(textsurface,(250,200))

这是字体系列下可用的字体: Raleway

最佳答案

您的字体实际上只是命名为Raleway,要加载粗体版本,您必须 set the bold flag :

myfont = pygame.font.SysFont('Raleway', 72, bold=True, italic=False)

关于python - 如何在 pygame 上使用字体系列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52032825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com