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
49 void MathSymbolInset::metrics(MathStyles st) const
52 MathTextCodes Code = code();
53 if (sym_->latex_font_id > 0 && math_font_available(Code)) {
54 mathed_char_dim(Code, size_, sym_->latex_font_id,
55 ascent_, descent_, width_);
56 if (Code == LM_TC_CMEX) {
61 } else if (sym_->id > 0 && sym_->id < 255 &&
62 math_font_available(LM_TC_SYMB)) {
63 mathed_char_dim(LM_TC_SYMB, size_, sym_->id,
64 ascent_, descent_, width_);
66 mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
71 void MathSymbolInset::draw(Painter & pain, int x, int y) const
75 MathTextCodes Code = code();
76 if (sym_->latex_font_id > 0 && math_font_available(Code))
77 drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
78 else if (sym_->id > 0 && sym_->id < 255 &&
79 math_font_available(LM_TC_SYMB))
80 drawChar(pain, LM_TC_SYMB, size_, x, y, sym_->id);
82 drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
86 bool MathSymbolInset::isRelOp() const
88 return sym_->type == LMB_RELATION;
92 bool MathSymbolInset::isScriptable() const
94 return sym_->token == LM_TK_CMEX;