output babel options via \babelprovide in all cases needed

This commit is contained in:
Juergen Spitzmueller 2024-08-26 07:20:58 +02:00
parent 686b55e70d
commit b1b8ded15d
4 changed files with 34 additions and 6 deletions

View 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);
}

View 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())

View 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

View File

@ -205,6 +205,8 @@ public:
const_iterator begin() const { return languagelist_.begin(); }
///
const_iterator end() const { return languagelist_.end(); }
///
bool haveOtherForceProvide() const;
private:
///