X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathSpecialChar.cpp;h=701bcc86862d37d1406ae7958dbcbb51f4fcd3d2;hb=f9835d054d7aac5830ec6bb5a3537c2b4fa2d269;hp=6157c7977a023fb949e28119c67e9090a1095b41;hpb=7d4ec3f9440d70894e5a8d4cc578d9ef4c825764;p=lyx.git diff --git a/src/mathed/InsetMathSpecialChar.cpp b/src/mathed/InsetMathSpecialChar.cpp index 6157c7977a..701bcc8686 100644 --- a/src/mathed/InsetMathSpecialChar.cpp +++ b/src/mathed/InsetMathSpecialChar.cpp @@ -21,6 +21,7 @@ #include "TextPainter.h" #include "frontends/FontMetrics.h" +#include "frontends/Painter.h" #include "support/lassert.h" @@ -28,19 +29,18 @@ 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 << "&"; + break; + default: + ms.os().put(char_); + break; + } +} + + } // namespace lyx