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(ostream & os, bool /* fragile */) 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(MathStyles st) const
64 MathTextCodes Code = code();
65 if (sym_->latex_font_id > 0 && math_font_available(Code)) {
66 mathed_char_dim(Code, size_, sym_->latex_font_id,
67 ascent_, descent_, width_);
68 if (Code == LM_TC_CMEX) {
73 } else if (sym_->id > 0 && sym_->id < 255 &&
74 math_font_available(LM_TC_SYMB)) {
75 mathed_char_dim(code2(), size_, sym_->id,
76 ascent_, descent_, width_);
78 mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
83 void MathSymbolInset::draw(Painter & pain, int x, int y) const
87 MathTextCodes Code = code();
88 if (sym_->latex_font_id > 0 && math_font_available(Code))
89 drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
90 else if (sym_->id > 0 && sym_->id < 255 &&
91 math_font_available(LM_TC_SYMB))
92 drawChar(pain, code2(), size_, x, y, sym_->id);
94 drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
98 bool MathSymbolInset::isRelOp() const
100 return sym_->type == LMB_RELATION;
104 bool MathSymbolInset::isScriptable() const
106 return size_ == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
110 bool MathSymbolInset::takesLimits() const
112 return sym_->token == LM_TK_CMEX;