Few improvements.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5527 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-10-28 10:39:12 +00:00
parent 59b0558eca
commit 05b8faa706
4 changed files with 36 additions and 8 deletions

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

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

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

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