]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Remove hardcoded values
[lyx.git] / src / LaTeXFeatures.cpp
index 0650da1b8e3c96b1a1003159dd7583b31829b25e..4c993b6f7b9c55041a4a08e1e9b2f0490b5725d2 100644 (file)
@@ -118,6 +118,25 @@ static docstring const guilsinglright_def = from_ascii(
        "  {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
        "}");
 
+static docstring const textquotedbl_def = from_ascii(
+       "\\DeclareTextSymbolDefault{\\textquotedbl}{T1}");
+
+static docstring const textquotedblp_xetex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotedbl\\egroup}");
+
+static docstring const textquotedblp_luatex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotedbl\\egroup}");
+
+static docstring const textquotesinglep_xetex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotesingle\\egroup}");
+
+static docstring const textquotesinglep_luatex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotesingle\\egroup}");
+
 static docstring const paragraphleftindent_def = from_ascii(
        "\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
        "{\n"
@@ -327,6 +346,23 @@ static docstring const textbaltic_def = from_ascii(
         "\\DeclareTextCompositeCommand{\\c}{T1}{r}{\\textcommabelow{r}}\n"
         "\\DeclareTextCompositeCommand{\\c}{T1}{R}{\\textcommabelow{R}}\n");
 
+// split-level fractions
+static docstring const xfrac_def = from_ascii(
+          "\\usepackage{xfrac}\n");
+static docstring const smallLetterFrac_def = from_ascii(
+        "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{default}{text}\n"
+               "  {phantom=c, scale-factor=1.0, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmr}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmss}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmr}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmss}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\newcommand{\\smallLetterFrac}[2]{%\n"
+               "  {\\UseCollection{xfrac}{smallLetterFrac}\\sfrac{#1}{#2}}}\n");
+
 static docstring const lyxref_def = from_ascii(
                "\\RS@ifundefined{subsecref}\n"
                "  {\\newref{subsec}{name = \\RSsectxt}}\n"
@@ -736,6 +772,42 @@ bool LaTeXFeatures::hasPolyglossiaExclusiveLanguages() const
 }
 
 
+vector<string> LaTeXFeatures::getPolyglossiaExclusiveLanguages() const
+{
+       vector<string> result;
+       // first the main language
+       if (params_.language->isPolyglossiaExclusive())
+               result.push_back(params_.language->display());
+       // now the secondary languages
+       LanguageList::const_iterator const begin = UsedLanguages_.begin();
+       for (LanguageList::const_iterator cit = begin;
+            cit != UsedLanguages_.end();
+            ++cit) {
+               if ((*cit)->isPolyglossiaExclusive())
+                       result.push_back((*cit)->display());
+       }
+       return result;
+}
+
+
+vector<string> LaTeXFeatures::getBabelExclusiveLanguages() const
+{
+       vector<string> result;
+       // first the main language
+       if (params_.language->isBabelExclusive())
+               result.push_back(params_.language->display());
+       // now the secondary languages
+       LanguageList::const_iterator const begin = UsedLanguages_.begin();
+       for (LanguageList::const_iterator cit = begin;
+            cit != UsedLanguages_.end();
+            ++cit) {
+               if ((*cit)->isBabelExclusive())
+                       result.push_back((*cit)->display());
+       }
+       return result;
+}
+
+
 string LaTeXFeatures::getBabelLanguages() const
 {
        ostringstream languages;
@@ -757,15 +829,16 @@ string LaTeXFeatures::getBabelLanguages() const
 }
 
 
-std::map<std::string, std::string> LaTeXFeatures::getPolyglossiaLanguages() const
+set<string> LaTeXFeatures::getPolyglossiaLanguages() const
 {
-       std::map<std::string, std::string> languages;
+       set<string> languages;
 
        LanguageList::const_iterator const begin = UsedLanguages_.begin();
        for (LanguageList::const_iterator cit = begin;
             cit != UsedLanguages_.end();
             ++cit) {
-               languages[(*cit)->polyglossia()] = (*cit)->polyglossiaOpts();
+               // We do not need the variants here
+               languages.insert((*cit)->polyglossia());
        }
        return languages;
 }
@@ -877,7 +950,7 @@ char const * simplefeatures[] = {
        "fixme",
        "todonotes",
        "forest",
-       "varwidth"
+       "varwidth",
 };
 
 char const * bibliofeatures[] = {
@@ -1236,7 +1309,7 @@ TexString LaTeXFeatures::getMacros() const
                macros << lyxarrow_def << '\n';
 
        if (!usePolyglossia() && mustProvide("textgreek")) {
-               // ensure LGR font encoding is defined also if fontenc is not loaded by LyX
+           // ensure LGR font encoding is defined also if fontenc is not loaded by LyX
                if (params_.font_encoding() == "default")
                        macros << textgreek_LGR_def;
                macros << textgreek_def << '\n';
@@ -1249,7 +1322,7 @@ TexString LaTeXFeatures::getMacros() const
                macros << textcyr_def << '\n';
        }
 
-        // non-standard text accents:
+       // non-standard text accents:
        if (mustProvide("textcommaabove") || mustProvide("textcommaaboveright") ||
            mustProvide("textcommabelow") || mustProvide("textbaltic"))
                macros << lyxaccent_def;
@@ -1266,6 +1339,13 @@ TexString LaTeXFeatures::getMacros() const
        if (mustProvide("textbaltic"))
                macros << textbaltic_def << '\n';
 
+       // split-level fractions
+       if (mustProvide("xfrac") || mustProvide("smallLetterFrac"))
+               macros << xfrac_def << '\n';
+
+       if (mustProvide("smallLetterFrac"))
+               macros << smallLetterFrac_def << '\n';
+
        if (mustProvide("lyxmathsym"))
                macros << lyxmathsym_def << '\n';
 
@@ -1312,6 +1392,20 @@ TexString LaTeXFeatures::getMacros() const
                macros << guillemotleft_def << '\n';
        if (mustProvide("guillemotright"))
                macros << guillemotright_def << '\n';
+       if (mustProvide("textquotedbl"))
+               macros << textquotedbl_def << '\n';
+       if (mustProvide("textquotesinglep")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotesinglep_xetex_def << '\n';
+               else
+                       macros << textquotesinglep_luatex_def << '\n';
+       }
+       if (mustProvide("textquotedblp")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotedblp_xetex_def << '\n';
+               else
+                       macros << textquotedblp_luatex_def << '\n';
+       }
 
        // Math mode
        if (mustProvide("binom") && !isRequired("amsmath"))