Reputation: 17
I'm trying to use fonts that came with the pygame ( fonts from pygame.font.get_fonts()
)
for example, trying to use the font 'comicsansms' (which is in the available fonts in pygame):
font = pygame.font.Font('comicsansms', size)
I get the error:
FileNotFoundError: [Errno 2] No such file or directory: 'comicsansms'
Upvotes: 1
Views: 201
Reputation: 210876
Use pygame.font.SysFont
instead of pygame.font.Font
:
font = pygame.font.SysFont('comicsansms', size)
Or use pygame.font.match_font()
to find the path to a specific font file:
comicsansms_file = pygame.font.match_font('comicsansms')
font = pygame.font.Font(comicsansms_file, size)
Upvotes: 3