{
LyXFont font;
whichFont(font, LM_TC_VAR, mi);
- double h = mathed_char_height(font, 'I', ascent_, descent_);
+ double h = mathed_char_ascent(font, 'I');
double f = increase();
width_ = 6;
ascent_ = int(h + f * h);
#include "LColor.h"
#include "Painter.h"
#include "support/LOstream.h"
-#include "math_support.h"
-#include "math_parser.h"
+#include "font.h"
#include "debug.h"
+#include "math_support.h"
#include "math_mathmlstream.h"
#include "LaTeXFeatures.h"
#include "textpainter.h"
using std::ostream;
+using std::endl;
+
+
+bool isBinaryOp(char c, MathTextCodes type)
+{
+ return type < LM_TC_SYMB && strchr("+-<>=/*", c);
+}
MathCharInset::MathCharInset(char c)
{
whichFont(font_, code_, mi);
mathed_char_dim(font_, char_, ascent_, descent_, width_);
+ if (isBinaryOp(char_, code_))
+ width_ += 2 * lyxfont::width(' ', font_);
}
void MathCharInset::draw(Painter & pain, int x, int y) const
{
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
+ if (isBinaryOp(char_, code_))
+ x += lyxfont::width(' ', font_);
drawChar(pain, font_, x, y, char_);
}
void MathCharInset::draw(TextPainter & pain, int x, int y) const
{
- lyxerr << "drawing text '" << char_ << "' code: " << code_ << endl;
+ //lyxerr << "drawing text '" << char_ << "' code: " << code_ << endl;
pain.draw(x, y, char_);
}
using std::max;
-bool isBinaryOp(char c, MathTextCodes type)
-{
- return type < LM_TC_SYMB && strchr("+-<>=/*", c);
-}
-
-
///
class Matrix {
public:
}
-int mathed_char_height(LyXFont const & font,
- unsigned char c, int & asc, int & des)
-{
- des = lyxfont::descent(c, font);
- asc = lyxfont::ascent(c, font);
- return asc + des;
-}
-
-
-int mathed_char_height(LyXFont const & font, unsigned char c)
-{
- int asc;
- int des;
- return mathed_char_height(font, c, asc, des);
-}
-
-
int mathed_char_ascent(LyXFont const & font, unsigned char c)
{
return lyxfont::ascent(c, font);
}
-int mathed_char_width(LyXFont const & font,
- unsigned char c)
+int mathed_char_width(LyXFont const & font, unsigned char c)
{
- //if (isBinaryOp(c, type))
- // return lyxfont::width(c, font) + 2 * lyxfont::width(' ', font);
return lyxfont::width(c, font);
}
void mathed_string_dim(LyXFont const & font,
string const & s, int & asc, int & des, int & wid)
-{
- mathed_string_height(font, s, asc, des);
- wid = mathed_string_width(font, s);
-}
-
-
-int mathed_string_height(LyXFont const & font,
- string const & s, int & asc, int & des)
{
asc = des = 0;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
des = max(des, lyxfont::descent(*it, font));
asc = max(asc, lyxfont::ascent(*it, font));
}
- return asc + des;
+ wid = lyxfont::width(s, font);
}
void drawChar(Painter & pain, LyXFont const & font, int x, int y, char c)
{
- //if (isBinaryOp(c, type))
- // x += lyxfont::width(' ', font);
pain.text(x, y, c, font);
}
void mathed_char_dim(LyXFont const &, unsigned char c,
int & asc, int & des, int & wid);
-int mathed_char_height(LyXFont const &, unsigned char c, int & asc, int & des);
int mathed_char_width(LyXFont const &, unsigned char c);
int mathed_char_ascent(LyXFont const &, unsigned char c);
int mathed_char_descent(LyXFont const &, unsigned char c);
void mathed_string_dim(LyXFont const &,
string const & s, int & asc, int & des, int & wid);
-int mathed_string_height(LyXFont const &,
- string const & s, int & asc, int & des);
int mathed_string_width(LyXFont const &, string const & s);
int mathed_string_ascent(LyXFont const &, string const & s);