]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathKern.cpp
Account for old versions of Pygments
[lyx.git] / src / mathed / InsetMathKern.cpp
index ccb01c411ba816b22b751bed83cc4eba331bb1fd..d223887e3b6c2d712f0c9a4a1b577dc1e285b70c 100644 (file)
 #include <config.h>
 
 #include "InsetMathKern.h"
-#include "MathStream.h"
+
 #include "MathStream.h"
 #include "MathSupport.h"
+
 #include "Dimension.h"
+#include "MetricsInfo.h"
 
 #include "support/docstring.h"
 
@@ -47,7 +49,7 @@ void InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        dim.asc = 0;
        dim.des = 0;
-       dim.wid = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M'));
+       dim.wid = wid_.inPixels(mi.base);
 }
 
 
@@ -57,13 +59,29 @@ void InsetMathKern::draw(PainterInfo &, int, int) const
 
 void InsetMathKern::write(WriteStream & os) const
 {
-       os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
+       if (wid_.empty())
+               os << "\\kern" << ' ';
+       else if (wid_.unit() == Length::MU)
+               os << "\\mkern" << from_utf8(wid_.asLatexString()) << ' ';
+       else
+               os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
 }
 
 
 void InsetMathKern::normalize(NormalStream & os) const
 {
-       os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
+       if (wid_.empty())
+               os << "[kern]";
+       else
+               os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
+}
+
+
+void InsetMathKern::infoize2(odocstream & os) const
+{
+       os << "Kern";
+       if (!wid_.empty())
+               os << ": " << from_utf8(wid_.asLatexString());
 }