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);
65 metricsMarkers(mi, dim);
69 void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
71 current_mode_ = isTextFont(pi.base.fontname)
72 ? TEXT_MODE : MATH_MODE;
74 std::string const fontname = current_mode_ == MATH_MODE
75 ? "math" + font() : "text" + font();// I doubt that this still works
77 // When \cal is used in text mode, the font is not changed
78 bool really_change_font = fontname != "textcal";
80 Changer dummy = really_change_font ? pi.base.changeFontSet(fontname)
82 cell(0).draw(pi, x + 1, y);
83 drawMarkers(pi, x, y);
87 void InsetMathFontOld::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
89 cell(0).metricsT(mi, dim);
93 void InsetMathFontOld::drawT(TextPainter & pain, int x, int y) const
95 cell(0).drawT(pain, x, y);
99 void InsetMathFontOld::write(WriteStream & os) const
101 os << "{\\" << key_->name << ' ' << cell(0) << '}';
105 void InsetMathFontOld::normalize(NormalStream & os) const
107 os << "[font " << key_->name << ' ' << cell(0) << ']';
111 void InsetMathFontOld::infoize(odocstream & os) const
113 os << bformat(_("Font: %1$s"), key_->name);