user2764859
user2764859

Reputation: 23

How to change font object size in pygame

I have these code

FONT = pygame.font.Font("font/calibri.ttf", 50)
FONT.size = 25

but the compilter say

AttributeError: 'pygame.font.FONT' object attribute 'size' is read-only

I see no method help me change size. How can I do that?

Upvotes: 2

Views: 6617

Answers (1)

sloth
sloth

Reputation: 101042

You can't change the size of an existing Font object. You have to create a new Font object with the size you want.


An alternative is the newer freetype module. The render methods of the Font class in this module support text rendering using a different size.

Upvotes: 6

Related Questions