Fix default fonts in RH8.0. We use the style hint after all else fails

in order to find a reasonable font.

Note that StyleSerif does not work. I blame RedHat 8.0 personally,
but cannot verify yet.

Note also that in a sane world, we could just use font.setFamily(blah);
QFontInfo(font).family() and set to that. But Qt is obviously not sane, so
we stay with the weird setComboxFont() code we have :(


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5869 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-12-19 03:22:33 +00:00
parent 8ba465c7da
commit adbf4d7f68
2 changed files with 28 additions and 10 deletions

View File

@ -1,3 +1,8 @@
2002-12-19 John Levon <levon@movementarian.org>
* QPrefs.C: if we can't find the font family, use
StyleHint to get one close by
2002-12-18 Alfredo Braunstein <abraunst@libero.it>
* QRef.C (redoRefs): small bug fix (wrong label was selected)

View File

@ -305,10 +305,9 @@ findPos(std::vector<A> const & vec, A const & val)
return std::distance(vec.begin(), it);
}
void setComboxFont(QComboBox * cb,
string const & family, string const & foundry)
void setComboxFont(QComboBox * cb, string const & family,
string const & foundry, QFont::StyleHint hint)
{
string const name = makeFontName(family, foundry);
for (int i = 0; i < cb->count(); ++i) {
if (fromqstr(cb->text(i)) == name) {
@ -318,14 +317,27 @@ void setComboxFont(QComboBox * cb,
}
// Try matching without foundary name
// We count in reverse in order to prefer the Xft foundry
for (int i = cb->count() - 1; i >= 0; --i) {
// We count in reverse in order to prefer the Xft foundry
pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
if (compare_no_case(tmp.first, family) == 0) {
cb->setCurrentItem(i);
return;
}
}
// Try the hint
QFont font;
font.setStyleHint(hint);
QFontInfo fi(font);
for (int i = cb->count() - 1; i >= 0; --i) {
if (cb->text(i) == fi.family()) {
cb->setCurrentItem(i);
return;
}
}
}
}
@ -411,6 +423,7 @@ void QPrefs::update_contents()
case grfx::ColorDisplay: item = 2; break;
case grfx::GrayscaleDisplay: item = 1; break;
case grfx::MonochromeDisplay: item = 0; break;
default: break;
}
displaymod->displayGraphicsCO->setCurrentItem(item);
@ -465,12 +478,12 @@ void QPrefs::update_contents()
QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
setComboxFont(fontmod->screenRomanCO,
rc.roman_font_name, rc.roman_font_foundry);
setComboxFont(fontmod->screenSansCO,
rc.sans_font_name, rc.sans_font_foundry);
setComboxFont(fontmod->screenTypewriterCO,
rc.typewriter_font_name, rc.typewriter_font_foundry);
setComboxFont(fontmod->screenRomanCO, rc.roman_font_name,
rc.roman_font_foundry, QFont::Serif);
setComboxFont(fontmod->screenSansCO, rc.sans_font_name,
rc.sans_font_foundry, QFont::SansSerif);
setComboxFont(fontmod->screenTypewriterCO, rc.typewriter_font_name,
rc.typewriter_font_foundry, QFont::TypeWriter);
dialog_->select_roman(fontmod->screenRomanCO->currentText());
dialog_->select_sans(fontmod->screenSansCO->currentText());