From 4fc5f86137141b157a85dfcd32c90aacdddf238d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 31 Mar 2010 01:09:38 +0000 Subject: [PATCH] Fix bug #4565: Using keyboard shortcuts to write Greek letters with an underbar produces LaTeX errors. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33963 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathDecoration.cpp | 16 +++++++++++++++- src/mathed/InsetMathDecoration.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index a5e333e308..f10cc4c13d 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -96,8 +96,17 @@ bool InsetMathDecoration::wide() const } +InsetMath::mode_type InsetMathDecoration::currentMode() const +{ + return key_->name == "underbar" ? TEXT_MODE : MATH_MODE; +} + + void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const { + FontSetChanger dummy(mi.base, currentMode() == TEXT_MODE ? + "textnormal" : "mathnormal"); + cell(0).metrics(mi, dim); dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_); @@ -117,6 +126,9 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const { + FontSetChanger dummy(pi.base, currentMode() == TEXT_MODE ? + "textnormal" : "mathnormal"); + cell(0).draw(pi, x + 1, y); Dimension const & dim0 = cell(0).dimension(*pi.base.bv); if (wide()) @@ -134,7 +146,9 @@ void InsetMathDecoration::write(WriteStream & os) const MathEnsurer ensurer(os); if (os.fragile() && protect()) os << "\\protect"; - os << '\\' << key_->name << '{' << cell(0) << '}'; + os << '\\' << key_->name << '{'; + ModeSpecifier specifier(os, currentMode()); + os << cell(0) << '}'; } diff --git a/src/mathed/InsetMathDecoration.h b/src/mathed/InsetMathDecoration.h index adabcd7c04..9e58065ee3 100644 --- a/src/mathed/InsetMathDecoration.h +++ b/src/mathed/InsetMathDecoration.h @@ -26,6 +26,8 @@ public: /// explicit InsetMathDecoration(Buffer * buf, latexkeys const * key); /// + mode_type currentMode() const; + /// void draw(PainterInfo &, int x, int y) const; /// void write(WriteStream & os) const; -- 2.39.2