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 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")
50 Inset * InsetMathSpecialChar::clone() const
52 return new InsetMathSpecialChar(*this);
56 void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
62 } else if (mi.base.fontname == "mathnormal") {
63 ShapeChanger dummy(mi.base.font, UP_SHAPE);
64 dim = theFontMetrics(mi.base.font).dimension(char_);
66 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
67 dim = fm.dimension(char_);
68 kerning_ = fm.rbearing(char_) - dim.wid;
73 void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const
80 xp[0] = ++x; yp[0] = y - 3;
82 xp[2] = x + w - 2; yp[2] = y;
83 xp[3] = x + w - 2; yp[3] = y - 3;
85 pi.pain.lines(xp, yp, 4, Color_special);
86 } else if (pi.base.fontname == "mathnormal") {
87 ShapeChanger dummy(pi.base.font, UP_SHAPE);
95 void InsetMathSpecialChar::metricsT(TextMetricsInfo const &, Dimension & dim) const
103 void InsetMathSpecialChar::drawT(TextPainter & pain, int x, int y) const
105 pain.draw(x, y, char_);
109 void InsetMathSpecialChar::write(WriteStream & os) const
112 if (name_.size() != 1)
113 os.pendingSpace(true);
117 void InsetMathSpecialChar::validate(LaTeXFeatures & features) const
119 if (name_ == "mathcircumflex")
120 features.require("mathcircumflex");
124 void InsetMathSpecialChar::normalize(NormalStream & os) const
132 void InsetMathSpecialChar::maple(MapleStream & os) const
138 void InsetMathSpecialChar::mathematica(MathematicaStream & os) const
144 void InsetMathSpecialChar::octave(OctaveStream & os) const
150 void InsetMathSpecialChar::mathmlize(MathStream & ms) const