]> git.lyx.org Git - features.git/blob - src/mathed/math_fontinset.C
fixes for \xxalignat and old style font changes
[features.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_fontinset.h"
8 #include "debug.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "math_parser.h"
13 #include "LaTeXFeatures.h"
14 #include "textpainter.h"
15 #include "frontends/Painter.h"
16
17
18
19 MathFontInset::MathFontInset(latexkeys const * key)
20         : MathNestInset(1), key_(key)
21 {
22         //lock(true);
23 }
24
25
26 MathInset * MathFontInset::clone() const
27 {
28         return new MathFontInset(*this);
29 }
30
31
32 void MathFontInset::metrics(MathMetricsInfo & mi) const
33 {
34         MathFontSetChanger dummy(mi.base, key_->name.c_str());
35         dim_ = xcell(0).metrics(mi);
36         metricsMarkers();
37 }
38
39
40 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
41 {
42         //lyxerr << "MathFontInset::draw\n";
43         //MathNestInset::draw(pi, x, y);
44         MathFontSetChanger dummy(pi.base, key_->name.c_str());
45         xcell(0).draw(pi, x + 1, y);
46         drawMarkers(pi, x, y);
47 }
48
49
50 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
51 {
52         dim_ = xcell(0).metricsT(mi);
53 }
54
55
56 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
57 {
58         //lyxerr << "drawing font code: " << code_ << '\n';
59         xcell(0).drawT(pain, x, y);
60 }
61
62
63 void MathFontInset::write(WriteStream & os) const
64 {
65         os << '\\' << key_->name << '{' << cell(0) << '}';
66 }
67
68
69 void MathFontInset::normalize(NormalStream & os) const
70 {
71         os << "[font " << key_->name << " " << cell(0) << "]";
72 }
73
74
75 void MathFontInset::validate(LaTeXFeatures & features) const
76 {
77         // Make sure amssymb is put in preamble if Blackboard Bold or
78         // Fraktur used:
79         if (key_->name == "mathfrak" || key_->name == "mathbb")
80                 features.require("amssymb");
81 }
82
83
84 void MathFontInset::infoize(std::ostream & os) const
85 {
86         os << "Font: " << key_->name;
87 }