Micro-optimization
This commit is contained in:
parent
410e6dc259
commit
1244ad0aa1
@ -24,7 +24,7 @@ def ascii_width(fm: QFontMetrics) -> int:
|
|||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=2**11)
|
@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 = QPixmap(w, h)
|
||||||
p.fill(Qt.transparent)
|
p.fill(Qt.transparent)
|
||||||
fg = as_color(color & COL_MASK, fg_color_table()) or default_fg
|
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.setFont(font)
|
||||||
painter.setPen(QPen(QColor(*fg)))
|
painter.setPen(QPen(QColor(*fg)))
|
||||||
painter.setRenderHints(QPainter.TextAntialiasing | QPainter.Antialiasing)
|
painter.setRenderHints(QPainter.TextAntialiasing | QPainter.Antialiasing)
|
||||||
painter.drawText(0, baseline, text)
|
painter.drawText(0, baseline, chr(ch) + (cc or ''))
|
||||||
painter.end()
|
painter.end()
|
||||||
return p
|
return p
|
||||||
|
|
||||||
@ -257,11 +257,11 @@ class Renderer(QObject):
|
|||||||
font = self.current_font
|
font = self.current_font
|
||||||
b, i = attrs & BOLD_MASK, attrs & ITALIC_MASK
|
b, i = attrs & BOLD_MASK, attrs & ITALIC_MASK
|
||||||
if b:
|
if b:
|
||||||
font = self.bi_font() if i else self.bold_font
|
font = self.bi_font if i else self.bold_font
|
||||||
elif i:
|
elif i:
|
||||||
font = self.italic_font
|
font = self.italic_font
|
||||||
text = chr(ch) + line.combining_chars.get(cnum, '')
|
p = pixmap_for_text(ch, line.combining_chars.get(cnum), colors & COL_MASK,
|
||||||
p = pixmap_for_text(text, colors, self.default_fg, font, self.cell_width * 2, self.cell_height, self.baseline_offset)
|
self.default_fg, font, self.cell_width * 2, self.cell_height, self.baseline_offset)
|
||||||
painter.drawPixmap(x, y, p)
|
painter.drawPixmap(x, y, p)
|
||||||
|
|
||||||
def paint_cursor(self, painter, x, y):
|
def paint_cursor(self, painter, x, y):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user