]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSpace.cpp
Accept \kern and \mkern for math kerning
[lyx.git] / src / mathed / InsetMathSpace.cpp
index e53c62e6ee6747d9ab644b7e7f595f0e59fd3946..39f3147bf1b3603864260e802beced96fcc2f29d 100644 (file)
@@ -21,6 +21,7 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
+#include "MetricsInfo.h"
 
 #include "insets/InsetSpace.h"
 
@@ -120,12 +121,11 @@ Inset * InsetMathSpace::clone() const
 
 void InsetMathSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+       Changer dummy = mi.base.changeEnsureMath();
        dim.asc = 4;
        dim.des = 0;
        if (space_info[space_].custom)
-               dim.wid = abs(length_.inPixels(
-                               mi.base.textwidth,
-                               mathed_char_width(mi.base.font, 'M')));
+               dim.wid = abs(length_.inPixels(mi.base));
        else
                dim.wid = space_info[space_].width;
 }
@@ -133,6 +133,7 @@ void InsetMathSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetMathSpace::draw(PainterInfo & pi, int x, int y) const
 {
+       Changer dummy = pi.base.changeEnsureMath();
        // Sadly, HP-UX CC can't handle that kind of initialization.
        // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
        if (!space_info[space_].visible)
@@ -267,30 +268,32 @@ void InsetMathSpace::normalize(NormalStream & os) const
 
 void InsetMathSpace::write(WriteStream & os) const
 {
-       // no MathEnsurer - all kinds work in text and math mode
+       // All kinds work in text and math mode, so simply suspend
+       // writing a possibly pending mode closing brace.
+       MathEnsurer ensurer(os, false);
        if (space_info[space_].escape)
                os << '\\';
        os << space_info[space_].name.c_str();
        if (space_info[space_].custom)
                os << '{' << length_.asLatexString().c_str() << '}';
-       else if (space_info[space_].escape && space_info[space_].name != " ")
+       else if (space_info[space_].escape && space_info[space_].name.length() > 1)
                os.pendingSpace(true);
 }
 
 
 InsetSpaceParams InsetMathSpace::params() const
 {
-       LASSERT(space_info[space_].visible, /**/);
        InsetSpaceParams isp(true);
+       LASSERT(space_info[space_].visible, return isp);
        isp.kind = space_info[space_].kind;
        isp.length = GlueLength(length_);
        return isp;
 }
 
 
-docstring InsetMathSpace::contextMenuName() const
+string InsetMathSpace::contextMenuName() const
 {
-       return from_ascii("context-mathspace");
+       return "context-mathspace";
 }