mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Few improvements.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5527 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
59b0558eca
commit
05b8faa706
@ -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>
|
2002-10-21 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ using std::strchr;
|
|||||||
using std::isalpha;
|
using std::isalpha;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern bool has_math_fonts;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -60,14 +61,23 @@ MathInset * MathCharInset::clone() const
|
|||||||
void MathCharInset::metrics(MathMetricsInfo & mi) const
|
void MathCharInset::metrics(MathMetricsInfo & mi) const
|
||||||
{
|
{
|
||||||
#if 1
|
#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);
|
MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
|
||||||
mathed_char_dim(mi.base.font, char_, dim_);
|
mathed_char_dim(mi.base.font, char_, dim_);
|
||||||
} else {
|
} else {
|
||||||
mathed_char_dim(mi.base.font, char_, dim_);
|
mathed_char_dim(mi.base.font, char_, dim_);
|
||||||
}
|
}
|
||||||
|
int const em = mathed_char_width(mi.base.font, 'M');
|
||||||
if (isBinaryOp(char_))
|
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
|
#else
|
||||||
whichFont(font_, code_, mi);
|
whichFont(font_, code_, mi);
|
||||||
mathed_char_dim(font_, char_, dim_);
|
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
|
void MathCharInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
//lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << endl;
|
//lyxerr << "drawing '" << char_ << "' font: " << pi.base.fontname << endl;
|
||||||
|
int const em = mathed_char_width(pi.base.font, 'M');
|
||||||
if (isBinaryOp(char_))
|
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 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);
|
MathShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE);
|
||||||
pi.draw(x, y, char_);
|
pi.draw(x, y, char_);
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
bool has_math_fonts;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ void initSymbols()
|
|||||||
if (line.size() > 0 && line[0] == '#')
|
if (line.size() > 0 && line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// special case of \iffont / \fi
|
// special case of iffont/else/endif
|
||||||
if (line.size() >= 7 && line.substr(0, 6) == "iffont") {
|
if (line.size() >= 7 && line.substr(0, 6) == "iffont") {
|
||||||
istringstream is(line);
|
istringstream is(line);
|
||||||
string tmp;
|
string tmp;
|
||||||
@ -177,6 +178,9 @@ void initSymbols()
|
|||||||
<< " extra: " << tmp.extra
|
<< " extra: " << tmp.extra
|
||||||
<< "'\n";
|
<< "'\n";
|
||||||
}
|
}
|
||||||
|
string tmp = "cmm";
|
||||||
|
string tmp2 = "cmsy";
|
||||||
|
has_math_fonts = math_font_available(tmp) && math_font_available(tmp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
|
|||||||
// << "' drawn as: '" << sym_->draw
|
// << "' drawn as: '" << sym_->draw
|
||||||
// << "'\n";
|
// << "'\n";
|
||||||
|
|
||||||
|
int const em = mathed_char_width(mi.base.font, 'M');
|
||||||
MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
|
MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
|
||||||
mathed_string_dim(mi.base.font, sym_->draw, dim_);
|
mathed_string_dim(mi.base.font, sym_->draw, dim_);
|
||||||
// correct height for broken cmex and wasy font
|
// correct height for broken cmex and wasy font
|
||||||
@ -57,11 +58,10 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
|
|||||||
dim_.d -= h_;
|
dim_.d -= h_;
|
||||||
}
|
}
|
||||||
// seperate things a bit
|
// seperate things a bit
|
||||||
int const em = mathed_char_width(mi.base.font, 'M');
|
|
||||||
if (isRelOp())
|
if (isRelOp())
|
||||||
dim_.w += static_cast<int>(0.5*em+0.5);
|
dim_.w += static_cast<int>(0.5*em+0.5);
|
||||||
else
|
else
|
||||||
dim_.w += static_cast<int>(0.15*em+0.5);
|
dim_.w += static_cast<int>(0.1667*em+0.5);
|
||||||
|
|
||||||
scriptable_ = false;
|
scriptable_ = false;
|
||||||
if (mi.base.style == LM_ST_DISPLAY)
|
if (mi.base.style == LM_ST_DISPLAY)
|
||||||
@ -80,7 +80,7 @@ void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
|
|||||||
if (isRelOp())
|
if (isRelOp())
|
||||||
x += static_cast<int>(0.25*em+0.5);
|
x += static_cast<int>(0.25*em+0.5);
|
||||||
else
|
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());
|
MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
|
||||||
drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
|
drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
|
||||||
|
Loading…
Reference in New Issue
Block a user