]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiFontLoader.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiFontLoader.cpp
index b6b03be610f2313e76d01e7ade8d82400aee8c34..6ec0bc508d366cac2ce7b1a3c4f116151c6ad37c 100644 (file)
 #include "GuiFontLoader.h"
 #include "qt_helpers.h"
 
-#include "debug.h"
 #include "LyXRC.h"
 
 #include "support/convert.h"
+#include "support/debug.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 #include "support/Systemcall.h"
 #include "support/Package.h"
 #include "support/os.h"
 
-#include <boost/tuple/tuple.hpp>
-
 #include <QFontInfo>
 #include <QFontDatabase>
 
-using std::endl;
-using std::make_pair;
-
-using std::pair;
-using std::vector;
+using namespace std;
+using namespace lyx::support;
 
 QString const math_fonts[] = {"cmex10", "cmmi10", "cmr10", "cmsy10",
        "eufm10", "msam10", "msbm10", "wasy10", "esint10"};
@@ -42,11 +37,6 @@ int const num_math_fonts = sizeof(math_fonts) / sizeof(*math_fonts);
 
 namespace lyx {
 
-using support::contains;
-using support::package;
-using support::addPath;
-using support::addName;
-
 extern docstring const stateText(FontInfo const & f);
 
 namespace frontend {
@@ -150,7 +140,7 @@ static bool isChosenFont(QFont & font, QString const & family)
 }
 
 
-static pair<QFont, bool> const getSymbolFont(QString const & family)
+QFont symbolFont(QString const & family, bool * ok)
 {
        LYXERR(Debug::FONT, "Looking for font family "
                << fromqstr(family) << " ... ");
@@ -163,7 +153,8 @@ static pair<QFont, bool> const getSymbolFont(QString const & family)
 
        if (isChosenFont(font, family)) {
                LYXERR(Debug::FONT, "normal!");
-               return make_pair<QFont, bool>(font, true);
+               *ok = true;
+               return font;
        }
 
        LYXERR(Debug::FONT, "Trying " << fromqstr(upper) << " ... ");
@@ -171,7 +162,8 @@ static pair<QFont, bool> const getSymbolFont(QString const & family)
 
        if (isChosenFont(font, upper)) {
                LYXERR(Debug::FONT, "upper!");
-               return make_pair<QFont, bool>(font, true);
+               *ok = true;
+               return font;
        }
 
        // A simple setFamily() fails on Qt 2
@@ -182,11 +174,13 @@ static pair<QFont, bool> const getSymbolFont(QString const & family)
 
        if (isChosenFont(font, family)) {
                LYXERR(Debug::FONT, "raw version!");
-               return make_pair<QFont, bool>(font, true);
+               *ok = true;
+               return font;
        }
 
        LYXERR(Debug::FONT, " FAILED :-(");
-       return make_pair<QFont, bool>(font, false);
+       *ok = false;
+       return font;
 }
 
 } // namespace anon
@@ -227,6 +221,11 @@ void GuiFontLoader::update()
 }
 
 
+GuiFontLoader::~GuiFontLoader()
+{
+       update();
+}
+
 /////////////////////////////////////////////////
 
 
@@ -240,12 +239,13 @@ static QString makeFontName(QString const & family, QString const & foundry)
 
 
 GuiFontInfo::GuiFontInfo(FontInfo const & f)
+       : metrics(QFont())
 {
        font.setKerning(false);
        QString const pat = symbolFamily(f.family());
        if (!pat.isEmpty()) {
-               bool tmp;
-               boost::tie(font, tmp) = getSymbolFont(pat);
+               bool ok;
+               font = symbolFont(pat, &ok);
        } else {
                switch (f.family()) {
                case ROMAN_FAMILY: {
@@ -313,7 +313,7 @@ GuiFontInfo::GuiFontInfo(FontInfo const & f)
        LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF());
 
        if (f.realShape() != SMALLCAPS_SHAPE) {
-               metrics.reset(new GuiFontMetrics(font));
+               metrics = GuiFontMetrics(font);
        } else {
                // handle small caps ourselves ...
                FontInfo smallfont = f;
@@ -323,9 +323,8 @@ GuiFontInfo::GuiFontInfo(FontInfo const & f)
                font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()])
                               * lyxrc.zoom / 100.0);
 
-               metrics.reset(new GuiFontMetrics(font, font2));
+               metrics = GuiFontMetrics(font, font2);
        }
-
 }
 
 
@@ -344,8 +343,9 @@ bool GuiFontLoader::available(FontInfo const & f)
                // We don't care about non-symbol fonts
                return false;
 
-       pair<QFont, bool> tmp = getSymbolFont(pat);
-       if (!tmp.second)
+       bool ok;
+       symbolFont(pat, &ok);
+       if (!ok)
                return false;
 
        cache[family] = true;