]> git.lyx.org Git - lyx.git/commitdiff
bugfix for compound 'symbols' using \lyxkern
authorAndré Pönitz <poenitz@gmx.net>
Wed, 27 Mar 2002 10:51:46 +0000 (10:51 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 27 Mar 2002 10:51:46 +0000 (10:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3850 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_factory.C
src/mathed/math_kerninset.C
src/mathed/math_kerninset.h
src/mathed/math_parser.C

index 4a966d99e077febe9a9ce705c08d0c7f8e016c84..ec39ab9636a50569b58de84412bcfb5228ea1604 100644 (file)
@@ -96,7 +96,7 @@ MathAtom createMathInset(string const & s)
                        && 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")
index 91701166a83f46a908325c49cb31792cfe636182..af155e68befad60ec615e22dbf6af751805884e1 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)
 {}
 
 
@@ -25,13 +34,15 @@ MathInset * MathKernInset::clone() 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() << "]";
 }
index 69da69f96152c45d59cba63f19a15b1d9685cbb7..5af50f4651e47722c097536fa7846ca3effed3ad 100644 (file)
@@ -2,19 +2,27 @@
 #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;
@@ -23,6 +31,9 @@ public:
        ///
        void normalize(NormalStream & ns) const;
        ///
-       void metrics(MathMetricsInfo const &cwmist) const;
+       void metrics(MathMetricsInfo const & st) const;
+private:
+       /// width in em
+       LyXLength wid_;
 };
 #endif
index afee0c7c5e071f6e2146bd7ce913bed1aaf4ee40..a398178a5707699fe79f5373d45ca6d36f5e367c 100644 (file)
@@ -1112,7 +1112,6 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                                lyxerr << "unknow math inset begin '" << name << "'\n";
                }
 
-/*
                else if (t.cs() == "kern") {
 #ifdef WITH_WARNINGS
 #warning A hack...
@@ -1129,13 +1128,15 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                                        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('{', '}');