[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] FreeSanBold Font and Screen Terminating Problems



hi,

you need to blit the text surface to the screen.

Thanks for pointing out the lack of the ttf file... I think the
installer was broken.

cheers,



On Thu, Feb 28, 2008 at 4:01 PM, Unnsse Khan <untz786@xxxxxxxxx> wrote:
> Why isn't the text drawing (or being rendered) when one runs this
>  program:
>
>
>  import pygame
>  from pygame.locals import *
>
>  def main():
>         # Initialize screen
>         pygame.init()
>         screen = pygame.display.set_mode((800,300))
>
>         pygame.display.set_caption('Basic Pygame program')
>
>         # Fill background
>         background = pygame.Surface(screen.get_size())
>         background = background.convert()
>         background.fill((250, 250, 250))
>
>         # Display some text
>         font = pygame.font.Font(None, 36)
>         text = font.render("Hello Unnsse!", 1, (10, 10, 10))
>         textpos = text.get_rect()
>         textpos.centerx = background.get_rect().centerx
>
>         # Blit everything to the screen
>         screen.blit(background, (0, 0))
>         pygame.display.flip()
>
>         # Event loop
>         while 1:
>                         for event in pygame.event.get():
>                                 if event.type == QUIT:
>                                         return
>                         screen.blit(background, (0, 0))
>                         pygame.display.flip()
>
>  if __name__ == '__main__': main()
>
>  Many, many thanks!
>
>  -Unnsse
>
>
>
>  On Feb 27, 2008, at 8:56 PM, Unnsse Khan wrote:
>
>  > I fixed it by manually moving the freesanbold.ttf file to:
>  >
>  > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
>  > packages/pygame
>  >
>  > Happy programming,
>  >
>  > Unnsse
>  >
>  > On Feb 27, 2008, at 8:38 PM, Ian Mallett wrote:
>  >
>  >> For some reason, the default pygame font is not to be found.
>  >> Your program is fine--it runs for me (and just to make sure, you
>  >> see only a white background, you aren't drawing text).
>  >> As a solution, you can locate the fonts on your computer and use
>  >> one of them.
>  >
>
>