]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_symbolinset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_symbolinset.C
index 57d8d7b2bc86fdac93ec165251616258a7d2c2fa..272c38861dd09be9e9e0bddbf1a1e9f6c2dcc78c 100644 (file)
@@ -1,3 +1,4 @@
+
 #include <config.h>
 
 #include "math_symbolinset.h"
@@ -8,10 +9,6 @@
 #include "LaTeXFeatures.h"
 #include "debug.h"
 
-
-using std::ostream;
-
-
 MathSymbolInset::MathSymbolInset(const latexkeys * l)
        : sym_(l), h_(0)
 {}
@@ -46,16 +43,21 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
        //      << "' in font: '" << sym_->inset
        //      << "' drawn as: '" << sym_->draw
        //      << "'\n";
+
+       int const em = mathed_char_width(mi.base.font, 'M');
        MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
-       mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
-       // correct height for broken cmex font
-       if (sym_->inset == "cmex") {
-               h_ = 4 * descent_ / 5;
-               ascent_  += h_;
-               descent_ -= h_;
+       mathed_string_dim(mi.base.font, sym_->draw, dim_);
+       // correct height for broken cmex and wasy font
+       if (sym_->inset == "cmex" || sym_->inset == "wasy") {
+               h_ = 4 * dim_.d / 5;
+               dim_.a += h_;
+               dim_.d -= h_;
        }
+       // seperate things a bit
        if (isRelOp())
-               width_ += 6;
+               dim_.w += static_cast<int>(0.5*em+0.5);
+       else
+               dim_.w += static_cast<int>(0.1667*em+0.5);
 
        scriptable_ = false;
        if (mi.base.style == LM_ST_DISPLAY)
@@ -70,8 +72,12 @@ void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
        //      << "' in font: '" << sym_->inset
        //      << "' drawn as: '" << sym_->draw
        //      << "'\n";
+       int const em = mathed_char_width(pi.base.font, 'M');
        if (isRelOp())
-               x += 3;
+               x += static_cast<int>(0.25*em+0.5);
+       else
+               x += static_cast<int>(0.0833*em+0.5);
+
        MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
        drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
 }
@@ -107,18 +113,38 @@ void MathSymbolInset::validate(LaTeXFeatures & features) const
 
 void MathSymbolInset::normalize(NormalStream & os) const
 {
-       os << "[symbol " << name() << "]";
+       os << "[symbol " << name() << ']';
 }
 
 
-void MathSymbolInset::maplize(MapleStream & os) const
+void MathSymbolInset::maple(MapleStream & os) const
 {
        if (name() == "cdot")
                os << '*';
+       else if (name() == "infty")
+               os << "infinity";
        else
                os << name();
 }
 
+void MathSymbolInset::maxima(MaximaStream & os) const
+{
+       if (name() == "cdot")
+               os << '*';
+       else if (name() == "infty")
+               os << "INF";
+       else
+               os << name();
+}
+
+
+void MathSymbolInset::mathematica(MathematicaStream & os) const
+{
+       if ( name() == "pi")    { os << "Pi"; return;}
+       if ( name() == "infty") { os << "Infinity"; return;}
+       os << name();
+}
+
 
 char const * MathMLtype(string const & s)
 {
@@ -128,9 +154,9 @@ char const * MathMLtype(string const & s)
 }
 
 
-bool MathSymbolInset::match(MathInset * p) const
+bool MathSymbolInset::match(MathAtom const & at) const
 {
-       MathSymbolInset const * q = p->asSymbolInset();
+       MathSymbolInset const * q = at->asSymbolInset();
        return q && name() == q->name();
 }
 
@@ -147,7 +173,7 @@ void MathSymbolInset::mathmlize(MathMLStream & os) const
 }
 
 
-void MathSymbolInset::octavize(OctaveStream & os) const
+void MathSymbolInset::octave(OctaveStream & os) const
 {
        if (name() == "cdot")
                os << '*';
@@ -158,11 +184,12 @@ void MathSymbolInset::octavize(OctaveStream & os) const
 
 void MathSymbolInset::write(WriteStream & os) const
 {
-       os << '\\' << name() << ' ';
+       os << '\\' << name();
+       os.pendingSpace(true);
 }
 
 
-void MathSymbolInset::infoize(ostream & os) const
+void MathSymbolInset::infoize2(std::ostream & os) const
 {
-       os << '\\' << name();
+       os << "Symbol: " << name();
 }