]> git.lyx.org Git - features.git/commitdiff
Fix default fonts in RH8.0. We use the style hint after all else fails
authorJohn Levon <levon@movementarian.org>
Thu, 19 Dec 2002 03:22:33 +0000 (03:22 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 19 Dec 2002 03:22:33 +0000 (03:22 +0000)
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

src/frontends/qt2/ChangeLog
src/frontends/qt2/QPrefs.C

index 3d823f556a09a96bca0b9ed39f4ed3dcb079a4e9..776c531377e333e60e6eb9f9cf78d33664dca3d9 100644 (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)
index a09cac151f34e8d8a5880cd933fea0dabb2605c2..b2e559a3e63c36158b6b3a0af928a4a67f06404e 100644 (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());