]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathSupport.C
make it compile again (hopefully)
[lyx.git] / src / mathed / MathSupport.C
index f89289b5b77d32383bbccbd5140eed6283df9c7e..23ad7351b88fa130943e922fb97ca378f2ec7029 100644 (file)
@@ -20,7 +20,6 @@
 #include "debug.h"
 #include "LColor.h"
 
-#include "frontends/Application.h"
 #include "frontends/FontLoader.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
@@ -366,46 +365,37 @@ deco_struct const * search_deco(string const & name)
 } // 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);
 }
 
 
@@ -479,28 +469,25 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 }
 
 
-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();
 }
@@ -665,9 +652,9 @@ void augmentFont(LyXFont & font, string const & name)
        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);
@@ -684,32 +671,35 @@ void augmentFont(LyXFont & font, string const & 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());
 }