]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathChar.C
fix reading UTF8 encoded symbol file
[lyx.git] / src / mathed / InsetMathChar.C
index edec8c43d08d829828d9cefd450c221e37d63fd9..18437ff6cff0b9f7044258df31e6728aeda4522a 100644 (file)
 
 #include "InsetMathChar.h"
 #include "MathSupport.h"
-#include "MathMLStream.h"
+#include "MathStream.h"
 
 #include "debug.h"
 #include "dimension.h"
 #include "support/lstrings.h"
 #include "TextPainter.h"
 
+#include "frontends/FontMetrics.h"
+
+
+namespace lyx {
+
 using std::auto_ptr;
 
 extern bool has_math_fonts;
 
 namespace {
 
-       bool isBinaryOp(char c)
+       bool isBinaryOp(char_type c)
        {
-               return lyx::support::contains("+-<>=/*", c);
+               return support::contains("+-<>=/*", static_cast<char>(c));
        }
 
 
-       bool slanted(char c)
+       bool slanted(char_type c)
        {
                return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
        }
@@ -40,7 +45,7 @@ namespace {
 }
 
 
-InsetMathChar::InsetMathChar(char c)
+InsetMathChar::InsetMathChar(char_type c)
        : char_(c)
 {}
 
@@ -76,7 +81,7 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
        whichFont(font_, code_, mi);
        mathed_char_dim(font_, char_, dim_);
        if (isBinaryOp(char_, code_))
-               width_ += 2 * font_metrics::width(' ', font_);
+               width_ += 2 * theFontMetrics(font_).width(' ');
        lyxerr << "InsetMathChar::metrics: " << dim << endl;
 #endif
        width_ = dim.wid;
@@ -127,29 +132,31 @@ void InsetMathChar::drawT(TextPainter & pain, int x, int y) const
 
 void InsetMathChar::write(WriteStream & os) const
 {
-       os << char_;
+       os.os().put(char_);
 }
 
 
 void InsetMathChar::normalize(NormalStream & os) const
 {
-       os << "[char " << char_ << " mathalpha]";
+       os << "[char ";
+       os.os().put(char_);
+       os << " mathalpha]";
 }
 
 
 void InsetMathChar::octave(OctaveStream & os) const
 {
-       os << char_;
+       os.os().put(char_);
 }
 
 
-void InsetMathChar::mathmlize(MathMLStream & ms) const
+void InsetMathChar::mathmlize(MathStream & ms) const
 {
        switch (char_) {
                case '<': ms << "&lt;"; break;
                case '>': ms << "&gt;"; break;
                case '&': ms << "&amp;"; break;
-               default: ms << char_; break;
+               default: ms.os().put(char_); break;
        }
 }
 
@@ -158,3 +165,6 @@ bool InsetMathChar::isRelOp() const
 {
        return char_ == '=' || char_ == '<' || char_ == '>';
 }
+
+
+} // namespace lyx