Jean-Marc Lasgouttes wrote:

>>>>>> "Georg" == Georg Baum
>>>>>> <[EMAIL PROTECTED]>
>>>>>> writes:
> 
> Georg> This is not how it works now (in 1.3 and 1.4), at least not for
> Georg> tables. Assuming that the table cells have no explicit font
> Georg> setting, we'll get
> 
> Georg> \textbf{bla}\begin{tabular}foo\end{tabular}\textbf{baz}
> 
> In my view this is a bug, and I think it did not work like that when I
> wrote the noFontChange patch (in 1.2?).
> 
> Georg> That would certainly be possible, but it would be a file format
> Georg> change.
> 
> This is a problem indeed. What shall we do in your opinion?

IMO fixing this bug now is too risky. We should restore the 1.3 behaviour
for now and apply as a first step the attached patch. I added comments
about the intention of noFontChange, the patch is otherwise the same as
before.
When we rework noFontCahnge later, we should also refine it, because this

\large{bla}\begin{tabular}\large{foo}\end{tabular}\large{baz}

instead of

\large{bla\begin{tabular}foo\end{tabular}baz}

leads to ugly tables with too small margins.


Georg
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2338
diff -u -p -r1.2338 ChangeLog
--- src/ChangeLog	9 Dec 2005 13:42:22 -0000	1.2338
+++ src/ChangeLog	12 Dec 2005 10:57:50 -0000
@@ -1,3 +1,8 @@
+2005-12-08  Georg Baum  <[EMAIL PROTECTED]>
+
+	* text.C (redoParagraph): honor inset->noFontChange()
+	* rowpainter.C (paintInset): ditto
+
 2005-12-07  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* Makefile.am (OTHERLIBS): add SOCKET_LIBS in case we compile
Index: src/rowpainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
retrieving revision 1.159
diff -u -p -r1.159 rowpainter.C
--- src/rowpainter.C	2 Dec 2005 13:20:26 -0000	1.159
+++ src/rowpainter.C	12 Dec 2005 10:57:50 -0000
@@ -154,7 +154,11 @@ void RowPainter::paintInset(pos_type con
 	InsetBase const * inset = par_.getInset(pos);
 	BOOST_ASSERT(inset);
 	PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
-	pi.base.font = font;
+	// FIXME: We should always use font, see documentation of
+	// noFontChange() in insetbase.h.
+	pi.base.font = inset->noFontChange() ?
+		bv_.buffer()->params().getLyXTextClass().defaultfont() :
+		font;
 	pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
 	pi.erased_ = erased_ || isDeletedText(par_, pos);
 	theCoords.insets().add(inset, int(x_), yo_);
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.637
diff -u -p -r1.637 text.C
--- src/text.C	6 Dec 2005 14:54:21 -0000	1.637
+++ src/text.C	12 Dec 2005 10:57:50 -0000
@@ -1684,12 +1684,19 @@ bool LyXText::redoParagraph(pit_type con
 	}
 
 	// redo insets
+	// FIXME: We should always use getFont(), see documentation of
+	// noFontChange() in insetbase.h.
+	LyXFont const tclassfont =
+		bv()->buffer()->params().getLyXTextClass().defaultfont();
 	InsetList::iterator ii = par.insetlist.begin();
 	InsetList::iterator iend = par.insetlist.end();
 	for (; ii != iend; ++ii) {
 		Dimension dim;
 		int const w = maxwidth_ - leftMargin(pit, ii->pos) - rightMargin(par);
-		MetricsInfo mi(bv(), getFont(par, ii->pos), w);
+		LyXFont const & font = ii->inset->noFontChange() ?
+			tclassfont :
+			getFont(par, ii->pos);
+		MetricsInfo mi(bv(), font, w);
 		ii->inset->metrics(mi, dim);
 	}
 
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1206
diff -u -p -r1.1206 ChangeLog
--- src/insets/ChangeLog	5 Dec 2005 15:03:38 -0000	1.1206
+++ src/insets/ChangeLog	12 Dec 2005 10:57:50 -0000
@@ -1,3 +1,7 @@
+2005-12-12  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetbase.h (noFontChange): refine documentation
+
 2005-12-05  Martin Vermeer  <[EMAIL PROTECTED]>
 
 	* insetbox.[Ch]: fix bugs 2136, 2123
Index: src/insets/insetbase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v
retrieving revision 1.62
diff -u -p -r1.62 insetbase.h
--- src/insets/insetbase.h	25 Nov 2005 14:40:32 -0000	1.62
+++ src/insets/insetbase.h	12 Dec 2005 10:57:50 -0000
@@ -383,7 +383,14 @@ public:
 	virtual mode_type currentMode() const { return UNDECIDED_MODE; }
 	/// returns whether this inset is allowed in other insets of given mode
 	virtual bool allowedIn(mode_type) const { return true; }
-	/// is this inset allowed within a font change?
+	/**
+	 * Is this inset allowed within a font change?
+	 *
+	 * FIXME: noFontChange means currently that the font change is closed
+	 * in LaTeX before the inset, and that the contents of the inset
+	 * will be in default font. This should be changed so that the inset
+	 * changes the font again.
+	 */
 	virtual bool noFontChange() const { return false; }
 
 	/// mark the inset as erased or not

Reply via email to