Try to fix pixelated console on Windows machines with small resolutions

This commit is contained in:
Alex Spataru 2024-11-07 13:58:20 -05:00
parent 549e024fe4
commit 7dd931e8a9

View File

@ -86,7 +86,7 @@ Widgets::Terminal::Terminal(QQuickItem *parent)
setAcceptedMouseButtons(Qt::AllButtons); setAcceptedMouseButtons(Qt::AllButtons);
// Set performance hints // Set performance hints
setMipmap(true); setMipmap(false);
setOpaquePainting(true); setOpaquePainting(true);
// Set font // Set font
@ -159,9 +159,13 @@ Widgets::Terminal::Terminal(QQuickItem *parent)
void Widgets::Terminal::paint(QPainter *painter) void Widgets::Terminal::paint(QPainter *painter)
{ {
// Skip if item is not visible // Skip if item is not visible
if (!isVisible()) if (!isVisible() || !painter)
return; return;
// Set painter flags
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setRenderHint(QPainter::TextAntialiasing, true);
// Set font and prepare painter // Set font and prepare painter
painter->setFont(m_font); painter->setFont(m_font);
int lineHeight = m_cHeight; int lineHeight = m_cHeight;
@ -626,6 +630,9 @@ void Widgets::Terminal::setFont(const QFont &font)
// Update font // Update font
m_font = font; m_font = font;
// Ensure that antialiasing is enabled
m_font.setStyleStrategy(QFont::PreferAntialias);
// Get size of font (in pixels) // Get size of font (in pixels)
auto metrics = QFontMetrics(font); auto metrics = QFontMetrics(font);