From dde44404255ad78ad651db2b815211fc59dcec25 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Thu, 17 Oct 2002 13:15:25 +0000 Subject: [PATCH] Better alignment of \longrightarrow like macros. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5432 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/symbols | 41 +++++++++++++++++++++++------------ src/ChangeLog | 5 +++++ src/lyxlength.C | 17 ++++++++------- src/mathed/ChangeLog | 4 ++++ src/mathed/math_kerninset.C | 5 ++--- src/mathed/math_symbolinset.C | 23 +++++++++++++++----- 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/lib/symbols b/lib/symbols index ffb4d31e07..655b581a23 100644 --- a/lib/symbols +++ b/lib/symbols @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index bf87efabf9..ffc28e8dcf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-10-17 Dekel Tsur + + * lyxlength.C (inPixels): Fix hanfling of negative length. + Fix LyXLength::MU case. + 2002-10-16 John Levon * buffer.C: remove \\protected_separator parsing done by lyx2lyx now diff --git a/src/lyxlength.C b/src/lyxlength.C index b9586b1c3b..77218b3e7b 100644 --- a/src/lyxlength.C +++ b/src/lyxlength.C @@ -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(result * val_sign + 0.5); + return static_cast(result + ((result >= 0) ? 0.5 : -0.5)); } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 417ba8d5b7..78e9b93bb1 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2002-10-17 Dekel Tsur + + * math_kerninset.C (metrics): Use LyXLength::inPixels. + 2002-10-14 Dekel Tsur * math_factory.C (initSymbols): iffont. diff --git a/src/mathed/math_kerninset.C b/src/mathed/math_kerninset.C index 768eb31cea..04335abdeb 100644 --- a/src/mathed/math_kerninset.C +++ b/src/mathed/math_kerninset.C @@ -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; } diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index 1bacd342c3..36f6fcf88c 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -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(0.5*em+0.5); + else + dim_.w += static_cast(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(0.25*em+0.5); + else + x += static_cast(0.075*em+0.5); + MathFontSetChanger dummy(pi.base, sym_->inset.c_str()); drawStr(pi, pi.base.font, x, y - h_, sym_->draw); } -- 2.39.2