def render(self, size, focus=False): fixed_size(size) # complain if parameter is wrong a = None ai = ak = 0 o = [] rows = self.font.height attrib = self.attrib + [(None, len(self.text))] for ch in self.text: if not ak: a, ak = attrib[ai] ai += 1 ak -= 1 width = self.font.char_width(ch) if not width: # ignore invalid characters continue c = self.font.render(ch) if a is not None: c = CompositeCanvas(c) c.fill_attr(a) o.append((c, None, False, width)) if o: canv = CanvasJoin(o) else: canv = TextCanvas([""] * rows, maxcol=0, check_width=False) canv = CompositeCanvas(canv) canv.set_depends([]) return canv
def render(self, c): if c in self.canvas: return self.canvas[c] width, l = self.char[c] tl = [] csl = [] for d in l: t, cs = apply_target_encoding(d) tl.append(t) csl.append(cs) canv = TextCanvas(tl, None, csl, maxcol=width, check_width=False) self.canvas[c] = canv return canv