diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 8a953d3c3e..641f92fa67 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2002-10-28 Dekel Tsur + + * math_symbolinset.C (metrics): Compute em with the default font. + + * math_charinset.C (draw): Use math symbol fonts for <,> & = 2002-10-21 Dekel Tsur diff --git a/src/mathed/math_charinset.C b/src/mathed/math_charinset.C index b44ad7111f..6b6c5f8202 100644 --- a/src/mathed/math_charinset.C +++ b/src/mathed/math_charinset.C @@ -27,6 +27,7 @@ using std::strchr; using std::isalpha; #endif +extern bool has_math_fonts; namespace { @@ -60,14 +61,23 @@ MathInset * MathCharInset::clone() const void MathCharInset::metrics(MathMetricsInfo & mi) const { #if 1 - if (slanted(char_) && mi.base.fontname == "mathnormal") { + if (char_ == '=' && has_math_fonts) { + MathFontSetChanger dummy(mi.base, "cmr"); + mathed_char_dim(mi.base.font, char_, dim_); + } else if ((char_ == '>' || char_ == '<') && has_math_fonts) { + MathFontSetChanger dummy(mi.base, "cmm"); + mathed_char_dim(mi.base.font, char_, dim_); + } else if (slanted(char_) && mi.base.fontname == "mathnormal") { MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE); mathed_char_dim(mi.base.font, char_, dim_); } else { mathed_char_dim(mi.base.font, char_, dim_); } + int const em = mathed_char_width(mi.base.font, 'M'); if (isBinaryOp(char_)) - dim_.w += 2 * font_metrics::width(' ', mi.base.font); + dim_.w += static_cast(0.5*em+0.5); + else if (char_ == '\'') + dim_.w += static_cast(0.1667*em+0.5); #else whichFont(font_, code_, mi); mathed_char_dim(font_, char_, dim_); @@ -81,10 +91,19 @@ void MathCharInset::metrics(MathMetricsInfo & mi) const void MathCharInset::draw(MathPainterInfo & pi, int x, int y) const { //lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << endl; + int const em = mathed_char_width(pi.base.font, 'M'); if (isBinaryOp(char_)) - x += font_metrics::width(' ', pi.base.font); + x += static_cast(0.25*em+0.5); + else if (char_ == '\'') + x += static_cast(0.0833*em+0.5); #if 1 - if (slanted(char_) && pi.base.fontname == "mathnormal") { + if (char_ == '=' && has_math_fonts) { + MathFontSetChanger dummy(pi.base, "cmr"); + pi.draw(x, y, char_); + } else if ((char_ == '>' || char_ == '<') && has_math_fonts) { + MathFontSetChanger dummy(pi.base, "cmm"); + pi.draw(x, y, char_); + } else if (slanted(char_) && pi.base.fontname == "mathnormal") { MathShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE); pi.draw(x, y, char_); } else { diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index c6bd7ae997..7858e4bfb9 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -54,6 +54,7 @@ #include #include +bool has_math_fonts; namespace { @@ -101,7 +102,7 @@ void initSymbols() if (line.size() > 0 && line[0] == '#') continue; - // special case of \iffont / \fi + // special case of iffont/else/endif if (line.size() >= 7 && line.substr(0, 6) == "iffont") { istringstream is(line); string tmp; @@ -177,6 +178,9 @@ void initSymbols() << " extra: " << tmp.extra << "'\n"; } + string tmp = "cmm"; + string tmp2 = "cmsy"; + has_math_fonts = math_font_available(tmp) && math_font_available(tmp2); } diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index c8f7e06190..8463bc998d 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -48,6 +48,7 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const // << "' drawn as: '" << sym_->draw // << "'\n"; + int const em = mathed_char_width(mi.base.font, 'M'); 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 @@ -57,11 +58,10 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const dim_.d -= h_; } // seperate things a bit - int const em = mathed_char_width(mi.base.font, 'M'); if (isRelOp()) dim_.w += static_cast(0.5*em+0.5); else - dim_.w += static_cast(0.15*em+0.5); + dim_.w += static_cast(0.1667*em+0.5); scriptable_ = false; if (mi.base.style == LM_ST_DISPLAY) @@ -80,7 +80,7 @@ void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const if (isRelOp()) x += static_cast(0.25*em+0.5); else - x += static_cast(0.075*em+0.5); + x += static_cast(0.0833*em+0.5); MathFontSetChanger dummy(pi.base, sym_->inset.c_str()); drawStr(pi, pi.base.font, x, y - h_, sym_->draw);