def draw(self, glyph: GlyphEntry, p: QPainter): """Render a glyph using the given painter.""" # Adjust the glyph coordinates to center it on origin x = self.x + glyph.x y = self.y + glyph.y if not self.fOpRedundant: p.fillRect(x, y, glyph.w, glyph.h, rgb_to_qcolor(self.fg)) p.setBrush(QBrush(rgb_to_qcolor(self.bg), glyph.bitmap)) p.setBrushOrigin(x, y) p.drawRect(x, y, glyph.w, glyph.h) if self.flAccel & SO_CHAR_INC_EQUAL_BM_BASE: self.x += glyph.w
def _brush(self, b: Brush, p: QPainter): """Configure the given brush.""" brush = None if b.index is not None: # This is a cached brush. brush = self.brushes.get(b.index) elif b.style == BrushStyle.PATTERN: pm = QPixmap.loadFromData(b.data, _fmt[b.bpp]) brush = QBrush(pm) elif b.style == BrushStyle.HATCHED: brush = QBrush(_hs[b.hatch]) else: brush = QBrush(_bs[b.style]) p.setBrush(brush) p.setBrushOrigin(b.x, b.y)