]> git.lyx.org Git - features.git/commitdiff
cleanup/compile fix
authorAndré Pönitz <poenitz@gmx.net>
Thu, 20 Mar 2008 00:19:10 +0000 (00:19 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 20 Mar 2008 00:19:10 +0000 (00:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23843 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiFontLoader.cpp
src/frontends/qt4/GuiFontLoader.h
src/frontends/qt4/GuiPainter.cpp

index 3fde5a096836836fa1e6c82a94b76076fe417686..3759fbf3cdebcdb5f6576ff160140cc44f7d7a6b 100644 (file)
@@ -14,7 +14,7 @@
 #include "FontLoader.h"
 
 #include "FontInfo.h"
-#include "GuiFontLoader.h"
+#include "GuiFontMetrics.h"
 #include "qt_helpers.h"
 
 #include "LyXRC.h"
@@ -45,6 +45,21 @@ extern docstring const stateText(FontInfo const & f);
 
 namespace frontend {
 
+/**
+ * Matches Fonts against
+ * actual QFont instances, and also caches metrics.
+ */
+class GuiFontInfo
+{
+public:
+       GuiFontInfo(FontInfo const & f);
+
+       /// The font instance
+       QFont font;
+       /// Metrics on the font
+       GuiFontMetrics metrics;
+};
+
 namespace {
 
 struct SymbolFont {
@@ -193,9 +208,9 @@ QFont symbolFont(QString const & family, bool * ok)
 
        // A simple setFamily() fails on Qt 2
 
-       QString const rawName = rawName(family);
-       LYXERR(Debug::FONT, "Trying " << fromqstr(rawName) << " ... ");
-       font.setRawName(rawName);
+       QString const raw = rawName(family);
+       LYXERR(Debug::FONT, "Trying " << fromqstr(raw) << " ... ");
+       font.setRawName(raw);
 
        if (isChosenFont(font, family)) {
                LYXERR(Debug::FONT, "raw version!");
@@ -377,21 +392,22 @@ bool FontLoader::available(FontInfo const & f)
        return true;
 }
 
+
 FontMetrics const & FontLoader::metrics(FontInfo const & f)
 {
        return fontinfo(f).metrics;
 }
 
-/// Get the QFont for this FontInfo
-QFont const & getFont(FontInfo const & f)
+
+GuiFontMetrics const & getFontMetrics(FontInfo const & f)
 {
-       return fontinfo(f).font;
+       return fontinfo(f).metrics;
 }
 
-/// Get the QFont for this FontInfo
-GuiFontInfo const & getFontInfo(FontInfo const & f)
+
+QFont const & getFont(FontInfo const & f)
 {
-       return fontinfo(f);
+       return fontinfo(f).font;
 }
 
 } // namespace frontend
index 1d09b6d616cad0af957c37786be2e9369cbd0df6..35be5eae11add1ffb7942d0f6397f856ed3ee182 100644 (file)
 #ifndef GUI_FONTLOADER_H
 #define GUI_FONTLOADER_H
 
-#include "GuiFontMetrics.h"
-
-#include <QFont>
+class QFont;
 
 namespace lyx {
 namespace frontend {
 
-/**
- * Qt font loader for LyX. Matches Fonts against
- * actual QFont instances, and also caches metrics.
- */
-class GuiFontInfo
-{
-public:
-       GuiFontInfo(FontInfo const & f);
-
-       /// The font instance
-       QFont font;
-       /// Metrics on the font
-       GuiFontMetrics metrics;
-};
-
+class GuiFontMetrics;
 
-// Load font
-GuiFontInfo const & getFontInfo(FontInfo const & f);
+/// Metrics on the font
+GuiFontMetrics const & getFontMetrics(FontInfo const & f);
 /// Get the QFont for this FontInfo
 QFont const & getFont(FontInfo const & f);
 
index 7c0af8bd9eac41e51143f42876f0fde7f5befcae..2499b0eb4ceafc92f44a1691a4b8185b15ca82e3 100644 (file)
@@ -319,7 +319,8 @@ int GuiPainter::text(int x, int y, docstring const & s,
                str = ' ' + str;
 #endif
 
-       GuiFontInfo const & fi = getFontInfo(f);
+       QFont const & ff = getFont(f); 
+       GuiFontMetrics const & fm = getFontMetrics(f); 
 
        int textwidth;
 
@@ -333,7 +334,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
        // Here we use the font width cache instead of
        //   textwidth = fontMetrics().width(str);
        // because the above is awfully expensive on MacOSX
-       textwidth = fi.metrics.width(s);
+       textwidth = fm.width(s);
        if (f.underbar() == FONT_ON)
                underline(f, x, y, textwidth);
 
@@ -347,7 +348,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
        if (s.size() == 1 && str[0].unicode() == 0x00ad) {
                setQPainterPen(computeColor(f.realColor()));
                QTextLayout adsymbol(str);
-               adsymbol.setFont(fi.font);
+               adsymbol.setFont(ff);
                adsymbol.beginLayout();
                QTextLine line = adsymbol.createLine();
                line.setNumColumns(1);
@@ -361,8 +362,8 @@ int GuiPainter::text(int x, int y, docstring const & s,
                // don't use the pixmap cache,
                // draw directly onto the painting device
                setQPainterPen(computeColor(f.realColor()));
-               if (font() != fi.font)
-                       setFont(fi.font);
+               if (font() != ff)
+                       setFont(ff);
                // We need to draw the text as LTR as we use our own bidi code.
                setLayoutDirection(Qt::LeftToRight);
                drawText(x, y, str);
@@ -379,22 +380,22 @@ int GuiPainter::text(int x, int y, docstring const & s,
        // Only the left bearing of the first character is important
        // as we always write from left to right, even for
        // right-to-left languages.
-       int const lb = min(fi.metrics.lbearing(s[0]), 0);
-       int const mA = fi.metrics.maxAscent();
+       int const lb = min(fm.lbearing(s[0]), 0);
+       int const mA = fm.maxAscent();
        if (!QPixmapCache::find(key, pm)) {
                // Only the right bearing of the last character is
                // important as we always write from left to right,
                // even for right-to-left languages.
-               int const rb = fi.metrics.rbearing(s[s.size()-1]);
+               int const rb = fm.rbearing(s[s.size()-1]);
                int const w = textwidth + rb - lb;
-               int const mD = fi.metrics.maxDescent();
+               int const mD = fm.maxDescent();
                int const h = mA + mD;
                pm = QPixmap(w, h);
                pm.fill(Qt::transparent);
                GuiPainter p(&pm);
                p.setQPainterPen(computeColor(f.realColor()));
-               if (p.font() != fi.font)
-                       p.setFont(fi.font);
+               if (p.font() != ff)
+                       p.setFont(ff);
                // We need to draw the text as LTR as we use our own bidi code.
                p.setLayoutDirection(Qt::LeftToRight);
                p.drawText(-lb, mA, str);