Cannot change font in pygame.

This is the place for queries that don't fit in any of the other categories.

Cannot change font in pygame.

Postby dboxall123 » Sat Jul 20, 2013 11:01 am

Hello everyone!
I'm hoping that someone here can help me. I'm trying to create displayIntro() function for my first ever game. But for some reason, I can't get the font to change. Here is my code:

Code: Select all
import pygame

black=(0,0,0)
white=(255,255,255)

pygame.init()
size=(600,400)
wn=pygame.display.set_mode(size)
clock=pygame.time.Clock()

def displayIntro():
    font=pygame.font.SysFont('vgafix',200)
    label=font.render('PONG',True,white)
    wn.blit(label,(100,100))
   
#####main loop#####
done=False
while done==False:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            done=True

    wn.fill(black)
    displayIntro()

    pygame.display.flip()

    clock.tick(20)

pygame.quit()


For some reason, this will not change the font, the font remains the same as if I'd entered 'None' instead of 'vgafix'. And this is happening with every type of font I've tried, they all just display the same basic font. I just can't work out what's going wrong here! any advice would be much appreciated.
Thanks!
Dan
Last edited by micseydel on Sat Jul 20, 2013 6:59 pm, edited 1 time in total.
Reason: Added code tags.
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm

Re: Cannot change font in pygame.

Postby DrakeMagi » Sat Jul 20, 2013 1:19 pm

1. USE CODE TAGS !!

2. if it is a custom font use.
Code: Select all
myfont = pygame.font.Font(pathtofont, 200)
Linux: won't find windows here.
Linux: the choice of a GNU generation.
https://github.com/DrakeMagi
DrakeMagi
 
Posts: 109
Joined: Sun May 12, 2013 8:36 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests