简体   繁体   中英

draw rotated font with pygame

What's the best way to draw rotated text rendered with fonts with pygame? I can just draw the font then rotozoom it, but it seems better result would be gotten if it were possible to draw the glyphs directly rotated, especially taking AA into account?

Pygame does not have the functionality you are looking for.

You will have to use the method you mention, ie rotozoom on an the already rendered font. The quality of this method isn't all that bad actually. And concerning speed, you don't want to be rendering the fonts all the time anyway.

If you are desperate for speed, and the text isn't dynamic, you can always make a cache of ie 32 directions for each text you want displayed. Pyglet will allow you to rotate sprites for "free", ie hardware accelerated.

Or you can go look at the raw SDL libraries pygame uses and see if you can find something that draws rotated fonts directly and hack pygame to use it.

You can use a pyOpenGL surface in pygame, if that simplifies it for you. Pyglet also uses OpenGL.

(for pygame surfaces) You can cache the rendered text, using that to rotate. Or pre-cache all 32 directions. [ see other answer ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM