Python 如何在pygame上使用字体族?
我不久前安装了“Raleway”,但似乎无法让它在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:
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)