]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/qfont_loader.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / qfont_loader.C
index 3f1d3e765ceba5acf22878133efe4146119706ab..40d79e3bc0981e6d93f83038530501675ec7078c 100644 (file)
@@ -20,6 +20,7 @@
 #include "debug.h"
 #include "lyxrc.h"
 #include "BufferView.h"
+#include "qt_helpers.h"
 
 #include <qglobal.h>
 #if QT_VERSION < 300
@@ -38,6 +39,15 @@ using std::endl;
 
 qfont_loader::qfont_loader()
 {
+       for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) {
+               for (int i2 = 0; i2 < 2; ++i2) {
+                       for (int i3 = 0; i3 < 4; ++i3) {
+                               for (int i4 = 0; i4 < 10; ++i4) {
+                                       fontinfo_[i1][i2][i3][i4] = 0;
+                               }
+                       }
+               }
+       }
 }
 
 
@@ -49,10 +59,11 @@ qfont_loader::~qfont_loader()
 void qfont_loader::update()
 {
        for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) {
-               for (int i2 = 0; i1 < 2; ++i2) {
-                       for (int i3 = 0; i1 < 4; ++i3) {
-                               for (int i4 = 0; i1 < 10; ++i4) {
-                                       fontinfo_[i1][i2][i3][i4].reset(0);
+               for (int i2 = 0; i2 < 2; ++i2) {
+                       for (int i3 = 0; i3 < 4; ++i3) {
+                               for (int i4 = 0; i4 < 10; ++i4) {
+                                       delete fontinfo_[i1][i2][i3][i4];
+                                       fontinfo_[i1][i2][i3][i4] = 0;
                                }
                        }
                }
@@ -109,7 +120,7 @@ string const symbolPattern(LyXFont::FONT_FAMILY family)
 
        default:
                return string();
-       }       
+       }
 }
 
 bool addFontPath()
@@ -125,7 +136,7 @@ bool addFontPath()
                lyxerr << "Adding " << dir << " to the font path.\n";
                string const command = "xset fp+ " + dir;
                Systemcall s;
-               if (!s.startscript(Systemcall::Wait, command)) 
+               if (!s.startscript(Systemcall::Wait, command))
                        return true;
                lyxerr << "Unable to add font path.\n";
        }
@@ -141,7 +152,7 @@ bool isAvailable(QFont const & font, LyXFont const & f) {
        if (tmp.empty())
                return false;
        else
-               return token(tmp, '-', 2) == 
+               return token(tmp, '-', 2) ==
                        token(font.rawName().latin1(), '-', 2);
 #endif
 }
@@ -163,16 +174,19 @@ qfont_loader::font_info::font_info(LyXFont const & f)
                                font.setRawName(pat.c_str());
                        }
                }
-       } else 
+       } else
                switch (f.family()) {
                case LyXFont::ROMAN_FAMILY:
-                       font.setFamily("times");
+                       font.setFamily(makeFontName(lyxrc.roman_font_name,
+                                                   lyxrc.roman_font_foundry).c_str());
                        break;
                case LyXFont::SANS_FAMILY:
-                       font.setFamily("helvetica");
+                       font.setFamily(makeFontName(lyxrc.sans_font_name,
+                                                   lyxrc.sans_font_foundry).c_str());
                        break;
                case LyXFont::TYPEWRITER_FAMILY:
-                       font.setFamily("courier");
+                       font.setFamily(makeFontName(lyxrc.typewriter_font_name,
+                                                   lyxrc.typewriter_font_foundry).c_str());
                        break;
                default:
                        break;
@@ -181,8 +195,6 @@ qfont_loader::font_info::font_info(LyXFont const & f)
        font.setPointSizeFloat(lyxrc.font_sizes[f.size()]
                               * lyxrc.zoom / 100.0);
 
-       // FIXME: lyxrc, check for failure etc.
-
        switch (f.series()) {
                case LyXFont::MEDIUM_SERIES:
                        font.setWeight(QFont::Normal);
@@ -219,10 +231,10 @@ qfont_loader::font_info const * qfont_loader::getfontinfo(LyXFont const & f)
                // FIXME
        }
 
-       font_info * fi = fontinfo_[f.family()][f.series()][f.realShape()][f.size()].get();
+       font_info const * fi = fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
        if (!fi) {
                fi = new font_info(f);
-               fontinfo_[f.family()][f.series()][f.realShape()][f.size()].reset(fi);
+               fontinfo_[f.family()][f.series()][f.realShape()][f.size()] = fi;
        }
 
        return fi;