]> git.lyx.org Git - features.git/commitdiff
Fix some unicode conversion problems, more work needed.
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 21 Oct 2006 11:15:37 +0000 (11:15 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 21 Oct 2006 11:15:37 +0000 (11:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15442 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathExFunc.C
src/mathed/InsetMathMacro.C
src/mathed/InsetMathNumber.C
src/mathed/InsetMathString.C
src/mathed/InsetMathSymbol.C
src/mathed/InsetMathUnknown.C
src/mathed/MathFactory.C
src/mathed/MathMacroArgument.C
src/mathed/MathParser.h
src/mathed/MathSupport.C
src/mathed/MathSupport.h

index 49647c26c0cd43384f911209373465423d4f7af9..5f6fcca6412a021f4b7eac1f9f040b53e23a5598 100644 (file)
@@ -22,6 +22,7 @@ namespace lyx {
 
 using std::string;
 using std::auto_ptr;
+using std::vector;
 
 
 InsetMathExFunc::InsetMathExFunc(string const & name)
@@ -45,7 +46,8 @@ auto_ptr<InsetBase> InsetMathExFunc::doClone() const
 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
 {
        // FIXME UNICODE
-       mathed_string_dim(mi.base.font, from_utf8(name_), dim_);
+       vector<char_type> n(name_.begin(), name_.end());
+       mathed_string_dim(mi.base.font, n, dim_);
 }
 
 
index af07e5d4ab52042da816400cf451a08886e8d4f3..17e61fb41462573b93cabda4f4c5f51d349014a5 100644 (file)
@@ -30,6 +30,7 @@ using std::string;
 using std::max;
 using std::auto_ptr;
 using std::endl;
+using std::vector;
 
 
 MathMacro::MathMacro(string const & name, int numargs)
@@ -61,7 +62,9 @@ void MathMacro::cursorPos(BufferView const & bv,
 void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (!MacroTable::globalMacros().has(name())) {
-               mathed_string_dim(mi.base.font, from_utf8("Unknown: " + name()), dim);
+               string t = "Unknown: " + name();
+               vector<char_type> n(t.begin(), t.end());
+               mathed_string_dim(mi.base.font, n, dim);
        } else if (editing(mi.base.bv)) {
                // FIXME UNICODE
                asArray(from_utf8(MacroTable::globalMacros().get(name()).def()), tmpl_);
@@ -103,7 +106,9 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                tmpl_.draw(pi, x + w + 12, h);
                h += tmpl_.descent();
                Dimension ldim;
-               mathed_string_dim(font, from_ascii("#1: "), ldim);
+               string t = "#1: ";
+               vector<char_type> n(t.begin(), t.end());
+               mathed_string_dim(font, n, ldim);
                for (idx_type i = 0; i < nargs(); ++i) {
                        MathArray const & c = cell(i);
                        h += max(c.ascent(), ldim.asc) + 5;
index 4b78e521ad7877d9de3ea57aa39aa3c66d34679c..d619ebca91c40481bc4bcee3890ae8ec5a63d11c 100644 (file)
@@ -20,7 +20,7 @@ namespace lyx {
 
 using std::string;
 using std::auto_ptr;
-
+using std::vector;
 
 InsetMathNumber::InsetMathNumber(string const & s)
        : str_(s)
@@ -36,7 +36,8 @@ auto_ptr<InsetBase> InsetMathNumber::doClone() const
 void InsetMathNumber::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        // FIXME UNICODE
-       mathed_string_dim(mi.base.font, from_utf8(str_), dim);
+       vector<char_type> n(str_.begin(), str_.end());
+       mathed_string_dim(mi.base.font, n, dim);
 }
 
 
index c072889b24dc4de8f21a66ee568722a8fc48fcd3..17df1a8200b133b3142eba75d982f995da40e45f 100644 (file)
@@ -20,6 +20,7 @@ namespace lyx {
 
 using std::string;
 using std::auto_ptr;
+using std::vector;
 
 
 InsetMathString::InsetMathString(string const & s)
@@ -36,7 +37,8 @@ auto_ptr<InsetBase> InsetMathString::doClone() const
 void InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        // FIXME UNICODE
-       mathed_string_dim(mi.base.font, from_utf8(str_), dim);
+       vector<char_type> n(str_.begin(), str_.end());
+       mathed_string_dim(mi.base.font, n, dim);
 }
 
 
index 726732beefb3568db6e42a770cd9c27198fbdbb8..7cd0e222b172d501eb334e4a0543b35f9201f680 100644 (file)
@@ -64,7 +64,7 @@ void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
        int const em = mathed_char_width(mi.base.font, 'M');
        FontSetChanger dummy(mi.base, sym_->inset.c_str());
        // FIXME UNICODE
-       mathed_string_dim(mi.base.font, from_utf8(sym_->draw), dim);
+       mathed_string_dim(mi.base.font, sym_->draw, dim);
        // correct height for broken cmex and wasy font
 #if defined(__APPLE__) && defined(__GNUC__)
        if (sym_->inset == "cmex") {
@@ -113,7 +113,8 @@ void InsetMathSymbol::draw(PainterInfo & pi, int x, int y) const
 
        FontSetChanger dummy(pi.base, sym_->inset.c_str());
        // FIXME UNICODE
-       pi.draw(x, y - h_, from_utf8(sym_->draw));
+       docstring n(sym_->draw.begin(), sym_->draw.end());
+       pi.draw(x, y - h_, n);
 }
 
 
index 869a5b6b588d2afca739f06577ee9b3f67b9d276..55ed11ae277824ae2ac8bd22c95d63984a4b6ba1 100644 (file)
@@ -21,6 +21,7 @@ namespace lyx {
 
 using std::string;
 using std::auto_ptr;
+using std::vector;
 
 
 InsetMathUnknown::InsetMathUnknown(string const & nm, bool final, bool black)
@@ -55,7 +56,8 @@ void InsetMathUnknown::normalize(NormalStream & os) const
 void InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        // FIXME UNICODE
-       mathed_string_dim(mi.base.font, from_utf8(name_), dim);
+       vector<char_type> n(name_.begin(), name_.end());
+       mathed_string_dim(mi.base.font, n, dim);
        dim_ = dim;
 }
 
index 3c1de31fdc20db99447504ecc0ff9c9315d2b9f4..c411b84cc2ce003d9f5b8d36bf82c289060343cd 100644 (file)
@@ -74,6 +74,7 @@ using support::split;
 using std::string;
 using std::endl;
 using std::istringstream;
+using std::vector;
 
 bool has_math_fonts;
 
@@ -179,20 +180,25 @@ void initSymbols()
 
                        if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra == "special") {
                                lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << endl;
-                               tmp.draw = tmp.name;
+                               // FIXME UNICODE
+                               vector<char_type> n(tmp.name.begin(), tmp.name.end());
+                               tmp.draw = n;
                        } else if (math_font_available(tmp.inset)) {
                                lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << endl;
-                               tmp.draw += char(charid);
+                               tmp.draw.push_back(char_type(charid));
                        } else if (fallbackid && math_font_available(symbol_font)) {
                                if (tmp.inset == "cmex")
                                        tmp.inset  = "lyxsymbol";
                                else
                                        tmp.inset  = "lyxboldsymbol";
                                lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << endl;
-                               tmp.draw += char(fallbackid);
+                               tmp.draw.push_back(char_type(fallbackid));
                        } else {
                                lyxerr[Debug::MATHED] << "faking " << tmp.name << endl;
-                               tmp.draw = tmp.name;
+                               vector<char_type> n(tmp.name.begin(),
+                                                   tmp.name.end());
+                               
+                               tmp.draw = n;
                                tmp.inset = "lyxtex";
                        }
                } else {
index 806a62ed881e956e7ffd191a12c462083532a8c6..e48defe98e9640f01d6581fa45a02b8bc55255e2 100644 (file)
@@ -23,6 +23,7 @@ namespace lyx {
 using std::endl;
 using std::auto_ptr;
 using std::size_t;
+using std::vector;
 
 
 MathMacroArgument::MathMacroArgument(size_t n)
@@ -52,7 +53,8 @@ void MathMacroArgument::write(WriteStream & os) const
 
 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       mathed_string_dim(mi.base.font, from_utf8(str_), dim_);
+       vector<char_type> n(str_, str_ + 3);
+       mathed_string_dim(mi.base.font, n, dim_);
        dim = dim_;
 }
 
index d23e9978d2abeeea6da3ab2175f4453b52e23ee8..30b274133eca89bec0e7a802384c26719edf514a 100644 (file)
 #ifndef MATH_PARSER_H
 #define MATH_PARSER_H
 
-#include <string>
+#include "support/types.h"
 
+#include <string>
+#include <vector>
 
 namespace lyx {
 
@@ -33,7 +35,7 @@ public:
        /// name of a inset that handles that macro
        std::string inset;
        /// position of the ting in a font
-       std::string draw;
+        std::vector<char_type> draw;
        /// operator/..., fontname e
        std::string extra;
        /// how is this called as XML entity?
index 3f77d28912f576f514cddf2e6366c17dbc743bb1..f03d4597eb5b1f0ce1a534d88de4fd0cb673b8bd 100644 (file)
@@ -35,6 +35,7 @@ using frontend::Painter;
 using std::string;
 using std::max;
 using std::endl;
+using std::vector;
 
 
 ///
@@ -382,16 +383,20 @@ int mathed_char_width(LyXFont const & font, char_type c)
 }
 
 
-void mathed_string_dim(LyXFont const & font, docstring const & s, Dimension & dim)
+void mathed_string_dim(LyXFont const & font,
+                      vector<char_type> const & s,
+                      Dimension & dim)
 {
        frontend::FontMetrics const & fm = theFontMetrics(font);
        dim.asc = 0;
        dim.des = 0;
-       for (docstring::const_iterator it = s.begin(); it != s.end(); ++it) {
+       for (vector<char_type>::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));
        }
-       dim.wid = fm.width(s);
+       dim.wid = fm.width(&s[0], s.size());
 }
 
 
index 626181aeeca961083b3731ab21a860ffa29dd824..ad2d1fe1174934f426fb788d8dfcb74ab82e2546 100644 (file)
@@ -16,7 +16,7 @@
 #include "support/docstring.h"
 
 #include <string>
-
+#include <vector>
 
 namespace lyx {
 
@@ -34,7 +34,10 @@ int mathed_char_width(LyXFont const &, char_type c);
 void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
        std::string const & name);
 
-void mathed_string_dim(LyXFont const & font, docstring const & s, Dimension & dim);
+void mathed_string_dim(LyXFont const & font,
+                      std::vector<char_type> const & s,
+                      Dimension & dim);
+
 int mathed_string_width(LyXFont const &, docstring const & s);
 
 void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s);