]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
fix #1073
[lyx.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3
4 #include "math_fontinset.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7 #include "math_support.h"
8 #include "math_parser.h"
9 #include "LaTeXFeatures.h"
10 #include "support/LOstream.h"
11 #include "textpainter.h"
12
13
14
15 MathFontInset::MathFontInset(latexkeys const * key)
16         : MathNestInset(1), key_(key)
17 {}
18
19
20 MathInset * MathFontInset::clone() const
21 {
22         return new MathFontInset(*this);
23 }
24
25
26 MathInset::mode_type MathFontInset::currentMode() const
27 {
28         if (key_->extra == "mathmode")
29                 return MATH_MODE;
30         if (key_->extra == "textmode")
31                 return TEXT_MODE;
32         return UNDECIDED_MODE;
33 }
34
35
36 void MathFontInset::metrics(MetricsInfo & mi) const
37 {
38         FontSetChanger dummy(mi.base, key_->name.c_str());
39         dim_ = cell(0).metrics(mi);
40         metricsMarkers();
41 }
42
43
44 void MathFontInset::draw(PainterInfo & pi, int x, int y) const
45 {
46         FontSetChanger dummy(pi.base, key_->name.c_str());
47         cell(0).draw(pi, x + 1, y);
48         drawMarkers(pi, x, y);
49 }
50
51
52 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
53 {
54         dim_ = cell(0).metricsT(mi);
55 }
56
57
58 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
59 {
60         cell(0).drawT(pain, x, y);
61 }
62
63
64 string MathFontInset::name() const
65 {
66         return key_->name;
67 }
68
69
70 void MathFontInset::validate(LaTeXFeatures & features) const
71 {
72         MathNestInset::validate(features);
73         // Make sure amssymb is put in preamble if Blackboard Bold or
74         // Fraktur used:
75         if (key_->name == "mathfrak" || key_->name == "mathbb")
76                 features.require("amssymb");
77 }
78
79
80 void MathFontInset::infoize(std::ostream & os) const
81 {
82         os << "Font: " << key_->name;
83 }