On Mon, Apr 11, 2005 at 09:12:38AM +0200, Juergen Spitzmueller wrote: > Martin Vermeer wrote: > > Committed. > > Now the metrics are completely wrong if you type longer text into an ERT or > char style inset. > > Jürgen
Fixed by attached. Doing this I learned more about the way LyX's fonts propagate through the inset stack than you'll ever want to forget. In lyxtext.h there are no fewer than four locally stored fonts. Of those, current_font and real_current_font are not referred to anywhere in the code, and I propose to remove them to reduce confusion. Of the lyxtext fonts that do mean something, we have defaultfont_: apparently the default textclass font, made available here. font_: the locally stored font that was handed down from the surroundings to an inset's textinset. In my understanding the original inset font error was a failure to hand down this surrounding font so it could be used in metrics computation and drawing. (Between insets, this handing down takes place in the MetricsInfo/PainterInfo argument). I fixed this, but at the same time saw myself forced to do the combination of this and the font defined by the local text paragraphs in a different (IMHO usually appropriate) way. Did I get this right? lyxfont hell ;-) - Martin
Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.145 diff -u -r1.145 rowpainter.C --- rowpainter.C 10 Apr 2005 20:15:47 -0000 1.145 +++ rowpainter.C 11 Apr 2005 18:52:44 -0000 @@ -147,7 +147,7 @@ { LyXFont lf(font_); LyXFont pf(text_.getFont(par_, pos)); - lf.reduce(LyXFont(LyXFont::ALL_SANE)); + lf.reduce(text_.defaultfont_); lf.realize(pf); lf.setLanguage(pf.language()); return lf; Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.605 diff -u -r1.605 text2.C --- text2.C 11 Mar 2005 14:20:58 -0000 1.605 +++ text2.C 11 Apr 2005 18:52:44 -0000 @@ -151,8 +151,13 @@ // We specialize the 95% common case: if (!par.getDepth()) { LyXFont f = par.getFontSettings(params, pos); - if (!isMainText()) - f.realize(font_); + if (!isMainText()) { + LyXFont lf(font_); + lf.reduce(defaultfont_); + lf.realize(f); + lf.setLanguage(f.language()); + f = lf; + } if (layout->labeltype == LABEL_MANUAL && pos < body_pos) return f.realize(layout->reslabelfont); else @@ -169,10 +174,15 @@ LyXFont font = par.getFontSettings(params, pos); font.realize(layoutfont); - if (!isMainText()) - font.realize(font_); + if (!isMainText()) { + LyXFont lf(font_); + lf.reduce(defaultfont_); + lf.realize(font); + lf.setLanguage(font.language()); + font = lf; + } - // Realize with the fonts of lesser depth. + // Realize with the fonts of lesser depth. (I think useless -- MV) font.realize(defaultfont_); return font;
pgpVDWVFlL24d.pgp
Description: PGP signature