diff --git a/lib/languages b/lib/languages index 4c3b49b2ac..909043d3f1 100644 --- a/lib/languages +++ b/lib/languages @@ -26,6 +26,7 @@ # # EndPostBabelPreamble # Requires +# Provides # End # # @@ -167,6 +168,7 @@ Language ancientgreek InternalEncoding true FontEncoding LGR LangCode grc_GR + Provides textgreek End # FIXME: dummy babel language for arabic_arabtex to be able @@ -618,6 +620,7 @@ Language greek InternalEncoding true FontEncoding LGR LangCode el_GR + Provides textgreek End Language polutonikogreek @@ -630,6 +633,7 @@ Language polutonikogreek InternalEncoding true FontEncoding LGR LangCode el_GR + Provides textgreek End Language hebrew diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 204c3ec4cc..3627cc660c 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -544,6 +544,12 @@ void LaTeXFeatures::require(set const & names) } +void LaTeXFeatures::provide(string const & name) +{ + provides_.insert(name); +} + + void LaTeXFeatures::useLayout(docstring const & layoutname) { useLayout(layoutname, 0); @@ -609,19 +615,11 @@ bool LaTeXFeatures::isRequired(string const & name) const bool LaTeXFeatures::isProvided(string const & name) const { - // \textgreek is provided by babel globally if a Greek language/variety - // is used in the document - if (useBabel() && name == "textgreek" - && params_.main_font_encoding() != "default") { - // get main font encodings - vector fontencs = params_.font_encodings(); - // get font encodings of secondary languages - getFontEncodings(fontencs, true); - for (auto & fe : fontencs) { - if (!Encodings::needsScriptWrapper(name, fe)) - return true; - } - } + // \textgreek is provided by babel globally if a Greek + // language/variety is used in the document + if (provides_.find(name) != provides_.end()) + return true; + // FIXME: Analoguously, babel provides a command \textcyrillic, but // for some reason, we roll our own \textcyr definition // We should use \textcyrillic instead and only define it @@ -756,6 +754,9 @@ void LaTeXFeatures::useLanguage(Language const * lang) UsedLanguages_.insert(lang); if (!lang->requires().empty()) require(lang->requires()); + // currently only supported for Babel + if (!lang->provides().empty() && useBabel()) + provide(lang->provides()); // CJK languages do not have a babel name. // They use the CJK package if (lang->encoding()->package() == Encoding::CJK) diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 29d0b369fd..32a62426c6 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -103,6 +103,8 @@ public: void require(std::string const & name); /// Add a set of feature names requirements void require(std::set const & names); + /// Add a feature name provision + void provide(std::string const & name); /// Is the (required) package available? static bool isAvailable(std::string const & name); /// Has the package been required? @@ -186,10 +188,12 @@ private: std::list usedLayouts_; /// std::list usedInsetLayouts_; - /// The features that are needed by the document - typedef std::set Features; /// + typedef std::set Features; + /// The features that are needed by the document Features features_; + /// Features that are provided + Features provides_; /// Static preamble bits, from external templates, or anywhere else typedef std::list SnippetList; /// diff --git a/src/Language.cpp b/src/Language.cpp index 31212cba28..3061df3130 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -87,9 +87,10 @@ bool Language::readLanguage(Lexer & lex) LA_POLYGLOSSIANAME, LA_POLYGLOSSIAOPTS, LA_POSTBABELPREAMBLE, - LA_QUOTESTYLE, LA_PREBABELPREAMBLE, + LA_PROVIDES, LA_REQUIRES, + LA_QUOTESTYLE, LA_RTL }; @@ -109,6 +110,7 @@ bool Language::readLanguage(Lexer & lex) { "polyglossiaopts", LA_POLYGLOSSIAOPTS }, { "postbabelpreamble", LA_POSTBABELPREAMBLE }, { "prebabelpreamble", LA_PREBABELPREAMBLE }, + { "provides", LA_PROVIDES }, { "quotestyle", LA_QUOTESTYLE }, { "requires", LA_REQUIRES }, { "rtl", LA_RTL } @@ -184,6 +186,9 @@ bool Language::readLanguage(Lexer & lex) case LA_REQUIRES: lex >> requires_; break; + case LA_PROVIDES: + lex >> provides_; + break; case LA_RTL: lex >> rightToLeft_; break; diff --git a/src/Language.h b/src/Language.h index 594a324253..ddcc32894c 100644 --- a/src/Language.h +++ b/src/Language.h @@ -50,6 +50,8 @@ public: std::string const quoteStyle() const { return quote_style_; } /// requirement (package, function) std::string const requires() const { return requires_; } + /// provides feature + std::string const provides() const { return provides_; } /// translatable GUI name std::string const display() const { return display_; } /// is this a RTL language? @@ -109,6 +111,8 @@ private: /// trivstring requires_; /// + trivstring provides_; + /// trivstring display_; /// bool rightToLeft_;