From 40698cffaf7079f68a9151317efe5226f873f84b Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 22 Apr 2003 23:25:27 +0000 Subject: [PATCH] bug 1063, 1.4.0 only git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6837 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QPrefs.C | 39 ++++++++++++++++++++++++++++++++++++- src/frontends/qt2/lyx_gui.C | 13 +++++++------ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index a8b5a9afff..5316b32076 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2003-04-23 John Levon + + * QPrefs.C: + * lyx_gui.C: fix bug 1063 + 2003-04-15 Angus Leeming * QLImage.C: #include lstrings.h. diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index ed4c595447..8d811d8b0a 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -31,6 +31,7 @@ #include "ui/QPrefPrinterModule.h" #include "ui/QPrefUIModule.h" #include "ui/QPrefIdentityModule.h" +#include "lyx_gui.h" #include "QPrefs.h" #include "Qt2BC.h" #include "lyxrc.h" @@ -48,6 +49,7 @@ #include #include #include +#include #include "qcoloritem.h" using std::vector; @@ -345,9 +347,44 @@ void setComboxFont(QComboBox * cb, string const & family, string const & foundry return; } } + + // Bleh, default fonts, and the names couldn't be found. Hack + // for bug 1063. Qt makes baby Jesus cry. + + QFont font; + + if (family == lyx_gui::roman_font_name()) { + font.setStyleHint(QFont::Serif); + font.setFamily(lyx_gui::roman_font_name().c_str()); + } else if (family == lyx_gui::sans_font_name()) { + font.setStyleHint(QFont::SansSerif); + font.setFamily(lyx_gui::sans_font_name().c_str()); + } else if (family == lyx_gui::typewriter_font_name()) { + font.setStyleHint(QFont::TypeWriter); + font.setFamily(lyx_gui::typewriter_font_name().c_str()); + } else { + lyxerr << "FAILED to find the default font !" + << foundry << ", " << family << endl; + return; + } + + QFontInfo info(font); + lyxerr << "Apparent font is " << info.family() << endl; + + for (int i = 0; i < cb->count(); ++i) { + lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl; + if (compare_no_case(cb->text(i).latin1(), info.family().latin1()) == 0) { + cb->setCurrentItem(i); + return; + } + } + + lyxerr << "FAILED to find the font !" + << foundry << ", " << family << endl; } -} +} // end namespace anon + void QPrefs::update_contents() { diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index 544c9556c8..4a754dea7b 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -252,9 +253,9 @@ string const roman_font_name() return "serif"; QFont font; - font.setFamily("serif"); font.setStyleHint(QFont::Serif); - return font.family().latin1(); + font.setFamily("serif"); + return QFontInfo(font).family().latin1(); } @@ -264,9 +265,9 @@ string const sans_font_name() return "sans"; QFont font; - font.setFamily("sans"); font.setStyleHint(QFont::SansSerif); - return font.family().latin1(); + font.setFamily("sans"); + return QFontInfo(font).family().latin1(); } @@ -276,9 +277,9 @@ string const typewriter_font_name() return "monospace"; QFont font; - font.setFamily("monospace"); font.setStyleHint(QFont::TypeWriter); - return font.family().latin1(); + font.setFamily("monospace"); + return QFontInfo(font).family().latin1(); } }; // namespace lyx_gui