X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathFontOld.cpp;h=cde388840cd9b755df53199b5575579e4dbfc708;hb=a59301eaff51c63db706e17bd5496b8e02928f14;hp=e70b7370f594a4d33a3224914b5050daa74dfa50;hpb=6e3a75969b97a5db4c80c46be49d4deb122abfe7;p=lyx.git diff --git a/src/mathed/InsetMathFontOld.cpp b/src/mathed/InsetMathFontOld.cpp index e70b7370f5..cde388840c 100644 --- a/src/mathed/InsetMathFontOld.cpp +++ b/src/mathed/InsetMathFontOld.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -11,48 +11,74 @@ #include #include "InsetMathFontOld.h" -#include "MathArray.h" -#include "MathStream.h" + +#include "MathData.h" #include "MathParser.h" #include "MathStream.h" -#include "support/std_ostream.h" +#include "MathSupport.h" +#include "MetricsInfo.h" +#include "support/gettext.h" +#include "support/lassert.h" +#include "support/lstrings.h" -namespace lyx { +#include -using std::auto_ptr; +using namespace lyx::support; +namespace lyx { -InsetMathFontOld::InsetMathFontOld(latexkeys const * key) - : InsetMathNest(1), key_(key) +InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key) + : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE) { //lock(true); } -auto_ptr InsetMathFontOld::doClone() const +std::string InsetMathFontOld::font() const +{ + LASSERT(isAscii(key_->name), return "mathnormal"); + return to_ascii(key_->name); +} + + +Inset * InsetMathFontOld::clone() const { - return auto_ptr(new InsetMathFontOld(*this)); + return new InsetMathFontOld(*this); } -bool InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const { - FontSetChanger dummy(mi.base, key_->name.c_str()); + current_mode_ = isTextFont(mi.base.fontname) + ? TEXT_MODE : MATH_MODE; + + std::string const fontname = current_mode_ == MATH_MODE + ? "math" + font() : "text" + font();// I doubt that this still works + + // When \cal is used in text mode, the font is not changed + bool really_change_font = fontname != "textcal"; + + Changer dummy = really_change_font ? mi.base.changeFontSet(fontname) + : Changer(); cell(0).metrics(mi, dim); - metricsMarkers(dim); - if (dim_ == dim) - return false; - dim_ = dim; - return true; } void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const { - FontSetChanger dummy(pi.base, key_->name.c_str()); - cell(0).draw(pi, x + 1, y); - drawMarkers(pi, x, y); + current_mode_ = isTextFont(pi.base.fontname) + ? TEXT_MODE : MATH_MODE; + + std::string const fontname = current_mode_ == MATH_MODE + ? "math" + font() : "text" + font();// I doubt that this still works + + // When \cal is used in text mode, the font is not changed + bool really_change_font = fontname != "textcal"; + + Changer dummy = really_change_font ? pi.base.changeFontSet(fontname) + : Changer(); + cell(0).draw(pi, x, y); } @@ -82,7 +108,7 @@ void InsetMathFontOld::normalize(NormalStream & os) const void InsetMathFontOld::infoize(odocstream & os) const { - os << "Font: " << key_->name; + os << bformat(_("Font: %1$s"), key_->name); }