3 #include "math_symbolinset.h"
4 #include "math_mathmlstream.h"
5 #include "math_streamstr.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8 #include "LaTeXFeatures.h"
15 MathSymbolInset::MathSymbolInset(const latexkeys * l)
20 MathSymbolInset::MathSymbolInset(const char * name)
21 : sym_(in_word_set(name)), h_(0)
25 MathSymbolInset::MathSymbolInset(string const & name)
26 : sym_(in_word_set(name.c_str())), h_(0)
31 MathInset * MathSymbolInset::clone() const
33 return new MathSymbolInset(*this);
37 string MathSymbolInset::name() const
43 void MathSymbolInset::metrics(MathMetricsInfo & mi) const
45 //lyxerr << "metrics: symbol: '" << sym_->name
46 // << "' in font: '" << sym_->inset
47 // << "' drawn as: '" << sym_->draw
49 MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
50 mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
51 // correct height for broken cmex font
52 if (sym_->inset == "cmex" || sym_->inset == "wasy") {
53 h_ = 4 * descent_ / 5;
59 // seperate things a bit
60 if (sym_->draw.size() > 1)
64 if (mi.base.style == LM_ST_DISPLAY)
65 if (sym_->inset == "cmex" || sym_->extra == "funclim")
70 void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
72 //lyxerr << "metrics: symbol: '" << sym_->name
73 // << "' in font: '" << sym_->inset
74 // << "' drawn as: '" << sym_->draw
78 if (sym_->draw.size() > 1)
80 MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
81 drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
85 bool MathSymbolInset::isRelOp() const
87 return sym_->extra == "mathrel";
91 bool MathSymbolInset::isScriptable() const
97 bool MathSymbolInset::takesLimits() const
100 sym_->inset == "cmex" ||
101 sym_->inset == "lyxboldsymb" ||
102 sym_->extra == "funclim";
106 void MathSymbolInset::validate(LaTeXFeatures & features) const
108 if (sym_->inset == "msa" || sym_->inset == "msb")
109 features.require("amssymb");
113 void MathSymbolInset::normalize(NormalStream & os) const
115 os << "[symbol " << name() << "]";
119 void MathSymbolInset::maplize(MapleStream & os) const
121 if (name() == "cdot")
123 else if (name() == "infty")
129 void MathSymbolInset::mathematicize(MathematicaStream & os) const
131 if ( name() == "pi") { os << "Pi"; return;}
132 if ( name() == "infty") { os << "Infinity"; return;}
137 char const * MathMLtype(string const & s)
145 bool MathSymbolInset::match(MathInset * p) const
147 MathSymbolInset const * q = p->asSymbolInset();
148 return q && name() == q->name();
152 void MathSymbolInset::mathmlize(MathMLStream & os) const
154 char const * type = MathMLtype(sym_->extra);
155 os << '<' << type << "> ";
156 if (sym_->xmlname == "x") // unknown so far
160 os << " </" << type << '>';
164 void MathSymbolInset::octavize(OctaveStream & os) const
166 if (name() == "cdot")
173 void MathSymbolInset::write(WriteStream & os) const
175 os << '\\' << name() << ' ';
179 void MathSymbolInset::infoize(ostream & os) const
181 os << "Symbol: " << name();