]> git.lyx.org Git - features.git/commitdiff
Few improvements.
authorDekel Tsur <dekelts@tau.ac.il>
Mon, 28 Oct 2002 10:39:12 +0000 (10:39 +0000)
committerDekel Tsur <dekelts@tau.ac.il>
Mon, 28 Oct 2002 10:39:12 +0000 (10:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5527 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_charinset.C
src/mathed/math_factory.C
src/mathed/math_symbolinset.C

index 8a953d3c3ecd368682dd0211a27ad161eed7812b..641f92fa677703fa6682892c8dd878440a098d83 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-28  Dekel Tsur  <dekelts@tau.ac.il>
+
+       * math_symbolinset.C (metrics): Compute em with the default font.
+
+       * math_charinset.C (draw): Use math symbol fonts for <,> & =
 
 2002-10-21  Dekel Tsur  <dekelts@tau.ac.il>
 
index b44ad7111f438ce21a8d89695a179304707365ed..6b6c5f8202ecea8304e6c69e6f5caa273f309072 100644 (file)
@@ -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<int>(0.5*em+0.5);
+       else if (char_ == '\'')
+               dim_.w += static_cast<int>(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<int>(0.25*em+0.5);
+       else if (char_ == '\'')
+               x += static_cast<int>(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 {
index c6bd7ae99767dbcad2a9c77c270b049d392784d5..7858e4bfb903ddbf06fc6a6c2e70347164cc1d7f 100644 (file)
@@ -54,6 +54,7 @@
 #include <map>
 #include <fstream>
 
+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);
 }
 
 
index c8f7e061901e67ccc4bc05f0783435645a6a4d7d..8463bc998da5c1a60255b29b791dc132910e6a75 100644 (file)
@@ -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<int>(0.5*em+0.5);
        else
-               dim_.w += static_cast<int>(0.15*em+0.5);
+               dim_.w += static_cast<int>(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<int>(0.25*em+0.5);
        else
-               x += static_cast<int>(0.075*em+0.5);
+               x += static_cast<int>(0.0833*em+0.5);
 
        MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
        drawStr(pi, pi.base.font, x, y - h_, sym_->draw);