]> git.lyx.org Git - lyx.git/blobdiff - src/bufferparams.C
The bug-fix in revision 16531 introduced another bug. This is the right fix. I did...
[lyx.git] / src / bufferparams.C
index 856fa185eee872db815f24d2f5adcaa5021c188b..959d087b79e8184aa0e00207a26f790a3f47b985 100644 (file)
@@ -261,7 +261,8 @@ BufferParams::Impl::Impl()
        : defskip(VSpace::MEDSKIP)
 {
        // set initial author
-       authorlist.record(Author(lyxrc.user_name, lyxrc.user_email));
+       // FIXME UNICODE
+       authorlist.record(Author(from_utf8(lyxrc.user_name), from_utf8(lyxrc.user_email)));
 }
 
 
@@ -850,14 +851,28 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                std::set<string> encodings =
                        features.getEncodingSet(doc_encoding);
 
-               os << "\\usepackage[";
-               std::set<string>::const_iterator it = encodings.begin();
-               std::set<string>::const_iterator const end = encodings.end();
-               for (; it != end; ++it)
-                       os << from_ascii(*it) << ',';
-               os << from_ascii(doc_encoding) << "]{inputenc}\n";
-               texrow.newline();
-       } else if (inputenc != "default") {
+               // thailatex does not use the inputenc package, but sets up
+               // babel directly for tis620-0 encoding, therefore we must
+               // not request inputenc for tis620-0 encoding
+               if (!encodings.empty() || doc_encoding != "tis620-0") {
+                       os << "\\usepackage[";
+                       std::set<string>::const_iterator it = encodings.begin();
+                       std::set<string>::const_iterator const end = encodings.end();
+                       if (it != end) {
+                               os << from_ascii(*it);
+                               ++it;
+                       }
+                       for (; it != end; ++it)
+                               os << ',' << from_ascii(*it);
+                       if (doc_encoding != "tis620-0") {
+                               if (!encodings.empty())
+                                       os << ',';
+                               os << from_ascii(doc_encoding);
+                       }
+                       os << "]{inputenc}\n";
+                       texrow.newline();
+               }
+       } else if (inputenc != "default" && inputenc != "tis620-0") {
                os << "\\usepackage[" << from_ascii(inputenc)
                   << "]{inputenc}\n";
                texrow.newline();
@@ -983,26 +998,26 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        if (paragraph_separation) {
                switch (getDefSkip().kind()) {
                case VSpace::SMALLSKIP:
-                       os << "\\setlength\\parskip{\\smallskipamount}\n";
+                       os << "\\setlength{\\parskip}{\\smallskipamount}\n";
                        break;
                case VSpace::MEDSKIP:
-                       os << "\\setlength\\parskip{\\medskipamount}\n";
+                       os << "\\setlength{\\parskip}{\\medskipamount}\n";
                        break;
                case VSpace::BIGSKIP:
-                       os << "\\setlength\\parskip{\\bigskipamount}\n";
+                       os << "\\setlength{\\parskip}{\\bigskipamount}\n";
                        break;
                case VSpace::LENGTH:
-                       os << "\\setlength\\parskip{"
+                       os << "\\setlength{\\parskip}{"
                           << from_utf8(getDefSkip().length().asLatexString())
                           << "}\n";
                        break;
                default: // should never happen // Then delete it.
-                       os << "\\setlength\\parskip{\\medskipamount}\n";
+                       os << "\\setlength{\\parskip}{\\medskipamount}\n";
                        break;
                }
                texrow.newline();
 
-               os << "\\setlength\\parindent{0pt}\n";
+               os << "\\setlength{\\parindent}{0pt}\n";
                texrow.newline();
        }
 
@@ -1453,11 +1468,18 @@ Encoding const & BufferParams::encoding() const
 {
        if (inputenc == "auto")
                return *(language->encoding());
-       Encoding const * const enc = encodings.getFromLaTeXName(inputenc);
+       Encoding const * const enc = (inputenc == "default") ?
+               encodings.getFromLyXName("iso8859-1") :
+               encodings.getFromLaTeXName(inputenc);
        if (enc)
                return *enc;
-       lyxerr << "Unknown inputenc value `" << inputenc
-              << "'. Using `auto' instead." << endl;
+       if (inputenc == "default")
+               lyxerr << "Could not find iso8859-1 encoding for inputenc "
+                         "value `default'. Using inputenc `auto' instead."
+                      << endl;
+       else
+               lyxerr << "Unknown inputenc value `" << inputenc
+                      << "'. Using `auto' instead." << endl;
        return *(language->encoding());
 }