From 1363ab2f8f0bc56e8303f2a1673644404c41ef03 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 23 Jun 2013 19:00:30 +0000 Subject: Fix font units. On Mac OS X, QT may return 0 for certain font metrics components. --- src/gui/conversation.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gui/conversation.cc') 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. -- cgit v1.2.3