plsHelpMe
plsHelpMe

Reputation: 17

I can't use the available fonts in pygame

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

Answers (1)

Rabbid76
Rabbid76

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

Related Questions