aboutsummaryrefslogtreecommitdiff
path: root/src/gui/conversation.cc
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-06-23 19:00:30 +0000
committerdos-reis <gdr@axiomatics.org>2013-06-23 19:00:30 +0000
commit1363ab2f8f0bc56e8303f2a1673644404c41ef03 (patch)
treec118b5d7a1e3282bfd706a23ad396a416a1b715b /src/gui/conversation.cc
parentd918d0a1f78696fec489c0ad7d581f9707b13df2 (diff)
downloadopen-axiom-1363ab2f8f0bc56e8303f2a1673644404c41ef03.tar.gz
Fix font units. On Mac OS X, QT may return 0 for certain font metrics components.
Diffstat (limited to 'src/gui/conversation.cc')
-rw-r--r--src/gui/conversation.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/conversation.cc b/src/gui/conversation.cc
index 64308665..6a1ecb18 100644
--- a/src/gui/conversation.cc
+++ b/src/gui/conversation.cc
@@ -1,5 +1,6 @@
-// Copyright (C) 2011, Gabriel Dos Reis.
+// Copyright (C) 2011-2013, Gabriel Dos Reis.
// All rights reserved.
+// Written by Gabriel Dos Reis.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -44,7 +45,10 @@ namespace OpenAxiom {
// associated with `w'.
static QSize font_units(const QWidget* w) {
const QFontMetrics fm = w->fontMetrics();
- return QSize(fm.maxWidth(), fm.lineSpacing());
+ const auto h = fm.lineSpacing();
+ if (auto w = fm.maxWidth())
+ return { w, h };
+ return { fm.width('W'), h };
}
// Return true if the QString `s' is morally an empty string.