I have read this post about centering text: Pygame - How to Center Text
However instead of importing text from a file:
font = pygame.font.Font("example_font.tff", 25)
I want to use a font from the users system
font = pygame.freetype.SysFont("comicsansms", 0)
using the freetype module as I think it makes rendering to various sizes easier (like when the user resizes the window)
font.render_to(surface, pos, ..., size=int(surface.get_height()/2))
Im not sure how to set a value for pos where the text will be shown in the center of the surface, as I can't .get_rect()
or anything to get the dimensions of the text
Possible solutions?
Getting the dimensions of the text
Using System Fonts with pygame.font.Font()
Thanks!