]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/Preamble.cpp
Cmake export tests: Ignore missing glyphs on some tests
[lyx.git] / src / tex2lyx / Preamble.cpp
index 7d6a07c9747bef089b174e51e18065fec1fe3e53..6650cf3fbbfc79cee7bb616c1a4653a360ba8a09 100644 (file)
@@ -125,17 +125,18 @@ const char * const known_old_language_packages[] = {"french", "frenchle",
 char const * const known_fontsizes[] = { "10pt", "11pt", "12pt", 0 };
 
 const char * const known_roman_fonts[] = { "ae", "beraserif", "bookman",
-"ccfonts", "chancery", "charter", "cmr", "fourier", "garamondx", "libertine",
-"libertine-type1", "lmodern", "mathdesign", "mathpazo", "mathptmx", "newcent",
-"tgbonum", "tgchorus", "tgpagella", "tgschola", "tgtermes", "utopia", 0};
+"ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "fourier",
+"garamondx", "libertine", "libertine-type1", "lmodern", "mathdesign", "mathpazo",
+"mathptmx", "newcent", "NotoSerif-TLF", "tgbonum", "tgchorus", "tgpagella", "tgschola",
+"tgtermes", "utopia", 0};
 
 const char * const known_sans_fonts[] = { "avant", "berasans", "biolinum-type1",
 "cmbr", "cmss", "helvet", "iwona", "iwonac", "iwonal", "iwonalc", "kurier",
-"kurierc", "kurierl", "kurierlc", "lmss", "tgadventor", "tgheros", 0};
+"kurierc", "kurierl", "kurierlc", "lmss", "NotoSans-TLF", "tgadventor", "tgheros", 0};
 
 const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt",
 "courier", "lmtt", "luximono", "fourier", "libertineMono-type1", "lmodern",
-"mathpazo", "mathptmx", "newcent", "tgcursor", "txtt", 0};
+"mathpazo", "mathptmx", "newcent", "NotoMono-TLF", "tgcursor", "txtt", 0};
 
 const char * const known_math_fonts[] = { "eulervm", "newtxmath", 0};
 
@@ -182,9 +183,10 @@ const char * const known_xetex_packages[] = {"arabxetex", "fixlatvian",
 const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb",
 "amstext", "amsthm", "array", "babel", "booktabs", "calc", "CJK", "color",
 "float", "fontspec", "framed", "graphicx", "hhline", "ifthen", "longtable",
-"makeidx", "multirow", "nomencl", "pdfpages", "prettyref", "refstyle", "rotating",
-"rotfloat", "splitidx", "setspace", "subscript", "textcomp", "tipa", "tipx",
-"tone", "ulem", "url", "varioref", "verbatim", "wrapfig", "xcolor", "xunicode", 0};
+"makeidx", "minted", "multirow", "nomencl", "pdfpages", "prettyref", "refstyle",
+"rotating", "rotfloat", "splitidx", "setspace", "subscript", "textcomp", "tipa",
+"tipx", "tone", "ulem", "url", "varioref", "verbatim", "wrapfig", "xcolor",
+"xunicode", 0};
 
 // codes used to remove packages that are loaded automatically by LyX.
 // Syntax: package_beg_sep<name>package_mid_sep<package loading code>package_end_sep
@@ -461,7 +463,7 @@ string remove_braces(string const & value)
 
 Preamble::Preamble() : one_language(true), explicit_babel(false),
        title_layout_found(false), index_number(0), h_font_cjk_set(false),
-       h_use_microtype(false)
+       h_use_microtype("false")
 {
        //h_backgroundcolor;
        //h_boxbgcolor;
@@ -471,6 +473,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_cite_engine_type        = "default";
        h_color                   = "#008000";
        h_defskip                 = "medskip";
+       h_dynamic_quotes          = false;
        //h_float_placement;
        //h_fontcolor;
        h_fontencoding            = "default";
@@ -491,6 +494,8 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_font_tt_scale[0]        = "100";
        h_font_tt_scale[1]        = "100";
        //h_font_cjk
+       h_is_mathindent           = "0";
+       h_math_numbering_side     = "default";
        h_graphics                = "default";
        h_default_output_format   = "default";
        h_html_be_strict          = "false";
@@ -533,7 +538,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_pdf_pdfusetitle         = "0";
        //h_pdf_pagemode;
        //h_pdf_quoted_options;
-       h_quotes_language         = "english";
+       h_quotes_style         = "english";
        h_secnumdepth             = "3";
        h_shortcut[0]             = "idx";
        h_spacing                 = "single";
@@ -543,12 +548,14 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_tocdepth                = "3";
        h_tracking_changes        = "false";
        h_use_bibtopic            = "false";
+       h_use_dash_ligatures      = "true";
        h_use_indices             = "false";
        h_use_geometry            = "false";
        h_use_default_options     = "false";
        h_use_hyperref            = "false";
-       h_use_microtype           = false;
+       h_use_microtype           = "false";
        h_use_refstyle            = false;
+       h_use_minted              = false;
        h_use_packages["amsmath"]    = "1";
        h_use_packages["amssymb"]    = "0";
        h_use_packages["cancel"]     = "0";
@@ -748,6 +755,36 @@ void Preamble::handle_package(Parser &p, string const & name,
        else if (name == "mathptmx")
                h_font_roman[0] = "times";
 
+       if (name == "crimson")
+               h_font_roman[0] = "cochineal";
+
+       if (name == "cochineal") {
+               h_font_roman[0] = "cochineal";
+               // cochineal can have several options, e.g. [proportional,osf]
+               string::size_type pos = opts.find("osf");
+               if (pos != string::npos)
+                       h_font_osf = "true";
+       }
+
+       if (name == "noto") {
+               // noto can have several options
+               if (opts.empty())
+                       h_font_roman[0] = "NotoSerif-TLF";
+               string::size_type pos = opts.find("rm");
+               if (pos != string::npos)
+                       h_font_roman[0] = "NotoSerif-TLF";
+               pos = opts.find("sf");
+               if (pos != string::npos)
+                       h_font_sans[0] = "NotoSans-TLF";
+               pos = opts.find("nott");
+               if (pos != string::npos) {
+                       h_font_roman[0] = "NotoSerif-TLF";
+                       h_font_sans[0] = "NotoSans-TLF";
+               }
+               // noto as typewriter is handled in handling of \ttdefault
+               // special cases are handled in handling of \rmdefault and \sfdefault
+       }
+
        // sansserif fonts
        if (is_known(name, known_sans_fonts)) {
                h_font_sans[0] = name;
@@ -799,6 +836,8 @@ void Preamble::handle_package(Parser &p, string const & name,
                        h_font_math[0] = "libertine-ntxm";
                else if (opts == "minion")
                        h_font_math[0] = "minion-ntxm";
+               else if (opts == "cochineal")
+                       h_font_math[0] = "cochineal-ntxm";
        }
 
        if (name == "iwona")
@@ -953,6 +992,8 @@ void Preamble::handle_package(Parser &p, string const & name,
        else if (is_known(name, known_lyx_packages) && options.empty()) {
                if (name == "splitidx")
                        h_use_indices = "true";
+               if (name == "minted")
+                       h_use_minted = "true";
                if (name == "refstyle")
                        h_use_refstyle = true;
                else if (name == "prettyref")
@@ -1021,7 +1062,7 @@ void Preamble::handle_package(Parser &p, string const & name,
        else if (name == "microtype") {
                //we internally support only microtype without params
                if (options.empty())
-                       h_use_microtype = true;
+                       h_use_microtype = "true";
                else
                        h_preamble << "\\usepackage[" << opts << "]{microtype}";
        }
@@ -1079,22 +1120,22 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
        // (quotes for kazakh and interlingua are unknown)
        // danish
        if (is_known(h_language, known_danish_quotes_languages))
-               h_quotes_language = "danish";
+               h_quotes_style = "danish";
        // french
        else if (is_known(h_language, known_french_quotes_languages))
-               h_quotes_language = "french";
+               h_quotes_style = "french";
        // german
        else if (is_known(h_language, known_german_quotes_languages))
-               h_quotes_language = "german";
+               h_quotes_style = "german";
        // polish
        else if (is_known(h_language, known_polish_quotes_languages))
-               h_quotes_language = "polish";
+               h_quotes_style = "polish";
        // swedish
        else if (is_known(h_language, known_swedish_quotes_languages))
-               h_quotes_language = "swedish";
+               h_quotes_style = "swedish";
        //english
        else if (is_known(h_language, known_english_quotes_languages))
-               h_quotes_language = "english";
+               h_quotes_style = "english";
 
        if (contains(h_float_placement, "H"))
                registerAutomaticallyLoadedPackage("float");
@@ -1175,6 +1216,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
        if (!h_font_cjk.empty())
                os << "\\font_cjk " << h_font_cjk << '\n';
        os << "\\use_microtype " << h_use_microtype << '\n'
+          << "\\use_dash_ligatures " << h_use_dash_ligatures << '\n'
           << "\\graphics " << h_graphics << '\n'
           << "\\default_output_format " << h_default_output_format << "\n"
           << "\\output_sync " << h_output_sync << "\n";
@@ -1223,7 +1265,8 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
           << "\\paperorientation " << h_paperorientation << '\n'
           << "\\suppress_date " << h_suppress_date << '\n'
           << "\\justification " << h_justification << '\n'
-          << "\\use_refstyle " << h_use_refstyle << '\n';
+          << "\\use_refstyle " << h_use_refstyle << '\n'
+          << "\\use_minted " << h_use_minted << '\n';
        if (!h_fontcolor.empty())
                os << "\\fontcolor " << h_fontcolor << '\n';
        if (!h_notefontcolor.empty())
@@ -1253,7 +1296,12 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
                os << "\\defskip " << h_defskip << "\n";
        else
                os << "\\paragraph_indentation " << h_paragraph_indentation << "\n";
-       os << "\\quotes_language " << h_quotes_language << "\n"
+       os << "\\is_math_indent " << h_is_mathindent << "\n";
+       if (!h_mathindentation.empty())
+               os << "\\math_indentation " << h_mathindentation << "\n";
+       os << "\\math_numbering_side " << h_math_numbering_side << "\n";
+       os << "\\quotes_style " << h_quotes_style << "\n"
+          << "\\dynamic_quotes " << h_dynamic_quotes << "\n"
           << "\\papercolumns " << h_papercolumns << "\n"
           << "\\papersides " << h_papersides << "\n"
           << "\\paperpagestyle " << h_paperpagestyle << "\n";
@@ -1640,6 +1688,24 @@ void Preamble::parse(Parser & p, string const & forceclass,
                        handle_opt(opts, known_languages, h_language);
                        delete_opt(opts, known_languages);
 
+                       // math indentation
+                       if ((it = find(opts.begin(), opts.end(), "fleqn"))
+                                != opts.end()) {
+                               h_is_mathindent = "1";
+                               opts.erase(it);
+                       }
+                       // formula numbering side
+                       if ((it = find(opts.begin(), opts.end(), "leqno"))
+                                != opts.end()) {
+                               h_math_numbering_side = "left";
+                               opts.erase(it);
+                       }
+                       else if ((it = find(opts.begin(), opts.end(), "reqno"))
+                                != opts.end()) {
+                               h_math_numbering_side = "right";
+                               opts.erase(it);
+                       }
+                       
                        // paper orientation
                        if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
                                h_paperorientation = "landscape";
@@ -1797,6 +1863,8 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                        h_defskip = "bigskip";
                                else
                                        h_defskip = translate_len(content);
+                       } else if (name == "\\mathindent") {
+                               h_mathindentation = translate_len(content);
                        } else
                                h_preamble << "\\setlength{" << name << "}{" << content << "}";
                }