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/lstrings.h"
26 using namespace lyx::support;
30 InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
31 : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
37 Inset * InsetMathFontOld::clone() const
39 return new InsetMathFontOld(*this);
43 void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
45 current_mode_ = isTextFont(from_ascii(mi.base.fontname))
46 ? TEXT_MODE : MATH_MODE;
48 docstring const font = current_mode_ == MATH_MODE
49 ? "math" + key_->name : "text" + key_->name;
51 // When \cal is used in text mode, the font is not changed
52 bool really_change_font = font != "textcal";
54 FontSetChanger dummy(mi.base, font, really_change_font);
55 cell(0).metrics(mi, dim);
60 void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
62 current_mode_ = isTextFont(from_ascii(pi.base.fontname))
63 ? TEXT_MODE : MATH_MODE;
65 docstring const font = current_mode_ == MATH_MODE
66 ? "math" + key_->name : "text" + key_->name;
68 // When \cal is used in text mode, the font is not changed
69 bool really_change_font = font != "textcal";
71 FontSetChanger dummy(pi.base, font, really_change_font);
72 cell(0).draw(pi, x + 1, y);
73 drawMarkers(pi, x, y);
77 void InsetMathFontOld::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
79 cell(0).metricsT(mi, dim);
83 void InsetMathFontOld::drawT(TextPainter & pain, int x, int y) const
85 cell(0).drawT(pain, x, y);
89 void InsetMathFontOld::write(WriteStream & os) const
91 os << "{\\" << key_->name << ' ' << cell(0) << '}';
95 void InsetMathFontOld::normalize(NormalStream & os) const
97 os << "[font " << key_->name << ' ' << cell(0) << ']';
101 void InsetMathFontOld::infoize(odocstream & os) const
103 os << bformat(_("Font: %1$s"), key_->name);