From 49295aa9be2197028f707daa4cc36d9244fd34a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 31 Oct 2001 10:54:34 +0000 Subject: [PATCH] fix drawing of mathrels. make \| equivalent to \Vert instead of \parallel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2949 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/BUGS | 2 ++ src/mathed/math_defs.h | 20 -------------------- src/mathed/math_macro.C | 8 ++++---- src/mathed/math_macrotable.C | 2 +- src/mathed/math_symbolinset.C | 21 +++++++++++++-------- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/mathed/BUGS b/src/mathed/BUGS index 679e64204c..bd9af09116 100644 --- a/src/mathed/BUGS +++ b/src/mathed/BUGS @@ -34,6 +34,8 @@ General hints for bug reports: ---------------------------------------------------------------------- +- \matrm{xy} gets written as \mathrm{x}\mathrm{y} + Dekel: Macros: diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index 6b49f5db9d..c1c6f04f55 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -127,26 +127,6 @@ enum MathSymbolTypes { LMB_RELATION, /// LMB_OPERATOR, - /// - LMB_BOP = (LMB_RELATION | LMB_OPERATOR) -}; - - -/// Paragraph permissions -enum MathParFlag { - LMPF_BASIC = 0, - /// If false can use a non-standard size - LMPF_FIXED_SIZE = 1, - /// If true can insert newlines - LMPF_ALLOW_CR = 2, - /// If true can use tabs - LMPF_ALLOW_TAB = 4, - /// If true can insert new columns - LMPF_ALLOW_NEW_COL = 8, - /// Smaller than current size (frac) - LMPF_SMALLER = 16, - /// Script size (subscript, stackrel) - LMPF_SCRIPT = 32 }; #endif diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 5872f070d5..f65f7c551e 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -105,9 +105,9 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const expanded_ = tmplate_->xcell(0); expanded_.data_.substitute(*this); expanded_.metrics(mi_); - width_ = expanded_.width() + 6; - ascent_ = expanded_.ascent() + 3; - descent_ = expanded_.descent() + 3; + width_ = expanded_.width(); + ascent_ = expanded_.ascent(); + descent_ = expanded_.descent(); } @@ -145,7 +145,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const return; } - expanded_.draw(pain, x + 3, y); + expanded_.draw(pain, x, y); } diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index c120da64f8..89065350ab 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -92,7 +92,7 @@ void MathMacroTable::builtinMacros() create("owns", 0, "\\ni"); create("gets", 0, "\\leftarrow"); create("to", 0, "\\rightarrow"); - create("|", 0, "\\parallel"); + create("|", 0, "\\Vert"); create("longleftrightarrow", 0, "\\leftarrow\\kern-6mu\\rightarrow"); create("Longleftrightarrow", 0, "\\Leftarrow\\kern-6mu\\Rightarrow"); diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index e27fbe1bc9..c895aa8951 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -1,5 +1,6 @@ #include "math_symbolinset.h" #include "math_parser.h" +#include "debug.h" #include "support.h" #include "support/LOstream.h" @@ -7,7 +8,8 @@ using std::ostream; MathSymbolInset::MathSymbolInset(const latexkeys * l) - : sym_(l), h_(0) {} + : sym_(l), h_(0) +{} MathInset * MathSymbolInset::clone() const @@ -69,18 +71,21 @@ void MathSymbolInset::metrics(MathMetricsInfo const & mi) const ascent_ += h_; descent_ -= h_; } - return; + } else { + if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB)) + mathed_char_dim(code2(), mi_, sym_->id, ascent_, descent_, width_); + else + mathed_string_dim(LM_TC_TEX, mi_, sym_->name, ascent_, descent_, width_); } - - if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB)) - mathed_char_dim(code2(), mi_, sym_->id, ascent_, descent_, width_); - else - mathed_string_dim(LM_TC_TEX, mi_, sym_->name, ascent_, descent_, width_); + if (isRelOp()) + width_ += mathed_char_width(LM_TC_TEX, mi_, 'I'); } void MathSymbolInset::draw(Painter & pain, int x, int y) const { + if (isRelOp()) + x += mathed_char_width(LM_TC_TEX, mi_, 'I') / 2; MathTextCodes Code = code(); if (sym_->latex_font_id > 0 && math_font_available(Code)) drawChar(pain, Code, mi_, x, y - h_, sym_->latex_font_id); @@ -92,7 +97,7 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const bool MathSymbolInset::isRelOp() const -{ +{ return sym_->type == LMB_RELATION; }