1 #include "math_symbolinset.h"
2 #include "math_parser.h"
5 #include "support/LOstream.h"
10 MathSymbolInset::MathSymbolInset(const latexkeys * l)
15 MathInset * MathSymbolInset::clone() const
17 return new MathSymbolInset(*this);
21 void MathSymbolInset::write(MathWriteInfo & os) const
23 os << '\\' << sym_->name << ' ';
27 void MathSymbolInset::writeNormal(ostream & os) const
29 os << "[symbol " << sym_->name << "]";
33 MathTextCodes MathSymbolInset::code() const
54 MathTextCodes MathSymbolInset::code2() const
56 if (sym_->token == LM_TK_CMEX)
57 return LM_TC_BOLDSYMB;
63 void MathSymbolInset::metrics(MathMetricsInfo const & mi) const
66 MathTextCodes c = code();
67 if (sym_->latex_font_id > 0 && math_font_available(c)) {
68 mathed_char_dim(c, mi_, sym_->latex_font_id, ascent_, descent_, width_);
69 if (c == LM_TC_CMEX) {
70 h_ = 4 * descent_ / 5;
75 if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
76 mathed_char_dim(code2(), mi_, sym_->id, ascent_, descent_, width_);
78 mathed_string_dim(LM_TC_TEX, mi_, sym_->name, ascent_, descent_, width_);
81 width_ += mathed_char_width(LM_TC_TEX, mi_, 'I');
85 void MathSymbolInset::draw(Painter & pain, int x, int y) const
88 x += mathed_char_width(LM_TC_TEX, mi_, 'I') / 2;
89 MathTextCodes Code = code();
90 if (sym_->latex_font_id > 0 && math_font_available(Code))
91 drawChar(pain, Code, mi_, x, y - h_, sym_->latex_font_id);
92 else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
93 drawChar(pain, code2(), mi_, x, y, sym_->id);
95 drawStr(pain, LM_TC_TEX, mi_, x, y, sym_->name);
99 bool MathSymbolInset::isRelOp() const
101 return sym_->type == LMB_RELATION;
105 bool MathSymbolInset::isScriptable() const
107 return mi_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
111 bool MathSymbolInset::takesLimits() const
113 return sym_->token == LM_TK_CMEX;