CTPUG/pygame_cffi

Too many open files error (fonts related).

Closed this issue · 2 comments

A lot of games written with pygame uses functions like this:

    @staticmethod
    def display_single_line(line, x, y, screen):
        """Displays a single line of text on Battle screen"""
        txt = pygame.font.Font(None, 36)
        render = txt.render(line[0:13], 0, (255, 255, 255))
        screen.blit(render, (x, y))

So font file being opened every time when function is called. But this error doesn't happen in PyGame.
Maybe we should add caching or something like it?

Tx.