** fix bug 2477: incorrect font in notes and erts in headings **

* InsetNote.{cpp,h}:
	- reimplement metrics to initialize display font correctly
* InsetERT.{cpp,h}:
	- (getDrawFont): pass buffer font as argument to reset the size appropriately.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@25315 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-06-19 05:40:02 +00:00
parent edbc7d9e12
commit e9a3408058
5 changed files with 28 additions and 5 deletions

View File

@ -398,7 +398,8 @@ bool InsetERT::insetAllowed(Inset::Code /* code */) const
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 @@ bool InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
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 @@ bool InsetERT::showInsetDialog(BufferView * bv) const
}
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());
}

View File

@ -71,7 +71,7 @@ public:
///
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?

View File

@ -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 @@ Inset::DisplayType InsetNote::display() const
}
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);

View File

@ -56,6 +56,8 @@ public:
/// 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);

View File

@ -78,6 +78,8 @@ What's new
- Fix crash related to the outline pane with some documents (bug 4857).
- Fix input of numeric values in non-english locales (bug 4951).
- Fix display of filters such as "LaTeX (plain)" in the file dialog.
- Fix 7 years-old bug with functions whose state can be toggled.
@ -86,7 +88,8 @@ What's new
- Allow the use of eqrefs in mathed (bug 4623).
- Fix input of numeric values in non-english locales (bug 4951).
- Use appropriate font in notes and ERT insets in section headings
(bug 2477).
* DOCUMENTATION AND LOCALIZATION