From: Martin Vermeer Date: Tue, 12 Apr 2005 18:42:27 +0000 (+0000) Subject: Fix the metric bug left after fixing the inset font bug X-Git-Tag: 1.6.10~14402 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f2ae756062d28379154ac4c913cf79767b97995c;p=features.git Fix the metric bug left after fixing the inset font bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9810 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 86b8a108e3..17c1b07e41 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2005-04-12 Martin Vermeer + + * 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 * paragraph.C (simpleTeXOnePar): add missing '}' in LaTeX diff --git a/src/lyxtext.h b/src/lyxtext.h index b4bef7289d..a8563e083e 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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_; /// diff --git a/src/rowpainter.C b/src/rowpainter.C index 13d7021b68..80e40158a1 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -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; } diff --git a/src/text.C b/src/text.C index d28cf336ea..46237fec23 100644 --- a/src/text.C +++ b/src/text.C @@ -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; diff --git a/src/text2.C b/src/text2.C index 053c292199..403aaf3c1a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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 {