]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_kerninset.C
oh well
[lyx.git] / src / mathed / math_kerninset.C
index 91701166a83f46a908325c49cb31792cfe636182..e2d8b60e52a3e5a06ea38434c45b5efc67f5d02b 100644 (file)
@@ -9,11 +9,20 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
-#include "font.h"
+#include "lyxrc.h"
 
 
 MathKernInset::MathKernInset()
-       : MathNestInset(1)
+{}
+
+
+MathKernInset::MathKernInset(LyXLength const & w)
+       : wid_(w)
+{}
+
+
+MathKernInset::MathKernInset(string const & s)
+       : wid_(s)
 {}
 
 
@@ -23,15 +32,17 @@ MathInset * MathKernInset::clone() const
 }
 
 
-void MathKernInset::metrics(MathMetricsInfo const & mi) const
+void MathKernInset::metrics(MathMetricsInfo const & /*mi*/) const
 {
-       LyXFont font;
-       whichFont(font, LM_TC_TEXTRM, mi);
-       double t;
-       extractNumber(cell(0), t);
-       width_   = int(t * lyxfont::width('m', font));
+#ifdef WITH_WARNINGS
+#warning fix this once the interface to LyXLength has improved
+#endif
+       // this uses the numerical valu in pixels, even if the unit is cm or ex!
+       width_   = static_cast<int>(wid_.value());
+       width_   = (width_*static_cast<int>(lyxrc.zoom))/150;
        ascent_  = 0;
        descent_ = 0;
+       //cerr << "handling kern of width " << wid_.value() << "\n";
 }
 
 
@@ -41,11 +52,11 @@ void MathKernInset::draw(Painter &, int, int) const
 
 void MathKernInset::write(WriteStream & os) const
 {
-       os << "\\lyxkern" << cell(0) << "em ";
+       os << "\\kern" << wid_.asLatexString() << " ";
 }
 
 
 void MathKernInset::normalize(NormalStream & os) const
 {
-       os << "[lyxkern " << cell(0) << "em]";
+       os << "[kern " << wid_.asLatexString() << "]";
 }