#include "debug.h"
#include "LColor.h"
-#include "frontends/Application.h"
#include "frontends/FontLoader.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
} // namespace anon
-void mathed_char_dim(LyXFont const & font, unsigned char c, Dimension & dim)
+void mathed_char_dim(LyXFont const & font, lyx::char_type c, Dimension & dim)
{
- lyx::frontend::FontMetrics const & fm =
- theApp->fontLoader().metrics(font);
+ lyx::frontend::FontMetrics const & fm = theFontMetrics(font);
dim.des = fm.descent(c);
dim.asc = fm.ascent(c);
dim.wid = fm.width(c);
}
-int mathed_char_width(LyXFont const & font, unsigned char c)
+int mathed_char_width(LyXFont const & font, lyx::char_type c)
{
- return theApp->fontLoader().metrics(font).width(c);
+ return theFontMetrics(font).width(c);
}
-void mathed_string_dim(LyXFont const & font, string const & s, Dimension & dim)
+void mathed_string_dim(LyXFont const & font, docstring const & s, Dimension & dim)
{
- lyx::frontend::FontMetrics const & fm =
- theApp->fontLoader().metrics(font);
-#if 1
+ lyx::frontend::FontMetrics const & fm = theFontMetrics(font);
dim.asc = 0;
dim.des = 0;
- for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
+ for (docstring::const_iterator it = s.begin(); it != s.end(); ++it) {
dim.asc = max(dim.asc, fm.ascent(*it));
dim.des = max(dim.des, fm.descent(*it));
}
-#else
- dim.asc = fm.maxAscent();
- dim.des = fm.maxDescent();
-#endif
- docstring ds(s.begin(), s.end());
- dim.wid = fm.width(ds);
+ dim.wid = fm.width(s);
}
-int mathed_string_width(LyXFont const & font, string const & s)
+int mathed_string_width(LyXFont const & font, docstring const & s)
{
- docstring ds(s.begin(), s.end());
- return theApp->fontLoader().metrics(font).width(ds);
+ return theFontMetrics(font).width(s);
}
}
-void drawStrRed(PainterInfo & pi, int x, int y, string const & str)
+void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
{
LyXFont f = pi.base.font;
f.setColor(LColor::latex);
- docstring dstr(str.begin(), str.end());
- pi.pain.text(x, y, dstr, f);
+ pi.pain.text(x, y, str, f);
}
-void drawStrBlack(PainterInfo & pi, int x, int y, string const & str)
+void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & str)
{
LyXFont f = pi.base.font;
f.setColor(LColor::foreground);
- docstring dstr(str.begin(), str.end());
- pi.pain.text(x, y, dstr, f);
+ pi.pain.text(x, y, str, f);
}
void math_font_max_dim(LyXFont const & font, int & asc, int & des)
{
- lyx::frontend::FontMetrics const & fm =
- theApp->fontLoader().metrics(font);
+ lyx::frontend::FontMetrics const & fm = theFontMetrics(font);
asc = fm.maxAscent();
des = fm.maxDescent();
}
if (!initialized) {
initialized = true;
// fake fonts if necessary
- if (!theApp->fontLoader().available(getFont("mathfrak")))
+ if (!theFontLoader().available(getFont("mathfrak")))
fakeFont("mathfrak", "lyxfakefrak");
- if (!theApp->fontLoader().available(getFont("mathcal")))
+ if (!theFontLoader().available(getFont("mathcal")))
fakeFont("mathcal", "lyxfakecal");
}
fontinfo * info = searchFont(name);
string asString(MathArray const & ar)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
ws << ar;
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}
-void asArray(string const & str, MathArray & ar)
+void asArray(docstring const & str, MathArray & ar)
{
- mathed_parse_cell(ar, str);
+ mathed_parse_cell(ar, lyx::to_utf8(str));
}
string asString(InsetMath const & inset)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
inset.write(ws);
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}
string asString(MathAtom const & at)
{
- std::ostringstream os;
+ lyx::odocstringstream os;
WriteStream ws(os);
at->write(ws);
- return os.str();
+ // FIXME UNICODE
+ return lyx::to_utf8(os.str());
}