>>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

Martin> From within an inset, I can confirm that indeed the default
Martin> font settings are returned when you change layout to Section.
Martin> When in the main text, ALL_INHERIT is returned as should.

Martin> Looking at the code in Paragraph::getFontSettings, these
Martin> default settings seem to come from the font list structure.
Martin> But how did they get there in the first place? And why only
Martin> inside an inset?

Ha! Been there, done that :)

The result is the following one-liner patch to text2.C (the patch to
text.C does nothing except remove code that is indimidating but does
nothing).

The problem is that the cache LyXText::current_font, which is (if I
understand correctly) the uninstantiated default font of the LyXText,
was not initialized, and thus received the default ALL_SANE (roman,
medium...) setting, instead of a good ALL_INHERIT.

The situation now is much more credible, but touching such core code
make me nervous. Could you test that (without your other patch)?

I think this current_font/real_current_font should eventually go away.
Also, it would be nice if defaultfont_ was either removed of
initalized to something somewhere :)

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2335
diff -u -p -r1.2335 ChangeLog
--- src/ChangeLog	2 Dec 2005 13:20:25 -0000	1.2335
+++ src/ChangeLog	2 Dec 2005 14:37:25 -0000
@@ -1,3 +1,11 @@
+2005-12-02  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* text.C (insertChar): remove bogus caching of fonts (did not do
+	anything). 
+
+	* text2.C (LyXText): initialize current_font to ALL_INHERIT (was
+	ALL_SANE).
+
 2005-12-01  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* rowpainter.C (paintFirst): fix centering of
Index: src/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.636
diff -u -p -r1.636 text.C
--- src/text.C	17 Nov 2005 09:19:02 -0000	1.636
+++ src/text.C	2 Dec 2005 14:37:25 -0000
@@ -1154,16 +1154,6 @@ void LyXText::insertChar(LCursor & cur, 
 	// difference are the special checks when calculating the row.fill
 	// (blank does not count at the end of a row) and the check here
 
-	// The bug is triggered when we type in a description environment:
-	// The current_font is not changed when we go from label to main text
-	// and it should (along with realtmpfont) when we type the space.
-	// CHECK There is a bug here! (Asger)
-
-	// store the current font.  This is because of the use of cursor
-	// movements. The moving cursor would refresh the current font
-	LyXFont realtmpfont = real_current_font;
-	LyXFont rawtmpfont = current_font;
-
 	// When the free-spacing option is set for the current layout,
 	// disable the double-space checking
 	if (!freeSpacing && IsLineSeparatorChar(c)) {
@@ -1190,10 +1180,7 @@ void LyXText::insertChar(LCursor & cur, 
 		}
 	}
 
-	par.insertChar(cur.pos(), c, rawtmpfont);
-
-	current_font = rawtmpfont;
-	real_current_font = realtmpfont;
+	par.insertChar(cur.pos(), c, current_font);
 	setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary());
 	charInserted();
 }
Index: src/text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.635
diff -u -p -r1.635 text2.C
--- src/text2.C	28 Nov 2005 11:52:02 -0000	1.635
+++ src/text2.C	2 Dec 2005 14:37:25 -0000
@@ -68,6 +68,7 @@ using std::min;
 
 LyXText::LyXText(BufferView * bv)
 	: maxwidth_(bv ? bv->workWidth() : 100),
+	  current_font(LyXFont::ALL_INHERIT),
 	  background_color_(LColor::background),
 	  bv_owner(bv),
 	  autoBreakRows_(false)

Reply via email to