如何在pygame上使用字体族?

2024-04-26 13:10:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我不久前安装了“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


Tags: 程序版本eventfalseinit字体screenpygame