From 040fb73b9ce527ea483aa081e8971fb76e8a4406 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 8 Jun 2012 12:54:57 +0200 Subject: [PATCH] Do not hardcode polyglossia-only languages --- src/BufferParams.cpp | 18 +++--------------- src/LaTeXFeatures.cpp | 19 ++++++++++++++++--- src/LaTeXFeatures.h | 4 +++- src/frontends/qt4/GuiDocument.cpp | 12 +++--------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index b1a61b9b40..818399d8d9 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1245,21 +1245,9 @@ void BufferParams::validate(LaTeXFeatures & features) const } // some languages are only available via polyglossia - if ( (features.runparams().flavor == OutputParams::XETEX - || language->lang() == "ancientgreek" - || language->lang() == "coptic" - || language->lang() == "divehi" - || language->lang() == "hindi" - || language->lang() == "kurmanji" - || language->lang() == "lao" - || language->lang() == "marathi" - || language->lang() == "occitan" - || language->lang() == "sanskrit" - || language->lang() == "syriac" - || language->lang() == "tamil" - || language->lang() == "telugu" - || language->lang() == "urdu" - ) && useNonTeXFonts) + if (features.runparams().flavor == OutputParams::XETEX + && (features.hasPolyglossiaExclusiveLanguages() + || useNonTeXFonts)) features.require("polyglossia"); if (language->lang() == "vietnamese") diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index b5fe2af404..f75fdc478b 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -313,12 +313,12 @@ bool LaTeXFeatures::usePolyglossia() const && isRequired("polyglossia") && isAvailable("polyglossia") && !params_.documentClass().provides("babel") - && this->hasPolyglossiaLanguages(); + && this->hasOnlyPolyglossiaLanguages(); return (bufferParams().lang_package == "auto") && isRequired("polyglossia") && isAvailable("polyglossia") && !params_.documentClass().provides("babel") - && this->hasPolyglossiaLanguages(); + && this->hasOnlyPolyglossiaLanguages(); } @@ -477,7 +477,7 @@ bool LaTeXFeatures::hasLanguages() const } -bool LaTeXFeatures::hasPolyglossiaLanguages() const +bool LaTeXFeatures::hasOnlyPolyglossiaLanguages() const { LanguageList::const_iterator const begin = UsedLanguages_.begin(); for (LanguageList::const_iterator cit = begin; @@ -490,6 +490,19 @@ bool LaTeXFeatures::hasPolyglossiaLanguages() const } +bool LaTeXFeatures::hasPolyglossiaExclusiveLanguages() const +{ + LanguageList::const_iterator const begin = UsedLanguages_.begin(); + for (LanguageList::const_iterator cit = begin; + cit != UsedLanguages_.end(); + ++cit) { + if ((*cit)->babel().empty() && !(*cit)->polyglossia().empty()) + return true; + } + return false; +} + + string LaTeXFeatures::getLanguages() const { ostringstream languages; diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 3b1cc89d64..7b1f51b8ec 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -106,7 +106,9 @@ public: /// bool hasLanguages() const; /// check if all used languages are supported by polyglossia - bool hasPolyglossiaLanguages() const; + bool hasOnlyPolyglossiaLanguages() const; + /// check if a language is supported only by polyglossia + bool hasPolyglossiaExclusiveLanguages() const; /// std::string getLanguages() const; /// diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 4b269ca1b5..cfe83a7a75 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1760,15 +1760,9 @@ void GuiDocument::deleteBoxBackgroundColor() void GuiDocument::languageChanged(int i) { // some languages only work with polyglossia/XeTeX - string current_language = lyx::languages.getLanguage( - fromqstr(langModule->languageCO->itemData(i).toString()))->lang(); - if (current_language == "ancientgreek" - || current_language == "coptic" || current_language == "divehi" - || current_language == "hindi" || current_language == "kurmanji" - || current_language == "lao" || current_language == "marathi" - || current_language == "occitan" || current_language == "sanskrit" - || current_language == "syriac" || current_language == "tamil" - || current_language == "telugu" || current_language == "urdu") { + Language const * lang = lyx::languages.getLanguage( + fromqstr(langModule->languageCO->itemData(i).toString())); + if (lang->babel().empty() && !lang->polyglossia().empty()) { fontModule->osFontsCB->setChecked(true); fontModule->osFontsCB->setEnabled(false); } -- 2.39.5