From 383434b3a9fed95ada6e20fff7cf9a8e193d1a46 Mon Sep 17 00:00:00 2001 From: Mariusz Glebocki Date: Tue, 23 Oct 2018 20:38:52 -0400 Subject: [PATCH] Edit Profile Dialog: Fix "Smooth fonts" preview Summary: `setStyleHint()` resets `styleStrategy` (which has information about font smoothing) when the second argument is missing. Test Plan: * {nav Settings > Edit current profile... > Appearance} * Unselect/select "Smooth fonts" checkbox **Actual result:** text rendering in the main terminal window does not change. **Expected result:** text rendering in the main terminal window should use smoothing or not, depending on the checkbox state. The option change should be visible instantly, without clicking OK or Apply. Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: hindenburg, konsole-devel Tags: #konsole Differential Revision: https://phabricator.kde.org/D16361 --- src/EditProfileDialog.cpp | 1 + src/TerminalDisplay.cpp | 37 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index ec26055c..5d7ede6c 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -624,6 +624,7 @@ void EditProfileDialog::setAntialiasText(bool enable) // update preview to reflect text smoothing state fontSelected(profileFont); + preview(Profile::AntiAliasFonts, enable); updateTempProfileProperty(Profile::AntiAliasFonts, enable); } diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 5b437937..84826735 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -240,10 +240,7 @@ void TerminalDisplay::fontChange(const QFont&) void TerminalDisplay::setVTFont(const QFont& f) { QFont newFont(f); - - // In case the provided font doesn't have some specific characters it should - // fall back to a Monospace fonts. - newFont.setStyleHint(QFont::TypeWriter); + int strategy = 0; QFontMetrics fontMetrics(newFont); @@ -257,38 +254,38 @@ void TerminalDisplay::setVTFont(const QFont& f) return; } - // hint that text should be drawn without anti-aliasing. + // hint that text should be drawn with- or without anti-aliasing. // depending on the user's font configuration, this may not be respected - if (!_antialiasText) { - newFont.setStyleStrategy(QFont::StyleStrategy(newFont.styleStrategy() | QFont::NoAntialias)); - } - - // experimental optimization. Konsole assumes that the terminal is using a - // mono-spaced font, in which case kerning information should have an effect. - // Disabling kerning saves some computation when rendering text. - newFont.setKerning(false); + strategy |= _antialiasText ? QFont::PreferAntialias : QFont::NoAntialias; // Konsole cannot handle non-integer font metrics - newFont.setStyleStrategy(QFont::StyleStrategy(newFont.styleStrategy() | QFont::ForceIntegerMetrics)); + strategy |= QFont::ForceIntegerMetrics; + + // In case the provided font doesn't have some specific characters it should + // fall back to a Monospace fonts. + newFont.setStyleHint(QFont::TypeWriter, QFont::StyleStrategy(strategy)); // Try to check that a good font has been loaded. // For some fonts, ForceIntegerMetrics causes height() == 0 which // will cause Konsole to crash later. QFontMetrics fontMetrics2(newFont); - if ((fontMetrics2.height() < 1)) { + if (fontMetrics2.height() < 1) { qCDebug(KonsoleDebug)<<"The font "<