]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathChar.cpp
Revert "XHTML: remove DOCTYPE, as the document is then understood as HTML4/XHTML1...
[lyx.git] / src / mathed / InsetMathChar.cpp
index 1137c95e75a8b0e709f91169b52465978ccc837d..aa1ddf8c5b7657c02393f4c1906e14a1ad29c730 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_)
+                               ? Changer()
+                               : 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_)
+                                       ? Changer()
+                                       : pi.base.font.changeShape(UP_SHAPE);
+                       pi.draw(x, y, char_);
+                       return;
                }
        }
        // cmmi has almost no left bearing: simulate this
@@ -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;
@@ -239,15 +254,18 @@ void InsetMathChar::mathmlize(MathStream & ms) const
        }
 
        if (!entity.empty()) {
-               ms << "<mo>" << from_ascii(entity) << "</mo>";
+               ms << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+                  << from_ascii(entity)
+                  << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
                return;
        }
 
        char const * type =
                (isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
                        ? "mi" : "mo";
-       // we don't use MTag and ETag because we do not want the spacing
-       ms << "<" << type << ">" << char_type(char_) << "</" << type << ">";
+       // we don't use MTag and ETag because we do not want the spacing before the end tag.
+       docstring tag = from_ascii(ms.namespacedTag(type));
+       ms << "<" << tag << ">" << char_type(char_) << "</" << tag << ">";
 }