1 #include "math_symbolinset.h"
2 #include "math_parser.h"
4 #include "support/LOstream.h"
9 MathSymbolInset::MathSymbolInset(const latexkeys * l)
13 MathInset * MathSymbolInset::clone() const
15 return new MathSymbolInset(*this);
19 void MathSymbolInset::write(MathWriteInfo & os) const
21 os << '\\' << sym_->name << ' ';
25 void MathSymbolInset::writeNormal(ostream & os) const
27 os << "[" << sym_->name << "] ";
31 MathTextCodes MathSymbolInset::code() const
52 MathTextCodes MathSymbolInset::code2() const
54 if (sym_->token == LM_TK_CMEX)
55 return LM_TC_BOLDSYMB;
61 void MathSymbolInset::metrics(MathMetricsInfo const & st) const
64 MathTextCodes c = code();
65 if (sym_->latex_font_id > 0 && math_font_available(c)) {
66 mathed_char_dim(c, size_, sym_->latex_font_id, ascent_, descent_, width_);
67 if (c == LM_TC_CMEX) {
68 h_ = 4 * descent_ / 5;
75 if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
76 mathed_char_dim(code2(), size_, sym_->id, ascent_, descent_, width_);
78 mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
82 void MathSymbolInset::draw(Painter & pain, int x, int y) const
86 MathTextCodes Code = code();
87 if (sym_->latex_font_id > 0 && math_font_available(Code))
88 drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
89 else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
90 drawChar(pain, code2(), size_, x, y, sym_->id);
92 drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
96 bool MathSymbolInset::isRelOp() const
98 return sym_->type == LMB_RELATION;
102 bool MathSymbolInset::isScriptable() const
104 return size_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
108 bool MathSymbolInset::takesLimits() const
110 return sym_->token == LM_TK_CMEX;