#include <config.h>
+#include "MathSupport.h"
+
#include "InsetMath.h"
#include "MathData.h"
#include "MathParser.h"
#include "MathStream.h"
-#include "MathSupport.h"
-
-#include "debug.h"
#include "frontends/FontLoader.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+#include "support/debug.h"
+#include "support/docstream.h"
+
#include <map>
#include <sstream>
+using namespace std;
namespace lyx {
using frontend::Painter;
-using std::max;
-using std::endl;
-using std::vector;
-
///
class Matrix {
};
-std::map<docstring, deco_struct> deco_list;
+map<docstring, deco_struct> deco_list;
// sort the table on startup
class init_deco_table {
deco_struct const * search_deco(docstring const & name)
{
- std::map<docstring, deco_struct>::const_iterator p = deco_list.find(name);
+ map<docstring, deco_struct>::const_iterator p = deco_list.find(name);
return p == deco_list.end() ? 0 : &(p->second);
}
} // namespace anon
-int mathed_char_width(Font const & font, char_type c)
+int mathed_char_width(FontInfo const & font, char_type c)
{
return theFontMetrics(font).width(c);
}
-int mathed_char_kerning(Font const & font, char_type c)
+int mathed_char_kerning(FontInfo const & font, char_type c)
{
frontend::FontMetrics const & fm = theFontMetrics(font);
return fm.rbearing(c) - fm.width(c);
}
-void mathed_string_dim(Font const & font,
+void mathed_string_dim(FontInfo const & font,
docstring const & s,
Dimension & dim)
{
}
-int mathed_string_width(Font const & font, docstring const & s)
+int mathed_string_width(FontInfo const & font, docstring const & s)
{
return theFontMetrics(font).width(s);
}
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
{
- Font f = pi.base.font;
+ FontInfo f = pi.base.font;
f.setColor(Color_latex);
pi.pain.text(x, y, str, f);
}
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & str)
{
- Font f = pi.base.font;
+ FontInfo f = pi.base.font;
f.setColor(Color_foreground);
pi.pain.text(x, y, str, f);
}
-void math_font_max_dim(Font const & font, int & asc, int & des)
+void math_font_max_dim(FontInfo const & font, int & asc, int & des)
{
frontend::FontMetrics const & fm = theFontMetrics(font);
asc = fm.maxAscent();
struct fontinfo {
- std::string cmd_;
- Font::FONT_FAMILY family_;
- Font::FONT_SERIES series_;
- Font::FONT_SHAPE shape_;
+ string cmd_;
+ FontFamily family_;
+ FontSeries series_;
+ FontShape shape_;
ColorCode color_;
};
-Font::FONT_FAMILY const inh_family = Font::INHERIT_FAMILY;
-Font::FONT_SERIES const inh_series = Font::INHERIT_SERIES;
-Font::FONT_SHAPE const inh_shape = Font::INHERIT_SHAPE;
+FontFamily const inh_family = INHERIT_FAMILY;
+FontSeries const inh_series = INHERIT_SERIES;
+FontShape const inh_shape = INHERIT_SHAPE;
// mathnormal should be the first, otherwise the fallback further down
// does not work
fontinfo fontinfos[] = {
// math fonts
- {"mathnormal", Font::ROMAN_FAMILY, Font::MEDIUM_SERIES,
- Font::ITALIC_SHAPE, Color_math},
- {"mathbf", inh_family, Font::BOLD_SERIES,
+ {"mathnormal", ROMAN_FAMILY, MEDIUM_SERIES,
+ ITALIC_SHAPE, Color_math},
+ {"mathbf", inh_family, BOLD_SERIES,
inh_shape, Color_math},
- {"mathcal", Font::CMSY_FAMILY, inh_series,
+ {"mathcal", CMSY_FAMILY, inh_series,
inh_shape, Color_math},
- {"mathfrak", Font::EUFRAK_FAMILY, inh_series,
+ {"mathfrak", EUFRAK_FAMILY, inh_series,
inh_shape, Color_math},
- {"mathrm", Font::ROMAN_FAMILY, inh_series,
- Font::UP_SHAPE, Color_math},
- {"mathsf", Font::SANS_FAMILY, inh_series,
+ {"mathrm", ROMAN_FAMILY, inh_series,
+ UP_SHAPE, Color_math},
+ {"mathsf", SANS_FAMILY, inh_series,
inh_shape, Color_math},
- {"mathbb", Font::MSB_FAMILY, inh_series,
+ {"mathbb", MSB_FAMILY, inh_series,
inh_shape, Color_math},
- {"mathtt", Font::TYPEWRITER_FAMILY, inh_series,
+ {"mathtt", TYPEWRITER_FAMILY, inh_series,
inh_shape, Color_math},
{"mathit", inh_family, inh_series,
- Font::ITALIC_SHAPE, Color_math},
- {"cmex", Font::CMEX_FAMILY, inh_series,
+ ITALIC_SHAPE, Color_math},
+ {"cmex", CMEX_FAMILY, inh_series,
inh_shape, Color_math},
- {"cmm", Font::CMM_FAMILY, inh_series,
+ {"cmm", CMM_FAMILY, inh_series,
inh_shape, Color_math},
- {"cmr", Font::CMR_FAMILY, inh_series,
+ {"cmr", CMR_FAMILY, inh_series,
inh_shape, Color_math},
- {"cmsy", Font::CMSY_FAMILY, inh_series,
+ {"cmsy", CMSY_FAMILY, inh_series,
inh_shape, Color_math},
- {"eufrak", Font::EUFRAK_FAMILY, inh_series,
+ {"eufrak", EUFRAK_FAMILY, inh_series,
inh_shape, Color_math},
- {"msa", Font::MSA_FAMILY, inh_series,
+ {"msa", MSA_FAMILY, inh_series,
inh_shape, Color_math},
- {"msb", Font::MSB_FAMILY, inh_series,
+ {"msb", MSB_FAMILY, inh_series,
inh_shape, Color_math},
- {"wasy", Font::WASY_FAMILY, inh_series,
+ {"wasy", WASY_FAMILY, inh_series,
inh_shape, Color_math},
- {"esint", Font::ESINT_FAMILY, inh_series,
+ {"esint", ESINT_FAMILY, inh_series,
inh_shape, Color_math},
// Text fonts
{"text", inh_family, inh_series,
inh_shape, Color_foreground},
- {"textbf", inh_family, Font::BOLD_SERIES,
+ {"textbf", inh_family, BOLD_SERIES,
inh_shape, Color_foreground},
{"textit", inh_family, inh_series,
- Font::ITALIC_SHAPE, Color_foreground},
- {"textmd", inh_family, Font::MEDIUM_SERIES,
+ ITALIC_SHAPE, Color_foreground},
+ {"textmd", inh_family, MEDIUM_SERIES,
inh_shape, Color_foreground},
{"textnormal", inh_family, inh_series,
- Font::UP_SHAPE, Color_foreground},
- {"textrm", Font::ROMAN_FAMILY,
- inh_series, Font::UP_SHAPE,Color_foreground},
+ UP_SHAPE, Color_foreground},
+ {"textrm", ROMAN_FAMILY,
+ inh_series, UP_SHAPE,Color_foreground},
{"textsc", inh_family, inh_series,
- Font::SMALLCAPS_SHAPE, Color_foreground},
- {"textsf", Font::SANS_FAMILY, inh_series,
+ SMALLCAPS_SHAPE, Color_foreground},
+ {"textsf", SANS_FAMILY, inh_series,
inh_shape, Color_foreground},
{"textsl", inh_family, inh_series,
- Font::SLANTED_SHAPE, Color_foreground},
- {"texttt", Font::TYPEWRITER_FAMILY, inh_series,
+ SLANTED_SHAPE, Color_foreground},
+ {"texttt", TYPEWRITER_FAMILY, inh_series,
inh_shape, Color_foreground},
{"textup", inh_family, inh_series,
- Font::UP_SHAPE, Color_foreground},
+ UP_SHAPE, Color_foreground},
// TIPA support
{"textipa", inh_family, inh_series,
// LyX internal usage
{"lyxtex", inh_family, inh_series,
- Font::UP_SHAPE, Color_latex},
- {"lyxsymbol", Font::SYMBOL_FAMILY, inh_series,
+ UP_SHAPE, Color_latex},
+ {"lyxsymbol", SYMBOL_FAMILY, inh_series,
inh_shape, Color_math},
- {"lyxboldsymbol", Font::SYMBOL_FAMILY, Font::BOLD_SERIES,
+ {"lyxboldsymbol", SYMBOL_FAMILY, BOLD_SERIES,
inh_shape, Color_math},
- {"lyxblacktext", Font::ROMAN_FAMILY, Font::MEDIUM_SERIES,
- Font::UP_SHAPE, Color_foreground},
+ {"lyxblacktext", ROMAN_FAMILY, MEDIUM_SERIES,
+ UP_SHAPE, Color_foreground},
{"lyxnochange", inh_family, inh_series,
inh_shape, Color_foreground},
- {"lyxfakebb", Font::TYPEWRITER_FAMILY, Font::BOLD_SERIES,
- Font::UP_SHAPE, Color_math},
- {"lyxfakecal", Font::SANS_FAMILY, Font::MEDIUM_SERIES,
- Font::ITALIC_SHAPE, Color_math},
- {"lyxfakefrak", Font::ROMAN_FAMILY, Font::BOLD_SERIES,
- Font::ITALIC_SHAPE, Color_math}
+ {"lyxfakebb", TYPEWRITER_FAMILY, BOLD_SERIES,
+ UP_SHAPE, Color_math},
+ {"lyxfakecal", SANS_FAMILY, MEDIUM_SERIES,
+ ITALIC_SHAPE, Color_math},
+ {"lyxfakefrak", ROMAN_FAMILY, BOLD_SERIES,
+ ITALIC_SHAPE, Color_math}
};
{
//lyxerr << "searching font '" << name << "'" << endl;
int const n = sizeof(fontinfos) / sizeof(fontinfo);
- std::string name = to_utf8(name0);
+ string name = to_utf8(name0);
for (int i = 0; i < n; ++i)
if (fontinfos[i].cmd_ == name) {
//lyxerr << "found '" << i << "'" << endl;
}
-Font getFont(docstring const & name)
+FontInfo getFont(docstring const & name)
{
- Font font;
+ FontInfo font;
augmentFont(font, name);
return font;
}
}
-void augmentFont(Font & font, docstring const & name)
+void augmentFont(FontInfo & font, docstring const & name)
{
static bool initialized = false;
if (!initialized) {