7 #include "math_fontinset.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "LaTeXFeatures.h"
13 #include "textpainter.h"
14 #include "frontends/Painter.h"
19 MathFontInset::MathFontInset(string const & name)
20 : MathNestInset(1), name_(name)
26 MathInset * MathFontInset::clone() const
28 return new MathFontInset(*this);
32 void MathFontInset::metrics(MathMetricsInfo & mi) const
34 MathFontSetChanger dummy(mi.base, name_.c_str());
36 ascent_ = xcell(0).ascent();
37 descent_ = xcell(0).descent() + 2;
38 width_ = xcell(0).width() + 2;
42 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
44 //lyxerr << "MathFontInset::draw\n";
45 //MathNestInset::draw(pi, x, y);
46 MathFontSetChanger dummy(pi.base, name_.c_str());
47 xcell(0).draw(pi, x + 1, y);
49 int t = x + width() - 1;
50 int d = y + descent();
51 pi.pain.line(x, d - 3, x, d, LColor::mathframe);
52 pi.pain.line(t, d - 3, t, d, LColor::mathframe);
53 pi.pain.line(x, d, x + 3, d, LColor::mathframe);
54 pi.pain.line(t - 2, d, t, d, LColor::mathframe);
59 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
61 xcell(0).metricsT(mi);
62 width_ = xcell(0).width();
63 ascent_ = xcell(0).ascent();
64 descent_ = xcell(0).descent();
68 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
70 //lyxerr << "drawing font code: " << code_ << '\n';
71 xcell(0).drawT(pain, x, y);
75 void MathFontInset::write(WriteStream & os) const
77 os << '\\' << name_ << '{' << cell(0) << '}';
81 void MathFontInset::normalize(NormalStream & os) const
83 os << "[font_ " << name_ << " " << cell(0) << "]";
87 void MathFontInset::validate(LaTeXFeatures & features) const
89 // Make sure amssymb is put in preamble if Blackboard Bold or
91 if (name_ == "mathfrak" || name_ == "mathbb")
92 features.require("amssymb");
96 void MathFontInset::infoize(std::ostream & os) const
98 os << "Font: " << name_;