On Tue, 2005-04-12 at 14:33, Jose' Matos wrote:
> On Tuesday 12 April 2005 11:52, Martin Vermeer wrote:
> > Alfredo,
> >
> > here's an improved and cleaner patch, with some documentation added.
> 
>   Where? ;-)

Don't get hung up on details...

- Martin
Index: lyxtext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
retrieving revision 1.320
diff -u -p -r1.320 lyxtext.h
--- lyxtext.h	25 Feb 2005 11:55:31 -0000	1.320
+++ lyxtext.h	12 Apr 2005 10:44:06 -0000
@@ -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: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.605
diff -u -p -r1.605 text2.C
--- text2.C	11 Mar 2005 14:20:58 -0000	1.605
+++ text2.C	12 Apr 2005 10:44:06 -0000
@@ -152,7 +152,7 @@ LyXFont LyXText::getFont(Paragraph 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,12 +170,27 @@ LyXFont LyXText::getFont(Paragraph const
 	font.realize(layoutfont);
 
 	if (!isMainText())
-		font.realize(font_);
+		applyOuterFont(font);
 
 	// Realize with the fonts of lesser depth.
 	font.realize(defaultfont_);
 
 	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;
 }
 
 
Index: rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.145
diff -u -p -r1.145 rowpainter.C
--- rowpainter.C	10 Apr 2005 20:15:47 -0000	1.145
+++ rowpainter.C	12 Apr 2005 10:44:06 -0000
@@ -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;
 }
 
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to