&& s[2] >= '1' && s[2] <= '9')
return MathAtom(new MathMacroArgument(s[2] - '0'));
- if (s == "lyxkern")
+ if (s == "kern")
return MathAtom(new MathKernInset);
if (s == "xymatrix")
#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)
{}
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";
}
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() << "]";
}
#ifndef MATH_CHEATINSET_H
#define MATH_CHEATINSET_H
+#include "math_diminset.h"
+#include "vspace.h"
+#include "LString.h"
#include "math_nestinset.h"
#ifdef __GNUG__
#pragma interface
#endif
+/// The \kern primitive
/// Some hack for visual effects
-class MathKernInset : public MathNestInset {
+class MathKernInset : public MathDimInset {
public:
///
MathKernInset();
///
+ explicit MathKernInset(LyXLength const & wid);
+ ///
+ explicit MathKernInset(string const & wid);
+ ///
MathInset * clone() const;
///
void draw(Painter &, int x, int y) const;
///
void normalize(NormalStream & ns) const;
///
- void metrics(MathMetricsInfo const &cwmist) const;
+ void metrics(MathMetricsInfo const & st) const;
+private:
+ /// width in em
+ LyXLength wid_;
};
#endif
lyxerr << "unknow math inset begin '" << name << "'\n";
}
-/*
else if (t.cs() == "kern") {
#ifdef WITH_WARNINGS
#warning A hack...
break;
}
array.push_back(MathAtom(new MathKernInset(s)));
-*/
+ }
+/*
else if (t.cs() == "lyxkern") {
MathAtom p = createMathInset(t.cs());
parse_into(p->cell(0), flags, code);
array.push_back(p);
}
+*/
else if (t.cs() == "label") {
curr_label_ = getArg('{', '}');