def test_render_blended(self): filename = RESOURCES.get_path("tuffy.ttf") font = sdlttf.open_font(filename, 10) color = SDL_Color(0, 0, 0) sf = sdlttf.render_blended(font, "Example", color) self.assertIsInstance(sf, surface.SDL_Surface) surface.free_surface(sf)
def _render_text(self): """ renders bw blended text. tinting is done in the shader. """ self.surface.fill((0,0,0,0)) i = 0 dump = False for s in self.strings: if len(s) > 0: if isinstance(self.data, dict): s = s.format(**self.data) strsurf = sdlttf.render_blended(self.font, s, SDL_Color()) # since we render with white, we can set the pixelformat # to anything that starts with 'A' and has the same bpp and amask, # thus avoiding extra blit cost # or we can just render_shaded and use that as the alpha channel. self.surface.blit(strsurf, (self.padding, self.padding + i * self.ystep)) sdlsurface.free_surface(strsurf) i += 1 self.surface.upload_tex2d(self._texture_name) self._surface_dirty = False