Better alignment of \longrightarrow like macros.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5432 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-10-17 13:15:25 +00:00
parent 5a601958b2
commit dde4440425
6 changed files with 64 additions and 31 deletions

View 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

View 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

View 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));
}

View 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.

View 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;
}

View 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);
}