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") {
53 h_ = 4 * descent_ / 5;
61 if (mi.base.style == LM_ST_DISPLAY)
62 if (sym_->inset == "cmex" || sym_->extra == "funclim")
67 void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
69 //lyxerr << "metrics: symbol: '" << sym_->name
70 // << "' in font: '" << sym_->inset
71 // << "' drawn as: '" << sym_->draw
75 MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
76 drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
80 bool MathSymbolInset::isRelOp() const
82 return sym_->extra == "mathrel";
86 bool MathSymbolInset::isScriptable() const
92 bool MathSymbolInset::takesLimits() const
95 sym_->inset == "cmex" ||
96 sym_->inset == "lyxboldsymb" ||
97 sym_->extra == "funclim";
101 void MathSymbolInset::validate(LaTeXFeatures & features) const
103 if (sym_->inset == "msa" || sym_->inset == "msb")
104 features.require("amssymb");
108 void MathSymbolInset::normalize(NormalStream & os) const
110 os << "[symbol " << name() << "]";
114 void MathSymbolInset::maplize(MapleStream & os) const
116 if (name() == "cdot")
123 char const * MathMLtype(string const & s)
131 bool MathSymbolInset::match(MathInset * p) const
133 MathSymbolInset const * q = p->asSymbolInset();
134 return q && name() == q->name();
138 void MathSymbolInset::mathmlize(MathMLStream & os) const
140 char const * type = MathMLtype(sym_->extra);
141 os << '<' << type << "> ";
142 if (sym_->xmlname == "x") // unknown so far
146 os << " </" << type << '>';
150 void MathSymbolInset::octavize(OctaveStream & os) const
152 if (name() == "cdot")
159 void MathSymbolInset::write(WriteStream & os) const
161 os << '\\' << name() << ' ';
165 void MathSymbolInset::infoize(ostream & os) const
167 os << '\\' << name();