2 * \file InsetMathFontOld.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathFontOld.h"
16 #include "MathParser.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19 #include "MetricsInfo.h"
21 #include "support/gettext.h"
22 #include "support/lassert.h"
23 #include "support/lstrings.h"
27 using namespace lyx::support;
31 InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
32 : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
38 std::string InsetMathFontOld::font() const
40 LASSERT(isAscii(key_->name), return "mathnormal");
41 return to_ascii(key_->name);
45 Inset * InsetMathFontOld::clone() const
47 return new InsetMathFontOld(*this);
51 void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
53 current_mode_ = isTextFont(mi.base.fontname)
54 ? TEXT_MODE : MATH_MODE;
56 std::string const fontname = current_mode_ == MATH_MODE
57 ? "math" + font() : "text" + font();// I doubt that this still works
59 // When \cal is used in text mode, the font is not changed
60 bool really_change_font = fontname != "textcal";
62 Changer dummy = really_change_font ? mi.base.changeFontSet(fontname)
64 cell(0).metrics(mi, dim);
68 void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
70 current_mode_ = isTextFont(pi.base.fontname)
71 ? TEXT_MODE : MATH_MODE;
73 std::string const fontname = current_mode_ == MATH_MODE
74 ? "math" + font() : "text" + font();// I doubt that this still works
76 // When \cal is used in text mode, the font is not changed
77 bool really_change_font = fontname != "textcal";
79 Changer dummy = really_change_font ? pi.base.changeFontSet(fontname)
81 cell(0).draw(pi, x, y);
85 void InsetMathFontOld::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
87 cell(0).metricsT(mi, dim);
91 void InsetMathFontOld::drawT(TextPainter & pain, int x, int y) const
93 cell(0).drawT(pain, x, y);
97 void InsetMathFontOld::write(TeXMathStream & os) const
99 os << "{\\" << key_->name << ' ' << cell(0) << '}';
103 void InsetMathFontOld::normalize(NormalStream & os) const
105 os << "[font " << key_->name << ' ' << cell(0) << ']';
109 void InsetMathFontOld::infoize(odocstream & os) const
111 os << bformat(_("Font: %1$s"), key_->name);