Skip to content

Instantly share code, notes, and snippets.

@SteveClement
Created February 19, 2015 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveClement/34ffd8959cff02908d0b to your computer and use it in GitHub Desktop.
Save SteveClement/34ffd8959cff02908d0b to your computer and use it in GitHub Desktop.
Simple font example
#!/usr/bin/env python3
import pygame, time
from pygame.locals import *
done = False
pygame.init()
pygame.font.init()
screen = pygame.display.set_mode((320,240))
fontobject = pygame.font.Font(None ,24)
all_fonts = pygame.font.get_fonts()
print(all_fonts)
# Try to play around with other fonts, it failed for me :(
#fontobject = pygame.font.Font("gillsans" ,24)
message = "Hi Alice, enjoy your day and code well"
# Make screen black
screen.fill((0, 0, 0))
# Endless loop until clicked on window X or Keyboard ESC
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
done = True
# Actually draw the stuff to the screen
screen.blit(fontobject.render(message, True, (255,255,255)), (0 , 0 ))
pygame.display.flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment