[LyX/master] output babel options via \babelprovide in all cases needed
Juergen Spitzmueller
spitz at lyx.org
Mon Aug 26 05:36:15 UTC 2024
commit b1b8ded15d72a6d098acc5c76679d78edb17419d
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Mon Aug 26 07:20:58 2024 +0200
output babel options via \babelprovide in all cases needed
---
src/BufferParams.cpp | 24 +++++++++++++++++++-----
src/LaTeXFeatures.cpp | 3 ++-
src/Language.cpp | 11 +++++++++++
src/Language.h | 2 ++
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 8f5dbfdcac..944d0714e9 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -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);
}
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index f1319facb5..7ce7966bba 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -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())
diff --git a/src/Language.cpp b/src/Language.cpp
index f178f9abd9..60428179b4 100644
--- a/src/Language.cpp
+++ b/src/Language.cpp
@@ -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
diff --git a/src/Language.h b/src/Language.h
index 4465809805..ddd6edf7c2 100644
--- a/src/Language.h
+++ b/src/Language.h
@@ -205,6 +205,8 @@ public:
const_iterator begin() const { return languagelist_.begin(); }
///
const_iterator end() const { return languagelist_.end(); }
+ ///
+ bool haveOtherForceProvide() const;
private:
///
More information about the lyx-cvs
mailing list