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 ++++++-- src/gui/conversation.h | 3 ++- src/gui/debate.cc | 1 + src/gui/debate.h | 1 + src/gui/gui.pro.in | 2 +- src/gui/main-window.cc | 1 + src/gui/main-window.h | 1 + src/gui/main.cc | 1 + 8 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src') 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. diff --git a/src/gui/conversation.h b/src/gui/conversation.h index 90f461a7..ff1a847d 100644 --- a/src/gui/conversation.h +++ b/src/gui/conversation.h @@ -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 diff --git a/src/gui/debate.cc b/src/gui/debate.cc index dbec1ae8..f96e5427 100644 --- a/src/gui/debate.cc +++ b/src/gui/debate.cc @@ -1,5 +1,6 @@ // 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 diff --git a/src/gui/debate.h b/src/gui/debate.h index 5e5356bb..1c5adf05 100644 --- a/src/gui/debate.h +++ b/src/gui/debate.h @@ -1,5 +1,6 @@ // 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 diff --git a/src/gui/gui.pro.in b/src/gui/gui.pro.in index 5dbc49bf..6969b454 100644 --- a/src/gui/gui.pro.in +++ b/src/gui/gui.pro.in @@ -1,4 +1,4 @@ -## Copyright (C) 2011 Gabriel Dos Reis. +## Copyright (C) 2011-2013 Gabriel Dos Reis. ## All rights reserved. ## Autoconf template file for the benefit of QMake ## Written by Gabriel Dos Reis. diff --git a/src/gui/main-window.cc b/src/gui/main-window.cc index caa6771c..6d3eb205 100644 --- a/src/gui/main-window.cc +++ b/src/gui/main-window.cc @@ -1,5 +1,6 @@ // 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 diff --git a/src/gui/main-window.h b/src/gui/main-window.h index 4b74828f..5e08067e 100644 --- a/src/gui/main-window.h +++ b/src/gui/main-window.h @@ -1,5 +1,6 @@ // Copyright (C) 2011, 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 diff --git a/src/gui/main.cc b/src/gui/main.cc index e6db3db6..bbbdd852 100644 --- a/src/gui/main.cc +++ b/src/gui/main.cc @@ -1,5 +1,6 @@ // 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 -- cgit v1.2.3