]> git.lyx.org Git - features.git/commitdiff
Fix the metric bug left after fixing the inset font bug
authorMartin Vermeer <martin.vermeer@hut.fi>
Tue, 12 Apr 2005 18:42:27 +0000 (18:42 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Tue, 12 Apr 2005 18:42:27 +0000 (18:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9810 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/rowpainter.C
src/text.C
src/text2.C

index 86b8a108e3cfb4ad8c993eb6b6ebbccd69895cb0..17c1b07e4101fc63b44a49e08fbb80b92c4a56ca 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-12  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * lyxtext.h:
+       * text.C (metrics): 
+       * text2.C (getFont):
+       * rowpainter.C (getFont): Fix metrics bug introduced by inset
+       fonts fix
+
 2005-04-11  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * paragraph.C (simpleTeXOnePar): add missing '}' in LaTeX
index b4bef7289d78f73f36db04a44d7b504f20242921..a8563e083ec5ad89db7279556b4f7219592967ba 100644 (file)
@@ -60,6 +60,8 @@ public:
        ///
        LyXFont getFont(Paragraph const & par, pos_type pos) const;
        ///
+       void applyOuterFont(LyXFont &) const;
+       ///
        LyXFont getLayoutFont(pit_type pit) const;
        ///
        LyXFont getLabelFont(Paragraph const & par) const;
@@ -336,7 +338,7 @@ public:
        LyXFont current_font;
        /// the current font
        LyXFont real_current_font;
-       /// our buffer's default layout font
+       /// our buffer's default layout font. This is textclass specific
        LyXFont defaultfont_;
        ///
        int background_color_;
@@ -349,7 +351,8 @@ public:
        ///
        ParagraphList pars_;
 
-       /// our 'outermost' Font
+       /// our 'outermost' font. This is handed down from the surrounding
+       // inset through the pi/mi parameter (pi.base.font)
        LyXFont font_;
 
        ///
index 13d7021b680ed6337d4c4a46035a8e02d8de871b..80e40158a181fb03a84cb1c52c81b53f7d88a310 100644 (file)
@@ -115,9 +115,6 @@ private:
        double separator_;
        double hfill_;
        double label_hfill_;
-
-       // Hack to get 1.4cvs working
-       LyXFont font_;
 };
 
 
@@ -125,7 +122,7 @@ RowPainter::RowPainter(PainterInfo & pi,
        LyXText const & text, pit_type pit, Row const & row, int x, int y)
        : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
          row_(row), pit_(pit), par_(text.paragraphs()[pit]),
-         xo_(x), yo_(y), width_(text_.width()), font_(pi.base.font)
+         xo_(x), yo_(y), width_(text_.width())
 {
        RowMetrics m = text_.computeRowMetrics(pit, row_);
        x_ = m.x + xo_;
@@ -145,12 +142,9 @@ RowPainter::RowPainter(PainterInfo & pi,
 /// "temporary"
 LyXFont const RowPainter::getFont(pos_type pos) const
 {
-       LyXFont lf(font_);
        LyXFont pf(text_.getFont(par_, pos));
-       lf.reduce(LyXFont(LyXFont::ALL_SANE));
-       lf.realize(pf); 
-       lf.setLanguage(pf.language());
-       return lf;
+       text_.applyOuterFont(pf);
+       return pf;
 }
 
 
index d28cf336eafb457d4ee02ecea21dfec65e50cea3..46237fec2331a865858e84b1cc750f1920240084 100644 (file)
@@ -1694,6 +1694,8 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
                maxwidth_ = mi.base.textwidth;
        //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
        //      << " maxWidth: " << maxwidth_ << "\nfont: " << mi.base.font << endl;
+       // save the caller's font locally:
+       font_ = mi.base.font;
 
        unsigned int h = 0;
        unsigned int w = 0;
index 053c292199e017f3bb7b8e6802ec4d5aec7c3c85..403aaf3c1abbbf4820f8858f7dcdb1099674bc5b 100644 (file)
@@ -152,7 +152,7 @@ LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
        if (!par.getDepth()) {
                LyXFont f = par.getFontSettings(params, pos);
                if (!isMainText())
-                       f.realize(font_);
+                       applyOuterFont(f);
                if (layout->labeltype == LABEL_MANUAL && pos < body_pos)
                        return f.realize(layout->reslabelfont);
                else
@@ -170,7 +170,7 @@ LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
        font.realize(layoutfont);
 
        if (!isMainText())
-               font.realize(font_);
+               applyOuterFont(font);
 
        // Realize with the fonts of lesser depth.
        font.realize(defaultfont_);
@@ -178,6 +178,21 @@ LyXFont LyXText::getFont(Paragraph const & par, pos_type const pos) const
        return font;
 }
 
+// There are currently two font mechanisms in LyX:
+// 1. The font attributes in a lyxtext, and
+// 2. The inset-specific font properties, defined in an inset's
+// metrics() and draw() methods and handed down the inset chain through
+// the pi/mi parameters, and stored locally in a lyxtext in font_.
+// This is where the two are integrated in the final fully realized
+// font.
+void LyXText::applyOuterFont(LyXFont & font) const {
+       LyXFont lf(font_);
+       lf.reduce(defaultfont_);
+       lf.realize(font);
+       lf.setLanguage(font.language());
+       font = lf;
+}
+
 
 LyXFont LyXText::getLayoutFont(pit_type const pit) const
 {