Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在pygame上使用字体族?_Python_Python 3.x_Fonts_Pygame_Font Family - Fatal编程技术网

Python 如何在pygame上使用字体族?

Python 如何在pygame上使用字体族?,python,python-3.x,fonts,pygame,font-family,Python,Python 3.x,Fonts,Pygame,Font Family,我不久前安装了“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:

我不久前安装了“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
,要加载粗体版本,您必须:


好的,谢谢。如果我想访问“加粗”或“中等”,我需要做什么?
myfont = pygame.font.SysFont('Raleway', 72, bold=True, italic=False)