2 * \file InsetMathEnsureMath.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Enrico Forestieri
9 * Full author contact details are available in file CREDITS.
14 #include "InsetMathEnsureMath.h"
16 #include "LaTeXFeatures.h"
18 #include "MathStream.h"
19 #include "MathSupport.h"
26 InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
27 : InsetMathNest(buf, 1)
31 Inset * InsetMathEnsureMath::clone() const
33 return new InsetMathEnsureMath(*this);
37 void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
39 bool really_change_font = isTextFont(from_ascii(mi.base.fontname));
40 FontSetChanger dummy(mi.base, "mathnormal", really_change_font);
41 cell(0).metrics(mi, dim);
46 void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
48 bool really_change_font = isTextFont(from_ascii(pi.base.fontname));
49 FontSetChanger dummy(pi.base, "mathnormal", really_change_font);
50 cell(0).draw(pi, x, y);
51 drawMarkers(pi, x, y);
55 void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
57 cell(0).metricsT(mi, dim);
61 void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
63 cell(0).drawT(pain, x, y);
67 void InsetMathEnsureMath::write(WriteStream & os) const
69 ModeSpecifier specifier(os, MATH_MODE);
70 os << "\\ensuremath{" << cell(0) << "}";
74 void InsetMathEnsureMath::mathmlize(MathStream & os) const
76 SetMode mathmode(os, false);
77 os << MTag("mstyle", "class='math'")
83 void InsetMathEnsureMath::htmlize(HtmlStream & os) const
85 SetHTMLMode mathmode(os, false);
86 os << MTag("span", "class='math'")
92 void InsetMathEnsureMath::infoize(odocstream & os) const
98 void InsetMathEnsureMath::validate(LaTeXFeatures & features) const
101 // It'd be better to be able to get this from an InsetLayout, but at present
102 // InsetLayouts do not seem really to work for things that aren't InsetTexts.
103 if (features.runparams().math_flavor == OutputParams::MathAsMathML)
104 features.addCSSSnippet("mstyle.math { font-style: italic; }");
105 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
106 features.addCSSSnippet("span.mathbox { font-style: italic; }");
108 InsetMathNest::validate(features);