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"
26 InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
27 : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
33 Inset * InsetMathFontOld::clone() const
35 return new InsetMathFontOld(*this);
39 void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
41 current_mode_ = isTextFont(from_ascii(mi.base.fontname))
42 ? TEXT_MODE : MATH_MODE;
44 docstring const font = current_mode_ == MATH_MODE
45 ? "math" + key_->name : "text" + key_->name;
47 // When \cal is used in text mode, the font is not changed
48 bool really_change_font = font != "textcal";
50 FontSetChanger dummy(mi.base, font, really_change_font);
51 cell(0).metrics(mi, dim);
56 void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
58 current_mode_ = isTextFont(from_ascii(pi.base.fontname))
59 ? TEXT_MODE : MATH_MODE;
61 docstring const font = current_mode_ == MATH_MODE
62 ? "math" + key_->name : "text" + key_->name;
64 // When \cal is used in text mode, the font is not changed
65 bool really_change_font = font != "textcal";
67 FontSetChanger dummy(pi.base, font, really_change_font);
68 cell(0).draw(pi, x + 1, y);
69 drawMarkers(pi, x, y);
73 void InsetMathFontOld::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
75 cell(0).metricsT(mi, dim);
79 void InsetMathFontOld::drawT(TextPainter & pain, int x, int y) const
81 cell(0).drawT(pain, x, y);
85 void InsetMathFontOld::write(WriteStream & os) const
87 os << "{\\" << key_->name << ' ' << cell(0) << '}';
91 void InsetMathFontOld::normalize(NormalStream & os) const
93 os << "[font " << key_->name << ' ' << cell(0) << ']';
97 void InsetMathFontOld::infoize(odocstream & os) const
99 os << "Font: " << key_->name;