]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathChar.cpp
We only support gcc >= 4.9.
[lyx.git] / src / mathed / InsetMathChar.cpp
index 7069bdcd5f0775cddcadca0d99af0dbf4c8e5d83..a02f54b43ac376f73f69894b0bb4c16c96d903f5 100644 (file)
@@ -113,13 +113,18 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
        if (isMathFont(f) && subst_) {
                // If the char has a substitute, draw the replacement symbol
                // instead, but only in math mode.
-               mathedSymbolDim(mi.base, dim, subst_);
-               kerning_ = mathed_char_kerning(mi.base.font, *subst_->draw.rbegin());
-               return;
+               kerning_ = mathedSymbolDim(mi.base, dim, subst_);
        } else if (!slanted(char_) && f == "mathnormal") {
                Changer dummy = mi.base.font.changeShape(UP_SHAPE);
                dim = theFontMetrics(mi.base.font).dimension(char_);
                kerning_ = 0;
+       } else if (!isASCII(char_) && Encodings::unicodeCharInfo(char_).isUnicodeSymbol()) {
+               Changer dummy1 = mi.base.changeFontSet("mathnormal");
+               Changer dummy2 = Encodings::isMathAlpha(char_)
+                               ? noChange()
+                               : mi.base.font.changeShape(UP_SHAPE);
+               dim = theFontMetrics(mi.base.font).dimension(char_);
+               kerning_ = -mathed_char_kerning(mi.base.font, char_);
        } else {
                frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
                dim = fm.dimension(char_);
@@ -158,6 +163,13 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) const
                        Changer dummy = pi.base.font.changeShape(UP_SHAPE);
                        pi.draw(x, y, char_);
                        return;
+               } else if (!isASCII(char_) && Encodings::unicodeCharInfo(char_).isUnicodeSymbol()) {
+                       Changer dummy1 = pi.base.changeFontSet("mathnormal");
+                       Changer dummy2 = Encodings::isMathAlpha(char_)
+                                       ? noChange()
+                                       : pi.base.font.changeShape(UP_SHAPE);
+                       pi.draw(x, y, char_);
+                       return;
                }
        }
        // cmmi has almost no left bearing: simulate this
@@ -183,7 +195,7 @@ void InsetMathChar::drawT(TextPainter & pain, int x, int y) const
 }
 
 
-void InsetMathChar::write(WriteStream & os) const
+void InsetMathChar::write(TeXMathStream & os) const
 {
        os.os().put(char_);
 }
@@ -216,7 +228,7 @@ void InsetMathChar::octave(OctaveStream & os) const
 // mathalpha, then we'll treat it as an identifier, otherwise as an
 // operator.
 // Worst case: We get bad spacing, or bad italics.
-void InsetMathChar::mathmlize(MathStream & ms) const
+void InsetMathChar::mathmlize(MathMLStream & ms) const
 {
        std::string entity;
        switch (char_) {
@@ -224,7 +236,10 @@ void InsetMathChar::mathmlize(MathStream & ms) const
                case '>': entity = ">"; break;
                case '&': entity = "&"; break;
                case ' ': {
-                       ms << from_ascii("&nbsp;");
+                       if (ms.xmlMode())
+                               ms << from_ascii("&#0160;");
+                       else
+                               ms << from_ascii("&nbsp;");
                        return;
                }
                default: break;