]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSpecialChar.cpp
Fix bug #10295.
[lyx.git] / src / mathed / InsetMathSpecialChar.cpp
index 6157c7977a023fb949e28119c67e9090a1095b41..701bcc86862d37d1406ae7958dbcbb51f4fcd3d2 100644 (file)
@@ -21,6 +21,7 @@
 #include "TextPainter.h"
 
 #include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
 
 #include "support/lassert.h"
 
 namespace lyx {
 
 
-InsetMathSpecialChar::InsetMathSpecialChar(docstring name)
+InsetMathSpecialChar::InsetMathSpecialChar(docstring const & name)
        : name_(name), kerning_(0)
 {
        if (name.size() != 1) {
-               if (name == from_ascii("textasciicircum")
-                   || name == from_ascii("mathcircumflex"))
+               if (name == "textasciicircum" || name == "mathcircumflex")
                        char_ = '^';
-               else if (name == from_ascii("textasciitilde"))
+               else if (name == "textasciitilde")
                        char_ = '~';
-               else if (name == from_ascii("textbackslash"))
+               else if (name == "textbackslash")
                        char_ = '\\';
                else
-                       LASSERT(false, /**/);
+                       LASSERT(false, char_ = '?');
        } else
                char_ = name.at(0);
 }
@@ -56,12 +56,12 @@ Inset * InsetMathSpecialChar::clone() const
 void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (mi.base.fontname == "mathnormal") {
-               ShapeChanger dummy(mi.base.font, UP_SHAPE);
+               Changer dummy = mi.base.font.changeShape(UP_SHAPE);;
                dim = theFontMetrics(mi.base.font).dimension(char_);
        } else {
                frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
                dim = fm.dimension(char_);
-               kerning_ = fm.rbearing(char_) - dim.wid;
+               kerning_ = mathed_char_kerning(mi.base.font, char_);
        }
 }
 
@@ -69,7 +69,7 @@ void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const
 {
        if (pi.base.fontname == "mathnormal") {
-               ShapeChanger dummy(pi.base.font, UP_SHAPE);
+               Changer dummy = pi.base.font.changeShape(UP_SHAPE);
                pi.draw(x, y, char_);
        } else {
                pi.draw(x, y, char_);
@@ -145,4 +145,17 @@ void InsetMathSpecialChar::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathSpecialChar::htmlize(HtmlStream & ms) const
+{
+       switch (char_) {
+       case '&':
+               ms << "&amp;";
+               break;
+       default:
+               ms.os().put(char_);
+               break;
+       }
+}
+
+
 } // namespace lyx