def test_font_line_skip(self): filename = RESOURCES.get_path("tuffy.ttf") last = cur = 0 for ptsize in range(-10, 10): font = sdlttf.open_font(filename, ptsize) cur = sdlttf.font_line_skip(font) self.assertGreaterEqual(cur, last) last = cur sdlttf.close_font(font) self.assertRaises((AttributeError, TypeError), sdlttf.font_line_skip, None) self.assertRaises((AttributeError, TypeError), sdlttf.font_line_skip, 1234) self.assertRaises((AttributeError, TypeError), sdlttf.font_line_skip, "test")
def __init__(self, strs, longest_str = None, active = True, font = None): self.fg = GLColor(1, 1, 1, 1) self.bg = GLColor(0, 0, 0, 0.68) self._texture_name = glGenTextures(1) self.font = font if font else a_mono_font(fgt.config.uifont) self.padding = 8 self.margin = 8 self.strings = strs if longest_str is None: longest_str_px = 0 for s in strs: sz = sdlttf.size(self.font, s)[0] if sz > longest_str_px: longest_str_px = sz else: longest_str_px = sdlttf.size(self.font, longest_str)[0] width = 2*self.padding + longest_str_px self.ystep = sdlttf.font_line_skip(self.font) height = 2*self.padding + self.ystep * len(strs) self.surface = rgba_surface(width, height) self._surface_dirty = True self.active = active self.rect = Rect(0, 0, width, height)