aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-05-07 21:50:00 +0200
committerMichael Mann <mmann78@netscape.net>2017-05-08 03:07:43 +0000
commitab504191fccdb7db1d9559ac0592f22872586133 (patch)
tree7b793e999db0ecdacdeeca4ec858ec45d577f8ba /ui
parentee37135c67c7dfc3339dec7d13e665da56867b7c (diff)
Qt: try harder to find a working monospace font
QFont::toString returned the default font (which might be unavailable), leading to use of non-monospace fonts in the bytes view. Detect the effective font instead and apply it to avoid this issue. Add additional logic to invoke font detection when the configured font is bad (for example, because of the bug or because a font has been removed in meantime). Bug: 13638 Change-Id: I8a625cf365c90119caebe8c4deada0df7426e53a Reviewed-on: https://code.wireshark.org/review/21551 Reviewed-by: Jörg Mayer <jmayer@loplof.de> Petri-Dish: Jörg Mayer <jmayer@loplof.de> Tested-by: Jörg Mayer <jmayer@loplof.de> Reviewed-by: Ahmad Fatoum <ahmad@a3f.at> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/wireshark_application.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index dfffc9748b..93fb1ec675 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -86,6 +86,7 @@
#include <QEvent>
#include <QFileOpenEvent>
#include <QFontMetrics>
+#include <QFontInfo>
#include <QLibraryInfo>
#include <QLocale>
#include <QMutableListIterator>
@@ -274,7 +275,11 @@ void WiresharkApplication::setMonospaceFont(const char *font_string) {
if (font_string && strlen(font_string) > 0) {
mono_font_.fromString(font_string);
- return;
+
+ // Only accept the font name if it actually exists.
+ if (mono_font_.family() == QFontInfo(mono_font_).family()) {
+ return;
+ }
}
// http://en.wikipedia.org/wiki/Category:Monospaced_typefaces
@@ -313,6 +318,9 @@ void WiresharkApplication::setMonospaceFont(const char *font_string) {
mono_font_.setPointSize(wsApp->font().pointSize() + font_size_adjust);
mono_font_.setBold(false);
+ // Retrieve the effective font and apply it.
+ mono_font_.setFamily(QFontInfo(mono_font_).family());
+
g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = qstring_strdup(mono_font_.toString());
}