John Liu
John Liu

Reputation: 172

Pygame text displays wrong fonts

I am using pygame to make a game, and I want to display some text, but the font doesn't change to any fonts that I've downloaded. I am using a Mac and the font that I downloaded appears in Font Book. I've used pygame.font.init, define the font as font = pygame.font.SysFont('font name', size), and use font.render(message, False, colour).

When defining the font, I tried using both the absolute and relative paths. When I run the program, it displays the text in the default font instead of the font I have downloaded. Why does this happen?

Upvotes: 2

Views: 319

Answers (1)

Pzet
Pzet

Reputation: 490

Use pygame.font.Font() instead of SysFont to use downloaded fonts Using this syntax:

font = pygame.font.Font("font name/path", size)

use the font.render() function to create a font surface you can display:

font.render(yourMessage, True/False, colour)

Upvotes: 3

Related Questions