[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    [patch branch] bug 2477: Contents of notes and ERT should be displayed in normal font
From:       Jürgen_Spitzmüller <juergen () spitzmueller ! org>
Date:       2008-06-18 10:47:42
Message-ID: 200806181247.43282.juergen () spitzmueller ! org
[Download RAW message or body]

http://bugzilla.lyx.org/show_bug.cgi?id=2477

The attached patch fixes the problem, which does not exist (anymore) in trunk.

I'll commit if I get no objections.

Jürgen

["2477.diff" (text/x-diff)]

Index: src/insets/InsetERT.h
===================================================================
--- src/insets/InsetERT.h	(Revision 25271)
+++ src/insets/InsetERT.h	(Arbeitskopie)
@@ -71,7 +71,7 @@
 	///
 	bool showInsetDialog(BufferView *) const;
 	///
-	void getDrawFont(Font &) const;
+	void getDrawFont(Font &, Font) const;
 	///
 	bool forceDefaultParagraphs(idx_type) const { return true; }
 	/// should paragraph indendation be ommitted in any case?
Index: src/insets/InsetERT.cpp
===================================================================
--- src/insets/InsetERT.cpp	(Revision 25271)
+++ src/insets/InsetERT.cpp	(Arbeitskopie)
@@ -398,7 +398,8 @@
 bool InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
 {
 	Font tmpfont = mi.base.font;
-	getDrawFont(mi.base.font);
+	getDrawFont(mi.base.font,
+		mi.base.bv->buffer()->params().getFont());
 	mi.base.font.realize(tmpfont);
 	InsetCollapsable::metrics(mi, dim);
 	mi.base.font = tmpfont;
@@ -411,7 +412,8 @@
 void InsetERT::draw(PainterInfo & pi, int x, int y) const
 {
 	Font tmpfont = pi.base.font;
-	getDrawFont(pi.base.font);
+	getDrawFont(pi.base.font,
+		pi.base.bv->buffer()->params().getFont());
 	pi.base.font.realize(tmpfont);
 	InsetCollapsable::draw(pi, x, y);
 	pi.base.font = tmpfont;
@@ -425,11 +427,14 @@
 }
 
 
-void InsetERT::getDrawFont(Font & font) const
+void InsetERT::getDrawFont(Font & font, Font bfont) const
 {
 	font = Font(Font::ALL_INHERIT, latex_language);
 	font.setFamily(Font::TYPEWRITER_FAMILY);
 	font.setColor(Color::latex);
+	// use sensible size (e.g. in headings)
+	if (status() != InsetCollapsable::Inlined)
+		font.setSize(bfont.size());
 }
 
 
Index: src/insets/InsetNote.cpp
===================================================================
--- src/insets/InsetNote.cpp	(Revision 25271)
+++ src/insets/InsetNote.cpp	(Arbeitskopie)
@@ -15,6 +15,7 @@
 #include "InsetNote.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferView.h"
 #include "Cursor.h"
 #include "debug.h"
@@ -160,6 +161,18 @@
 }
 
 
+bool InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+	Font tmpfont = mi.base.font;
+	mi.base.font = mi.base.bv->buffer()->params().getFont();
+	InsetCollapsable::metrics(mi, dim);
+	mi.base.font = tmpfont;
+	bool const changed = dim_ != dim;
+	dim_ = dim;
+	return changed;
+}
+
+
 void InsetNote::write(Buffer const & buf, ostream & os) const
 {
 	params_.write(os);
Index: src/insets/InsetNote.h
===================================================================
--- src/insets/InsetNote.h	(Revision 25271)
+++ src/insets/InsetNote.h	(Arbeitskopie)
@@ -56,6 +56,8 @@
 	/// framed and shaded notes are displayed
 	virtual DisplayType display() const;
 	///
+	bool metrics(MetricsInfo &, Dimension &) const;
+	///
 	void write(Buffer const &, std::ostream &) const;
 	///
 	void read(Buffer const & buf, Lexer & lex);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic