]> git.lyx.org Git - features.git/commitdiff
Better alignment of \longrightarrow like macros.
authorDekel Tsur <dekelts@tau.ac.il>
Thu, 17 Oct 2002 13:15:25 +0000 (13:15 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Thu, 17 Oct 2002 13:15:25 +0000 (13:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5432 a592a061-630c-0410-9148-cb99ea01b6c8

lib/symbols
src/ChangeLog
src/lyxlength.C
src/mathed/ChangeLog
src/mathed/math_kerninset.C
src/mathed/math_symbolinset.C

index ffb4d31e07281b76d7e9fcaa3cf9f85dc07541ab..655b581a23fe00fd2fb93da982070ed3db042b20 100644 (file)
@@ -196,7 +196,8 @@ clubsuit           cmsy        124 167 mathord  x
 diamondsuit        cmsy        125 168 mathord  x
 heartsuit          cmsy        126 169 mathord  x
 spadesuit          cmsy        127 170 mathord  x
-not                cmsy         54   0 mathord  x
+# We define \not as mathrel in order to align it properly
+not                cmsy         54   0 mathrel  x 
 coprod             cmex         96   0 mathop   x
 bigvee             cmex         87   0 mathop   x
 bigwedge           cmex         86   0 mathop   x
@@ -763,23 +764,35 @@ $                  mathnormal    0   0 special  x
 # pre-defined macros
 #
 
-\def\longleftrightarrow{\leftarrow\kern-2mm\rightarrow} 
-\def\Longleftrightarrow{\Leftarrow\kern-2mm\Rightarrow}
+\def\notin{\not\in}
+\def\slash{/}
+
+\def\longleftrightarrow{\leftarrow\kern-15mu\rightarrow} 
+\def\Longleftrightarrow{\Leftarrow\kern-15mu\Rightarrow}
 \def\doteq{\stackrel{\cdot}{\=}}
-\def\longrightarrow{\lyxbar\kern-2mm\rightarrow}
-\def\longleftarrow{\leftarrow\kern-2mm\lyxbar}
-\def\mapsto{\mapstochar\kern-2mm\rightarrow}
-\def\longmapsto{\mapstochar\kern-2mm\lyxbar\kern-6mu\rightarrow}
-\def\Longrightarrow{\lyxeq\kern-2mm\Rightarrow}
-\def\Longleftarrow{\Leftarrow\kern-2mm\lyxeq}
-\def\models{\vert\kern-2mm\lyxeq}
-\def\hookrightarrow{\lhook\kern-2mm\rightarrow}
-\def\hookleftarrow{\leftarrow\kern-2mm\rhook}
-\def\bowtie{\triangleright\kern-2mm\triangleleft}
+
+iffont cmsy
+\def\longrightarrow{\lyxbar\kern-11mu\rightarrow}
+\def\longleftarrow{\leftarrow\kern-11mu\lyxbar}
+\def\Longrightarrow{\lyxeq\kern-9mu\Rightarrow}
+\def\Longleftarrow{\Leftarrow\kern-9mu\lyxeq}
+\def\mapsto{\mapstochar\kern-12mu\rightarrow}
+\def\longmapsto{\mapstochar\kern-9mu\lyxbar\kern-11mu\rightarrow}
+\def\models{\vert\kern-7.5mu\lyxeq}
+end
+iffont cmm
+\def\hookrightarrow{\lhook\kern-13mu\rightarrow}
+\def\hookleftarrow{\leftarrow\kern-13mu\rhook}
+\def\bowtie{\triangleright\kern-6mu\triangleleft}
+end
+iffont msa
 \def\dashrightarrow{\lyxdabar\lyxdabar\lyxright}
 \def\dashleftarrow{\lyxleft\lyxdabar\lyxdabar}
 \def\dasharrow{\dashrightarrow}
-\def\Join{\ltimes\kern-2mm\rtimes}
+end
+iffont msb
+\def\Join{\ltimes\kern-12mu\rtimes}
+end
 \def\mathcircumflex{\mbox{\^{}}}
 
 neq                lyxsymbol             185 0 mathrel  x
index bf87efabf9e675c561be44d0f6404dd52fe20b57..ffc28e8dcf8b41b1a2919695bb8f4495f77a0541 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-17  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * lyxlength.C (inPixels): Fix hanfling of negative length.
+       Fix LyXLength::MU case.
+
 2002-10-16  John Levon  <levon@movementarian.org>
 
        * buffer.C: remove \\protected_separator parsing done by lyx2lyx now
index b9586b1c3bb5ef88d4ff211ae8d5bef251eb9a55..77218b3e7b4b862a8253fa1ed0807c2d90fb2b74 100644 (file)
@@ -142,7 +142,6 @@ int LyXLength::inPixels(int default_width, int default_height) const
 #endif
 
        double result = 0.0;
-       int val_sign = val_ < 0.0 ? -1 : 1;
 
        switch (unit_) {
        case LyXLength::SP:
@@ -191,16 +190,18 @@ int LyXLength::inPixels(int default_width, int default_height) const
                break;
        case LyXLength::EX:
                // Ex: The height of an "x"
-               result = zoom * val_ * default_height / 2; // what to / width?
+               // 0.4305 is the ration between 1ex and 1em in cmr10
+               result = zoom * val_ * default_height * 0.4305;
                break;
-       case LyXLength::EM: // what to / width?
+       case LyXLength::EM:
                // Em: The width of an "m"
-               result = zoom * val_ * default_height / 2; // Why 2?
-               break;
-       case LyXLength::MU: // This is probably only allowed in
-               // math mode
+               // 1em is approx 10points in cmr10
                result = zoom * val_ * default_height;
                break;
+       case LyXLength::MU:
+               // math unit = 1/18em
+               result = val_ * default_height / 18;
+               break;
        case LyXLength::PCW: // Always % of workarea
        case LyXLength::PTW:
        case LyXLength::PPW:
@@ -215,7 +216,7 @@ int LyXLength::inPixels(int default_width, int default_height) const
                result = 0;  // this cannot happen
                break;
        }
-       return static_cast<int>(result * val_sign + 0.5);
+       return static_cast<int>(result + ((result >= 0) ? 0.5 : -0.5));
 }
 
 
index 417ba8d5b7ac26d99cba7102a0fb5e3d1f2266ad..78e9b93bb1ed7225a65a92312ad0494f33d2952e 100644 (file)
@@ -1,3 +1,7 @@
+2002-10-17  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * math_kerninset.C (metrics): Use LyXLength::inPixels.
+
 2002-10-14  Dekel Tsur  <dekelts@tau.ac.il>
 
        * math_factory.C (initSymbols): iffont.
index 768eb31cea21bb0a3b4b6a8d68063f0de5bf68a4..04335abdebc96164e089740c14cd09d893a660ab 100644 (file)
@@ -9,7 +9,6 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
-#include "lyxrc.h"
 
 
 MathKernInset::MathKernInset()
@@ -32,9 +31,9 @@ MathInset * MathKernInset::clone() const
 }
 
 
-void MathKernInset::metrics(MathMetricsInfo & /*mi*/) const
+void MathKernInset::metrics(MathMetricsInfo & mi) const
 {
-       dim_.w = wid_.inBP();
+       dim_.w = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M'));
        dim_.a = 0;
        dim_.d = 0;
 }
index 1bacd342c35172565a593a7a935d035c1dce6597..36f6fcf88ccafe98f5ebe4a3e1f534e4cad184c5 100644 (file)
@@ -13,7 +13,6 @@
 #include "LaTeXFeatures.h"
 #include "debug.h"
 
-
 MathSymbolInset::MathSymbolInset(const latexkeys * l)
        : sym_(l), h_(0)
 {}
@@ -48,6 +47,7 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
        //      << "' in font: '" << sym_->inset
        //      << "' drawn as: '" << sym_->draw
        //      << "'\n";
+
        MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
        mathed_string_dim(mi.base.font, sym_->draw, dim_);
        // correct height for broken cmex and wasy font
@@ -56,10 +56,16 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
                dim_.a += h_;
                dim_.d -= h_;
        }
-       if (isRelOp())
-               dim_.w += 6;
        // seperate things a bit
-       dim_.w += 2;
+       int em = mathed_char_width(mi.base.font, 'M');
+       if (name() == "not")
+               // \not is a special case. 
+               // It must have 0 width to align properly with the next symbol.
+               dim_.w = 0;
+       else if (isRelOp())
+               dim_.w += static_cast<int>(0.5*em+0.5);
+       else
+               dim_.w += static_cast<int>(0.15*em+0.5);
 
        scriptable_ = false;
        if (mi.base.style == LM_ST_DISPLAY)
@@ -74,9 +80,14 @@ void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
        //      << "' in font: '" << sym_->inset
        //      << "' drawn as: '" << sym_->draw
        //      << "'\n";
+       int em = mathed_char_width(pi.base.font, 'M');
+       // Here we don't need a special case for \not, as it needs the same
+       // increase in x as the next symbol.
        if (isRelOp())
-               x += 3;
-       x += 1;
+               x += static_cast<int>(0.25*em+0.5);
+       else
+               x += static_cast<int>(0.075*em+0.5);
+
        MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
        drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
 }