]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathBig.C
fix reading UTF8 encoded symbol file
[lyx.git] / src / mathed / InsetMathBig.C
index b06654ae9e9581cf20af453c8bf8129b71da1ccd..49dbcd73c095efe8fcbf72155044a1e68ee85780 100644 (file)
 
 #include "InsetMathBig.h"
 #include "MathSupport.h"
-#include "MathMLStream.h"
 #include "MathStream.h"
+#include "MathStream.h"
+
+#include "frontends/FontMetrics.h"
 
 #include "support/lstrings.h"
 
 
-using std::string;
+namespace lyx {
+
 using std::auto_ptr;
 
 
-InsetMathBig::InsetMathBig(string const & name, string const & delim)
+InsetMathBig::InsetMathBig(docstring const & name, docstring const & delim)
        : name_(name), delim_(delim)
 {}
 
 
-string InsetMathBig::name() const
+docstring InsetMathBig::name() const
 {
        return name_;
 }
@@ -61,7 +64,7 @@ double InsetMathBig::increase() const
 
 void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       double const h = mathed_char_ascent(mi.base.font, 'I');
+       double const h = theFontMetrics(mi.base.font).ascent('I');
        double const f = increase();
        dim_.wid = 6;
        dim_.asc = int(h + f * h);
@@ -75,9 +78,8 @@ void InsetMathBig::draw(PainterInfo & pi, int x, int y) const
        // mathed_draw_deco does not use the leading backslash, so remove it.
        // Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco
        // would treat it as |.
-       string const delim = (delim_ == "\\|") ?
-               "Vert" :
-               lyx::support::ltrim(delim_, "\\");
+       docstring const delim = 
+               (delim_ == "\\|") ?  from_ascii("Vert") : support::ltrim(delim_, "\\");
        mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(),
                         delim);
        setPosCache(pi, x, y);
@@ -86,7 +88,7 @@ void InsetMathBig::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathBig::write(WriteStream & os) const
 {
-       os << '\\' << name_ << ' ' << delim_;
+       os << '\\' << name_ << delim_;
        if (delim_[0] == '\\')
                os.pendingSpace(true);
 }
@@ -94,17 +96,17 @@ void InsetMathBig::write(WriteStream & os) const
 
 void InsetMathBig::normalize(NormalStream & os) const
 {
-       os << '[' << name_ << ' ' <<  delim_ << ']';
+       os << '[' << name_ << ' ' << delim_ << ']';
 }
 
 
-void InsetMathBig::infoize2(std::ostream & os) const
+void InsetMathBig::infoize2(odocstream & os) const
 {
        os << name_;
 }
 
 
-bool InsetMathBig::isBigInsetDelim(string const & delim)
+bool InsetMathBig::isBigInsetDelim(docstring const & delim)
 {
        // mathed_draw_deco must handle these
        static char const * const delimiters[] = {
@@ -116,5 +118,8 @@ bool InsetMathBig::isBigInsetDelim(string const & delim)
                "\\uparrow", "\\Uparrow",
                "\\updownarrow", "\\Updownarrow", ""
        };
-       return (lyx::support::findToken(delimiters, delim) >= 0);
+       return support::findToken(delimiters, to_utf8(delim)) >= 0;
 }
+
+
+} // namespace lyx