]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiFontLoader.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiFontLoader.cpp
index 2dacc42d02f2d05f52ba152583890e25eb202811..9ea8e1837b8cdbcd2c0496d8567a4ef632b22601 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "LyXRC.h"
 
-#include "support/convert.h"
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
@@ -43,8 +42,6 @@ int const num_math_fonts = sizeof(math_fonts) / sizeof(*math_fonts);
 
 namespace lyx {
 
-extern docstring const stateText(FontInfo const & f);
-
 namespace frontend {
 
 /**
@@ -88,7 +85,18 @@ SymbolFont symbol_fonts[] = {
 size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_fonts[0]);
 
 /// BUTT ugly !
-static GuiFontInfo * fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE];
+static GuiFontInfo *
+fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE][NUM_STYLE];
+
+
+// returns a reference to the pointer type (GuiFontInfo *) in the
+// fontinfo_ table.
+GuiFontInfo * & fontinfo_ptr(FontInfo const & f)
+{
+       // The display font and the text font are the same
+       size_t const style = (f.style() == DISPLAY_STYLE) ? TEXT_STYLE : f.style();
+       return fontinfo_[f.family()][f.series()][f.realShape()][f.size()][style];
+}
 
 
 // Get font info (font + metrics) for the given LyX font.
@@ -106,16 +114,12 @@ GuiFontInfo & fontinfo(FontInfo const & f)
         LYXERR0("Unrealized font!");
         FontInfo f2 = f;
         f2.realize(sane_font);
-        GuiFontInfo * & fi =
-            fontinfo_[f2.family()][f2.series()][f2.realShape()][f2.size()];
+        GuiFontInfo * & fi = fontinfo_ptr(f2);
         if (!fi)
             fi = new GuiFontInfo(f2);
         return *fi;
     }
-       // fi is a reference to the pointer type (GuiFontInfo *) in the
-       // fontinfo_ table.
-       GuiFontInfo * & fi =
-               fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
+    GuiFontInfo * & fi = fontinfo_ptr(f);
        if (!fi)
                fi = new GuiFontInfo(f);
        return *fi;
@@ -228,7 +232,7 @@ QFont symbolFont(QString const & family, bool * ok)
        return font;
 }
 
-} // namespace anon
+} // namespace
 
 
 FontLoader::FontLoader()
@@ -248,7 +252,8 @@ FontLoader::FontLoader()
                for (int i2 = 0; i2 < NUM_SERIES; ++i2)
                        for (int i3 = 0; i3 < NUM_SHAPE; ++i3)
                                for (int i4 = 0; i4 < NUM_SIZE; ++i4)
-                                       fontinfo_[i1][i2][i3][i4] = 0;
+                                       for (int i5 = 0; i5 < NUM_STYLE; ++i5)
+                                               fontinfo_[i1][i2][i3][i4][i5] = 0;
 }
 
 
@@ -257,9 +262,10 @@ void FontLoader::update()
        for (int i1 = 0; i1 < NUM_FAMILIES; ++i1)
                for (int i2 = 0; i2 < NUM_SERIES; ++i2)
                        for (int i3 = 0; i3 < NUM_SHAPE; ++i3)
-                               for (int i4 = 0; i4 < NUM_SIZE; ++i4) {
-                                       delete fontinfo_[i1][i2][i3][i4];
-                                       fontinfo_[i1][i2][i3][i4] = 0;
+                               for (int i4 = 0; i4 < NUM_SIZE; ++i4)
+                                       for (int i5 = 0; i5 < NUM_STYLE; ++i5) {
+                                       delete fontinfo_[i1][i2][i3][i4][i5];
+                                       fontinfo_[i1][i2][i3][i4][i5] = 0;
                                }
 }
 
@@ -293,7 +299,7 @@ QFont makeQFont(FontInfo const & f)
                switch (f.family()) {
                case ROMAN_FAMILY: {
                        QString family = makeFontName(toqstr(lyxrc.roman_font_name),
-                               toqstr(lyxrc.roman_font_foundry)); 
+                               toqstr(lyxrc.roman_font_foundry));
                        font.setFamily(family);
 #ifdef Q_OS_MAC
 #if QT_VERSION >= 0x040300 //&& QT_VERSION < 0x040800
@@ -344,7 +350,7 @@ QFont makeQFont(FontInfo const & f)
                        break;
        }
 
-       LYXERR(Debug::FONT, "Font '" << stateText(f)
+       LYXERR(Debug::FONT, "Font '" << f.stateText()
                << "' matched by\n" << font.family());
 
        // Is this an exact match?
@@ -355,15 +361,14 @@ QFont makeQFont(FontInfo const & f)
 
        LYXERR(Debug::FONT, "XFLD: " << font.rawName());
 
-       font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
-                              * lyxrc.zoom / 100.0);
+       font.setPointSizeF(f.realSize() * lyxrc.currentZoom / 100.0);
 
        LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF());
 
        return font;
 }
 
-} // anon namespace
+} // namespace
 
 
 GuiFontInfo::GuiFontInfo(FontInfo const & f)
@@ -373,13 +378,9 @@ GuiFontInfo::GuiFontInfo(FontInfo const & f)
 
 bool FontLoader::available(FontInfo const & f)
 {
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
-       static vector<bool> cache_set(NUM_FAMILIES, false);
-       static vector<bool> cache(NUM_FAMILIES, false);
-#else
-       thread_local vector<bool> cache_set(NUM_FAMILIES, false);
-       thread_local vector<bool> cache(NUM_FAMILIES, false);
-#endif
+       // FIXME THREAD
+       static vector<int> cache_set(NUM_FAMILIES, false);
+       static vector<int> cache(NUM_FAMILIES, false);
 
        FontFamily family = f.family();
 #ifdef Q_OS_MAC