/ Published in: Python
A quick first test case in which I use aggdraw for rendering text to a pygame Surface. Pygame's font-rendering doesn't work properly cross-platform, and this looks promising. I'll need to integrate the AGG canvas more tightly with the pygame Surface, but I think it'll work out.
Expand |
Embed | Plain Text
import aggdraw as ag import pygame as pg class TextPainter(Painter): def __init__(self, text, *args, **kwds): Painter.__init__(self, *args, **kwds) self.text = text self.canvas = ag.Draw("RGB", (self.width, self.height), ColourScheme.background) self.font = ag.Font(ColourScheme.text, os.path.join("..", "gfx", "slkscr.ttf"), 8) self.canvas.text((0, 0), self.text, self.font) self.surf = pg.image.fromstring(self.canvas.tostring(), (self.width, self.height), "RGB") self.window = Window() self.window.addPainter(self) def paint(self): self.window.blit(self.surf, (self.xPos, self.yPos))
You need to login to post a comment.
