Ask coding questions

← Back to all posts
Is it possible to change fonts on pygame?

I've been attempting to successfully change the font for my game in pygame, but it seems that it's not working.

I'm comepletely open to the idea that I'm just not doing it right, so please feel free to give me some pointers regarding how to change fonts successfully.




Here is a page about fonts. Remember you can always look stuff up on the internet before posting on a forum :)


@ArchieMaclean Hi, sorry if this question seemed unnecessary. I recently learned you couldn't use pygame audio in, so I just wanted to be sure that this wasn't the case with fonts as well. Thanks anyways!


@ETHANSIAO Quick follow up: I just now copy-pasted that code on the page you shared with me and ran it on a repl, and sure enough it isn't working. Does this confirm that changing fonts in isn't possible, or is there something I have to do to make this work? Maybe you could share a repl successfully doing so?

My proof:

As you can see, the program clearly isn't giving the output intended. What's going on?


@ETHANSIAO The repl gives the right output for me:

What is it doing for you?


@ArchieMaclean Maybe share your repl, so @ETHANSIAO can see what you did differently.


@themaka I didn't do anything differently - I just ran @ETHANSIO's repl :|


@ArchieMaclean that's not the correct font that it was supposed to display.

Try using the comic sans program, and you'll see it doesn't display comic sans either. The following is an image of what the result is supposed to be:

This repl that exact same code, but it's still the same default font. , and definitely not comic sans, (the image above.) Also notice that it's the result of the repl is the exact same font as what you got, meaning you also got the default text as well, just as I did when I ran that program. What needs to happen for that to change? Or is it simply not possible at the moment?


@ETHANSIAO I looked at the available fonts with

and it appears that repl supports three fonts: dejavuserif, dejavusansmono, dejavusans. So repl doesn't really support fonts, except from these 3, which doesn't give much flexibility.

And I don't know what Comic Sans looks like xD


@ArchieMaclean Hi, thank you so much for the help. In case you're curious, comic sans is shown on the website that you shared with me much earlier. Again, thank you so much for the help, and have a nice day.