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) {
}
// 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;
+ }
+ }
}
}
case grfx::ColorDisplay: item = 2; break;
case grfx::GrayscaleDisplay: item = 1; break;
case grfx::MonochromeDisplay: item = 0; break;
+ default: break;
}
displaymod->displayGraphicsCO->setCurrentItem(item);
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());