]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Remove special code for CJK that is no longer required (amends e665715fc4).
[lyx.git] / src / BufferParams.cpp
index 8245f73cacc55b7472ca0c53d49450e041f901bf..fc4ac4a2c8d8a46b1de66773f2581ae5123b9d90 100644 (file)
@@ -1745,6 +1745,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 +1779,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);
 
@@ -2303,6 +2319,10 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                os << "\\usepackage{xunicode}\n";
        }
 
+       // covington must be loaded after beamerarticle
+       if (features.isRequired("covington"))
+           os << "\\usepackage{covington}\n";
+
        // Polyglossia must be loaded last ...
        if (use_polyglossia) {
                // call the package
@@ -2328,19 +2348,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 = ",";
@@ -2372,7 +2398,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";
        }
 
 
@@ -2449,7 +2478,7 @@ void BufferParams::setDocumentClass(DocumentClassConstPtr tc)
 }
 
 
-bool BufferParams::setBaseClass(string const & classname)
+bool BufferParams::setBaseClass(string const & classname, string const & path)
 {
        LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
        LayoutFileList & bcl = LayoutFileList::get();
@@ -2465,7 +2494,7 @@ bool BufferParams::setBaseClass(string const & classname)
                bcl.addEmptyClass(classname);
        }
 
-       bool const success = bcl[classname].load();
+       bool const success = bcl[classname].load(path);
        if (!success) {
                docstring s =
                        bformat(_("Due to some error in it, the layout file:\n"
@@ -3236,17 +3265,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
@@ -3261,24 +3288,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";
+       }
 }
 
 
@@ -3516,4 +3532,16 @@ void BufferParams::invalidateConverterCache() const
        pimpl_->isViewCacheValid = false;
 }
 
+
+// We shouldn't need to reset the params here, since anything
+// we need will be recopied.
+void BufferParams::copyForAdvFR(const BufferParams & bp)
+{
+       string const & lang = bp.language->lang();
+       setLanguage(lang);
+       layout_modules_ = bp.layout_modules_;
+       string const & doc_class = bp.documentClass().name();
+       setBaseClass(doc_class);
+}
+
 } // namespace lyx