pyGame fonts

Wade Brainerd wadetb at gmail.com
Thu Jan 17 10:26:04 EST 2008


Hi Ken, PyGame provides a font module which can render text onto a surface.


from gettext import gettext as _

    font = pygame.font.Font(None, 36)

    surf = font.render(_("Hello, world!"), 1, (255,255,255))
    pos = surf.get_rect(centerx=Pos[0], centery=Pos[1])
    screen.blit(surf, pos)

The _() around the text indicates that the string is to be localized, it
will be extracted and placed in a database by the gettext utility.

You can then blit the surface to the screen.  See
http://www.pygame.org/docs/ref/font.html for more information.

Wade

On Jan 16, 2008 7:00 PM, Kent Loobey <kent at uoregon.edu> wrote:

> Hi All,
>
> I have programmed for years but am new to Python and localization.
>
> I am clueless at this point on how to get/use fonts within Python.  I am
> also
> clueless as to what process to use to make sure that the fonts can be
> localized.
>
> Is there some sample code around that demonstrates how this is done within
> the
> OLPC Universe?
>
> Thanks.
>
> Kent
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.laptop.org/pipermail/devel/attachments/20080117/b66e6a1d/attachment.html>


More information about the Devel mailing list