pytheron pytheron - 15 days ago 5
Python Question

Text appearing low quality for unknown reason

I have 2 pieces of text which are using the exact same font settings to render.

Font:

font2 = pygame.font.SysFont(None, 18)


Text:

header_text = font2.render("Commodity", True, white)
screen.blit(header_text,(300,170))

text0 = font2.render(str(button[1]), True, white)
screen.blit(text0,(int(button[4])-100,int(button[5])+4))


Header_text is just a plain string, whereas text0 is referencing an array.

There does not seem to be any reason why these text should be rendering differently but the following image shows the first is very low quality - it's bold and has no aliasing:

example

What is going on here? Is there some kind of cache that I need to clear in python?

Answer

If you are blitting the text multiple times without redrawing, this will remove the anti-aliasing, because it will be placing partially transparent pixels on top of each other multiple times. I discovered this when programming a pause message for a game.