pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

Font constructor now raises an error when it fails to load a valid font file

Open oddbookworm opened this issue 1 year ago • 0 comments

Sample piece of code:

import pygame

pygame.init()

win = pygame.Window()
screen = win.get_surface()

font = pygame.font.Font("MODERN.fnt", 20)
text = font.render("Hello World!", True, "white")

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill("black")
    screen.blit(text, (0, 0))
    win.flip()

Sample font file (same file is added in the examples dir in this pull): MODERN.zip Source for the sample file

oddbookworm avatar Aug 19 '24 03:08 oddbookworm