2 * \file InsetMathSpecialChar.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Enrico Forestieri
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathSpecialChar.h"
15 #include "MathSupport.h"
16 #include "MathStream.h"
17 #include "MetricsInfo.h"
19 #include "Dimension.h"
20 #include "LaTeXFeatures.h"
21 #include "TextPainter.h"
23 #include "frontends/FontMetrics.h"
25 #include "support/lassert.h"
31 InsetMathSpecialChar::InsetMathSpecialChar(docstring name)
32 : name_(name), kerning_(0)
34 if (name.size() != 1) {
35 if (name == "textasciicircum" || name == "mathcircumflex")
37 else if (name == "textasciitilde")
39 else if (name == "textbackslash")
49 Inset * InsetMathSpecialChar::clone() const
51 return new InsetMathSpecialChar(*this);
55 void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
57 if (mi.base.fontname == "mathnormal") {
58 ShapeChanger dummy(mi.base.font, UP_SHAPE);
59 dim = theFontMetrics(mi.base.font).dimension(char_);
61 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
62 dim = fm.dimension(char_);
63 kerning_ = fm.rbearing(char_) - dim.wid;
68 void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const
70 if (pi.base.fontname == "mathnormal") {
71 ShapeChanger dummy(pi.base.font, UP_SHAPE);
79 void InsetMathSpecialChar::metricsT(TextMetricsInfo const &, Dimension & dim) const
87 void InsetMathSpecialChar::drawT(TextPainter & pain, int x, int y) const
89 pain.draw(x, y, char_);
93 void InsetMathSpecialChar::write(WriteStream & os) const
96 if (name_.size() != 1)
97 os.pendingSpace(true);
101 void InsetMathSpecialChar::validate(LaTeXFeatures & features) const
103 if (name_ == "mathcircumflex")
104 features.require("mathcircumflex");
108 void InsetMathSpecialChar::normalize(NormalStream & os) const
116 void InsetMathSpecialChar::maple(MapleStream & os) const
122 void InsetMathSpecialChar::mathematica(MathematicaStream & os) const
128 void InsetMathSpecialChar::octave(OctaveStream & os) const
134 void InsetMathSpecialChar::mathmlize(MathStream & ms) const