On 10 Nov 2006 at 4:32, Karlo Lozovina wrote: > My app is based on three classes, one widget class, one scene class > (something like a frame, or window in GUI world, and app class which > manages all the details. Now, the problem is that when widget class > renders fonts they look really crappy. Turning AA on/off does make a > difference in their appearance, but even with AA switched on, the > result is rather bad. > > The thing that puzzles me the most is the fact that when I render the > same font on my display surface, without using widget->scene->app > classes I get perfectly fine looking fonts :(. What could I have done > wrong so that my fonts get messed up? > > My design is as follows: widget uses its own Surface to do the > drawing, and renders text to that surface. Then, when update is needed > scene class takes widgets Surface and blits that with it's own > Surface, and then scene Surface finally gets blitted to main display > surface. > > Does anyone have any idea what could possibly go wrong during this > process? If needed, I'll attach my code later... > > Here is the code to the widget class, because I suspect that's where > my problem lies: > > --- cut here --- > class Viewport: > def __init__(self, parent, size, pos, bgimage, margin, font_path, > font_size): [snip __init__ code] > > def update(self): > text_row = 0 > for item in self.items: > item_text = self.font.render(item, 0, (249, 249, 249)) > self.canvas.blit(item_text, self.ritems.move(0, text_row)) > text_row += self.font_size + 1 > The problem is the backgound, font.canvas, is not cleared before each update. The font image is blitted onto the font image already there from the previous update. Font.render uses per-pixel alpha for anti- aliasing with a transparent background. Repeated alpha blitting makes partially transparent pixels more opaque, undoing anti-aliasing. A pygame 1.7 bug can also turn the background black.
Lenard Lindstrom <[EMAIL PROTECTED]>