Code

Rendering a Font Object in Pygame

You can use the render() function to render the font object into a surface object which can then be blitted onto the screen using surface.blit(). Render takes in the text, a bool for using anti-aliasing, and a tuple for the rgb color value.

newFont = pygame.font.Font("times-new-roman.ttf", 15) playerName = newFont.render("John Doe", True, (0,0,255)) mainScreen = pygame.display.set_mode((900, 900)) mainScreen.blit(playerName, (60, 60))

0

1

Updated 2021-08-02

Tags

Python Programming Language

Data Science