]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiFontLoader.C
This commit is a big rework of the FontLoader/FontMetrics interaction. Only Qt4 for...
[features.git] / src / frontends / qt4 / GuiFontLoader.C
index e75bbad8490eddc3ed7a2aa976ee8ddcac5845c1..f98c4a7324e33ee8e8df95c6f5681534705ac7f7 100644 (file)
@@ -220,9 +220,7 @@ void GuiFontLoader::update()
 
 
 QLFontInfo::QLFontInfo(LyXFont const & f)
-       : metrics(font)
 {
-
        string const pat = symbolFamily(f.family());
        if (!pat.empty()) {
                bool tmp;
@@ -246,9 +244,6 @@ QLFontInfo::QLFontInfo(LyXFont const & f)
                }
        }
 
-       font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
-                              * lyxrc.zoom / 100.0);
-
        switch (f.series()) {
                case LyXFont::MEDIUM_SERIES:
                        font.setWeight(QFont::Normal);
@@ -274,9 +269,6 @@ QLFontInfo::QLFontInfo(LyXFont const & f)
                        << "' matched by\n" << fromqstr(font.rawName()) << endl;
        }
 
-       lyxerr[Debug::FONT] << "The font has size: "
-                           << font.pointSizeF() << endl;
-
        // Is this an exact match?
        if (font.exactMatch())
                lyxerr[Debug::FONT] << "This font is an exact match" << endl;
@@ -286,21 +278,27 @@ QLFontInfo::QLFontInfo(LyXFont const & f)
 
        lyxerr[Debug::FONT] << "XFLD: " << fromqstr(font.rawName()) << endl;
 
-       metrics = QFontMetrics(font);
-}
+       font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
+                              * lyxrc.zoom / 100.0);
 
-#ifdef USE_LYX_FONTCACHE
-int QLFontInfo::width(Uchar val)
-{
-       QLFontInfo::WidthCache::const_iterator cit = widthcache.find(val);
-       if (cit != widthcache.end())
-               return cit->second;
+       lyxerr[Debug::FONT] << "The font has size: "
+                           << font.pointSizeF() << endl;
+
+       if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+               metrics.reset(new GuiFontMetrics(font));
+       }
+       else {  
+               // handle small caps ourselves ...
+               LyXFont smallfont = f;
+               smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+               QFont font2(font);
+               font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()])
+                              * lyxrc.zoom / 100.0);
+
+               metrics.reset(new GuiFontMetrics(font, font2));
+       }
 
-       int const w = metrics.width(QChar(val));
-       widthcache[val] = w;
-       return w;
 }
-#endif
 
 
 bool GuiFontLoader::available(LyXFont const & f)