]> git.lyx.org Git - lyx.git/commitdiff
output babel options via \babelprovide in all cases needed
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 26 Aug 2024 05:20:58 +0000 (07:20 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 26 Aug 2024 05:20:58 +0000 (07:20 +0200)
src/BufferParams.cpp
src/LaTeXFeatures.cpp
src/Language.cpp
src/Language.h

index 8f5dbfdcac531f4ec0204c5094c05705c9f18834..944d0714e9849d21fb2d3c6c7fee2aba9bbc2fac 100644 (file)
@@ -3503,12 +3503,17 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
        ostringstream os;
        string force_provide;
        bool have_main_forceprovide = false;
+       bool have_other_forceprovide = useNonTeXFonts
+                       ? languages.haveOtherForceProvide()
+                       : false;
        for (auto const & l : langs) {
                string blang = l->babel();
                bool use_opt = langoptions;
                if (blang.empty())
                        continue;
-               if (l->babelOptFormat() == "modifier") {
+               int const bp = l->useBabelProvide();
+               // pass option as modifier if apt
+               if (bp != 2 && !have_other_forceprovide && l->babelOptFormat() == "modifier") {
                        vector<string> opts = getVectorFromString(babelLangOptions(l->lang()));
                        bool have_one = false;
                        for (string const & s : opts) {
@@ -3522,8 +3527,8 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
                                use_opt = true;
                        }
                }
-               int const bp = l->useBabelProvide();
-               if (bp == 1) {
+               // language that always requires \babelprovide
+               if (bp == 1 && !have_other_forceprovide) {
                        os << "\n\\babelprovide[import";
                        if (l == language)
                                os << ", main";
@@ -3532,9 +3537,11 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
                        os << "]{" << blang << "}";
                        have_mods = true;
                }
+               // language that only requires \babelprovide with nonTeXFonts
                if (bp == 2 && useNonTeXFonts) {
-                       // here we need to tell babel to use the ini
-                       // even though an *.ldf exists
+                       // here we need to tell babel to use the *.ini
+                       // even though an *.ldf exists.
+                       // This imports the *ini, so no "import" needed.
                        if (l == language) {
                                force_provide = force_provide.empty()
                                                ? "provide=*"
@@ -3546,6 +3553,13 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
                                                : "provide+=*";
                        have_mods = true;
                }
+               if ((bp == 2 && useNonTeXFonts) || have_other_forceprovide) {
+                       // Options need to go to \babeprovide
+                       if (!babelLangOptions(l->lang()).empty())
+                               os << "\n\\babelprovide["
+                                  << babelLangOptions(l->lang())
+                                  << "]{" << blang << "}";
+               }
                if (bp != 1 && use_opt)
                        blangs.push_back(blang);
        }
index f1319facb52507b7b07b2407bb7e59fb37939951..7ce7966bba235cea23ad232c1a2eb0dbf9b51fbe 100644 (file)
@@ -1822,7 +1822,8 @@ docstring const LaTeXFeatures::getBabelPostsettings() const
        for (auto const & lang : langs) {
                if (!lang->babel_postsettings().empty())
                        tmp << lang->babel_postsettings() << '\n';
-               if (lang->babelOptFormat() != "modifier" && lang->useBabelProvide() == 0) {
+               if (lang->babelOptFormat() != "modifier" && lang->useBabelProvide() == 0
+                   && (!params_.useNonTeXFonts || !languages.haveOtherForceProvide())) {
                        // user-set options
                        string const opts = bufferParams().babelLangOptions(lang->lang());
                        if (!opts.empty())
index f178f9abd94cc7f31af9d43b5b56f93c8e0a7709..60428179b47ccea04142a1c11af6d244e43cfa9f 100644 (file)
@@ -535,4 +535,15 @@ Language const * Languages::getLanguage(string const & language) const
 }
 
 
+bool Languages::haveOtherForceProvide() const
+{
+       for (auto const & l : languagelist_) {
+               if (l.second.useBabelProvide())
+                       return true;
+       }
+       return false;
+}
+
+
+
 } // namespace lyx
index 44658098051f11abd42a88511bf8936576b96e91..ddd6edf7c287f843958f7b19637f8c4a106e2b65 100644 (file)
@@ -205,6 +205,8 @@ public:
        const_iterator begin() const { return languagelist_.begin(); }
        ///
        const_iterator end() const { return languagelist_.end(); }
+       ///
+       bool haveOtherForceProvide() const;
 
 private:
        ///