]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Remove accidentally committed debug statement
[lyx.git] / src / BufferParams.cpp
index 8de7bc5a7522cab889252b5d298ee71ff28f8b26..862c3ede40cbe739d54ebdef7a36fcbf3662786e 100644 (file)
@@ -308,7 +308,7 @@ bool inSystemDir(FileName const & document_dir, string & system_dir)
 
        string dir = document_dir.absFileName();
 
-       for (int i = 0; i < 2; ++i) {
+       for (int i = 0; i < 3; ++i) {
                dir = addPath(dir, "..");
                if (!fileSearch(dir, "configure.py").empty() &&
                    !fileSearch(dir, "chkconfig.ltx").empty()) {
@@ -754,6 +754,15 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                origin.replace(0, sysdirprefix.length() - 1,
                                        package().system_support().absFileName());
                }
+               string const builddirprefix = "/buildlyxdir/";
+               if (prefixIs(origin, builddirprefix)) {
+                       string docsys;
+                       if (inSystemDir(filepath, docsys))
+                               origin.replace(0, builddirprefix.length() - 1, docsys);
+                       else
+                               origin.replace(0, builddirprefix.length() - 1,
+                                       package().system_support().absFileName());
+               }
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
        } else if (token == "\\begin_local_layout") {
@@ -1142,7 +1151,10 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        string const relpath =
                to_utf8(makeRelPath(from_utf8(filepath), from_utf8(sysdir)));
        if (!prefixIs(relpath, "../") && !FileName::isAbsolute(relpath))
-               filepath = addPath("/systemlyxdir", relpath);
+               filepath = (prefixIs(docsys, package().build_support().realPath())) ?
+                                       addPath("/buildlyxdir", relpath)
+                                     : addPath("/systemlyxdir", relpath);
+
        else if (!save_transient_properties || !lyxrc.save_origin)
                filepath = "unavailable";
        os << "\\origin " << quoteIfNeeded(filepath) << '\n';
@@ -1745,6 +1757,16 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                        os << "\\usepackage{unicode-math}\n";
        }
 
+       // load CJK support package before font selection
+       // (see autotests/export/latex/CJK/micro-sign_utf8-cjk-libertine.lyx)
+       if (!useNonTeXFonts && encoding().package() != Encoding::none && inputenc != "utf8x"
+               && (encoding().package() == Encoding::CJK || features.mustProvide("CJK"))) {
+               if (inputenc == "utf8-cjk" || inputenc == "utf8")
+                       os << "\\usepackage{CJKutf8}\n";
+               else
+                       os << "\\usepackage[encapsulated]{CJK}\n";
+       }
+
        // font selection must be done before loading fontenc.sty
        string const fonts = loadFonts(features);
        if (!fonts.empty())
@@ -1769,6 +1791,12 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                }
        }
 
+       // Load textcomp and pmboxdraw before (lua)inputenc (#11454)
+       if (features.mustProvide("textcomp"))
+               os << "\\usepackage{textcomp}\n";
+       if (features.mustProvide("pmboxdraw"))
+               os << "\\usepackage{pmboxdraw}\n";
+
        // handle inputenc etc.
        writeEncodingPreamble(os, features);
 
@@ -2332,19 +2360,25 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        // ... but before biblatex (see #7065)
-       if (features.mustProvide("biblatex")
+       if ((features.mustProvide("biblatex")
+            || features.isRequired("biblatex-chicago"))
+           && !features.isProvided("biblatex-chicago")
            && !features.isProvided("biblatex-natbib")
            && !features.isProvided("natbib-internal")
            && !features.isProvided("natbib")
            && !features.isProvided("jurabib")) {
+               // The biblatex-chicago package has a differing interface
+               // it uses a wrapper package and loads styles via fixed options
+               bool const chicago = features.isRequired("biblatex-chicago");
                string delim = "";
                string opts;
                os << "\\usepackage";
                if (!biblatex_bibstyle.empty()
-                   && (biblatex_bibstyle == biblatex_citestyle)) {
+                   && (biblatex_bibstyle == biblatex_citestyle)
+                   && !chicago) {
                        opts = "style=" + biblatex_bibstyle;
                        delim = ",";
-               } else {
+               } else if (!chicago) {
                        if (!biblatex_bibstyle.empty()) {
                                opts = "bibstyle=" + biblatex_bibstyle;
                                delim = ",";
@@ -2376,7 +2410,10 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                        opts += delim + biblio_opts;
                if (!opts.empty())
                        os << "[" << opts << "]";
-               os << "{biblatex}\n";
+               if (chicago)
+                       os << "{biblatex-chicago}\n";
+               else
+                       os << "{biblatex}\n";
        }
 
 
@@ -3240,17 +3277,15 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                        else
                                os << "]{inputenc}\n";
                }
-               if (package == Encoding::CJK || features.mustProvide("CJK")) {
-                       if (language->encoding()->name() == "utf8-cjk"
-                           && LaTeXFeatures::isAvailable("CJKutf8"))
-                               os << "\\usepackage{CJKutf8}\n";
-                       else
-                               os << "\\usepackage{CJK}\n";
-               }
        } else if (inputenc != "default") {
                switch (encoding().package()) {
                case Encoding::none:
+               case Encoding::CJK:
                case Encoding::japanese:
+                       if (encoding().iconvName() != "UTF-8")
+                         // don't default to [utf8]{inputenc} with TeXLive >= 18
+                         os << "\\ifdefined\\UseRawInputEncoding\n"
+                                << "  \\UseRawInputEncoding\\fi\n";
                        break;
                case Encoding::inputenc:
                        // do not load inputenc if japanese is used
@@ -3265,24 +3300,13 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                        else
                                os << "]{inputenc}\n";
                        break;
-               case Encoding::CJK:
-                       if (encoding().name() == "utf8-cjk"
-                           && LaTeXFeatures::isAvailable("CJKutf8"))
-                               os << "\\usepackage{CJKutf8}\n";
-                       else
-                               os << "\\usepackage{CJK}\n";
-                       break;
-               }
-               // Load the CJK package if needed by a secondary language.
-               // If the main encoding is some variant of UTF8, use CJKutf8.
-               if (encoding().package() != Encoding::CJK && features.mustProvide("CJK")) {
-                       if (encoding().iconvName() == "UTF-8"
-                           && LaTeXFeatures::isAvailable("CJKutf8"))
-                               os << "\\usepackage{CJKutf8}\n";
-                       else
-                               os << "\\usepackage{CJK}\n";
                }
        }
+       if (inputenc == "default" || features.isRequired("japanese")) {
+               // don't default to [utf8]{inputenc} with TeXLive >= 18
+               os << "\\ifdefined\\UseRawInputEncoding\n";
+               os << "  \\UseRawInputEncoding\\fi\n";
+       }
 }