diff --git a/lib/symbols b/lib/symbols index 07830c6b35..cee45b9314 100644 --- a/lib/symbols +++ b/lib/symbols @@ -111,12 +111,11 @@ ce font forcetext cf font forcetext # old-style font commands -# name "oldfont" alias -bf oldfont textbf -cal oldfont mathcal -it oldfont textit -rm oldfont textrm -tt oldfont texttt +bf oldfont none +cal oldfont none +it oldfont none +rm oldfont none +tt oldfont none # matrix environments Bmatrix matrix none diff --git a/src/mathed/InsetMathFontOld.cpp b/src/mathed/InsetMathFontOld.cpp index 88a3cdfca9..c14c4e36a8 100644 --- a/src/mathed/InsetMathFontOld.cpp +++ b/src/mathed/InsetMathFontOld.cpp @@ -13,8 +13,9 @@ #include "InsetMathFontOld.h" #include "MathData.h" -#include "MathStream.h" #include "MathParser.h" +#include "MathStream.h" +#include "MathSupport.h" #include "MetricsInfo.h" #include @@ -23,7 +24,7 @@ namespace lyx { InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key) - : InsetMathNest(buf, 1), key_(key) + : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE) { //lock(true); } @@ -37,7 +38,16 @@ Inset * InsetMathFontOld::clone() const void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const { - FontSetChanger dummy(mi.base, key_->extra); + current_mode_ = isTextFont(from_ascii(mi.base.fontname)) + ? TEXT_MODE : MATH_MODE; + + docstring const font = current_mode_ == MATH_MODE + ? "math" + key_->name : "text" + key_->name; + + // When \cal is used in text mode, the font is not changed + bool really_change_font = font != "textcal"; + + FontSetChanger dummy(mi.base, font, really_change_font); cell(0).metrics(mi, dim); metricsMarkers(dim); } @@ -45,7 +55,16 @@ void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const { - FontSetChanger dummy(pi.base, key_->extra); + current_mode_ = isTextFont(from_ascii(pi.base.fontname)) + ? TEXT_MODE : MATH_MODE; + + docstring const font = current_mode_ == MATH_MODE + ? "math" + key_->name : "text" + key_->name; + + // When \cal is used in text mode, the font is not changed + bool really_change_font = font != "textcal"; + + FontSetChanger dummy(pi.base, font, really_change_font); cell(0).draw(pi, x + 1, y); drawMarkers(pi, x, y); } diff --git a/src/mathed/InsetMathFontOld.h b/src/mathed/InsetMathFontOld.h index c27bfa6658..3046d03d48 100644 --- a/src/mathed/InsetMathFontOld.h +++ b/src/mathed/InsetMathFontOld.h @@ -25,8 +25,8 @@ class InsetMathFontOld : public InsetMathNest { public: /// explicit InsetMathFontOld(Buffer * buf, latexkeys const * key); - /// we are in text mode. - mode_type currentMode() const { return TEXT_MODE; } + /// we inherit the mode + mode_type currentMode() const { return current_mode_; } /// we write extra braces in any case... bool extraBraces() const { return true; } /// @@ -52,6 +52,8 @@ private: virtual Inset * clone() const; /// the font to be used on screen latexkeys const * key_; + /// the inherited mode + mutable mode_type current_mode_; };