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
This commit is contained in:
Martin Vermeer 2005-04-12 18:42:27 +00:00
parent 948ffa5bd1
commit f2ae756062
5 changed files with 35 additions and 13 deletions

View 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

View 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_;
///

View 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;
}

View 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;

View 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
{