From 1244ad0aa1d52c86c725ffcb47aa476a6a3caab5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Oct 2016 08:57:22 +0530 Subject: [PATCH] Micro-optimization --- kitty/render.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kitty/render.py b/kitty/render.py index d3f5a00b2..891604c78 100644 --- a/kitty/render.py +++ b/kitty/render.py @@ -24,7 +24,7 @@ def ascii_width(fm: QFontMetrics) -> int: @lru_cache(maxsize=2**11) -def pixmap_for_text(text, color, default_fg, font, w, h, baseline): +def pixmap_for_text(ch, cc, color, default_fg, font, w, h, baseline): p = QPixmap(w, h) p.fill(Qt.transparent) fg = as_color(color & COL_MASK, fg_color_table()) or default_fg @@ -32,7 +32,7 @@ def pixmap_for_text(text, color, default_fg, font, w, h, baseline): painter.setFont(font) painter.setPen(QPen(QColor(*fg))) painter.setRenderHints(QPainter.TextAntialiasing | QPainter.Antialiasing) - painter.drawText(0, baseline, text) + painter.drawText(0, baseline, chr(ch) + (cc or '')) painter.end() return p @@ -257,11 +257,11 @@ class Renderer(QObject): font = self.current_font b, i = attrs & BOLD_MASK, attrs & ITALIC_MASK if b: - font = self.bi_font() if i else self.bold_font + font = self.bi_font if i else self.bold_font elif i: font = self.italic_font - text = chr(ch) + line.combining_chars.get(cnum, '') - p = pixmap_for_text(text, colors, self.default_fg, font, self.cell_width * 2, self.cell_height, self.baseline_offset) + p = pixmap_for_text(ch, line.combining_chars.get(cnum), colors & COL_MASK, + self.default_fg, font, self.cell_width * 2, self.cell_height, self.baseline_offset) painter.drawPixmap(x, y, p) def paint_cursor(self, painter, x, y):