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"
24 #include "frontends/Painter.h"
26 #include "support/lassert.h"
32 InsetMathSpecialChar::InsetMathSpecialChar(docstring const & name)
33 : name_(name), kerning_(0)
35 if (name.size() != 1) {
36 if (name == "textasciicircum" || name == "mathcircumflex")
38 else if (name == "textasciitilde")
40 else if (name == "textbackslash")
43 LASSERT(false, char_ = '?');
50 Inset * InsetMathSpecialChar::clone() const
52 return new InsetMathSpecialChar(*this);
56 void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
58 if (mi.base.fontname == "mathnormal") {
59 Changer dummy = mi.base.font.changeShape(UP_SHAPE);;
60 dim = theFontMetrics(mi.base.font).dimension(char_);
62 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
63 dim = fm.dimension(char_);
64 kerning_ = mathed_char_kerning(mi.base.font, char_);
69 void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const
71 if (pi.base.fontname == "mathnormal") {
72 Changer dummy = pi.base.font.changeShape(UP_SHAPE);
80 void InsetMathSpecialChar::metricsT(TextMetricsInfo const &, Dimension & dim) const
88 void InsetMathSpecialChar::drawT(TextPainter & pain, int x, int y) const
90 pain.draw(x, y, char_);
94 void InsetMathSpecialChar::write(WriteStream & os) const
97 if (name_.size() != 1)
98 os.pendingSpace(true);
102 void InsetMathSpecialChar::validate(LaTeXFeatures & features) const
104 if (name_ == "mathcircumflex")
105 features.require("mathcircumflex");
109 void InsetMathSpecialChar::normalize(NormalStream & os) const
117 void InsetMathSpecialChar::maple(MapleStream & os) const
123 void InsetMathSpecialChar::mathematica(MathematicaStream & os) const
129 void InsetMathSpecialChar::octave(OctaveStream & os) const
135 void InsetMathSpecialChar::mathmlize(MathStream & ms) const
148 void InsetMathSpecialChar::htmlize(HtmlStream & ms) const