Do not hardcode polyglossia-only languages

This commit is contained in:
Juergen Spitzmueller 2012-06-08 12:54:57 +02:00
parent ceb180cebd
commit 040fb73b9c
4 changed files with 25 additions and 28 deletions

View File

@ -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")

View File

@ -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;

View File

@ -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;
///

View File

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