bug 1063, 1.4.0 only

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6837 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-22 23:25:27 +00:00
parent db8d0b3817
commit 40698cffaf
3 changed files with 50 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2003-04-23 John Levon <levon@movementarian.org>
* QPrefs.C:
* lyx_gui.C: fix bug 1063
2003-04-15 Angus Leeming <leeming@lyx.org>
* QLImage.C: #include lstrings.h.

View File

@ -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 <qcombobox.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qfontinfo.h>
#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()
{

View File

@ -48,6 +48,7 @@
#include <qwidget.h>
#include <qpaintdevicemetrics.h>
#include <qfont.h>
#include <qfontinfo.h>
#include <fcntl.h>
#include <cstdlib>
@ -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