]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/Preamble.cpp
Some more oxygen svg icon fixes
[lyx.git] / src / tex2lyx / Preamble.cpp
index 934420a9c1cd364ae4793a5a4a82674e26795d16..94ab8f2b9ef23dee91eeaa52ede71d9df48b14f5 100644 (file)
@@ -39,9 +39,6 @@ using namespace lyx::support;
 
 namespace lyx {
 
-// special columntypes
-extern map<char, int> special_columns;
-
 Preamble preamble;
 
 namespace {
@@ -136,8 +133,8 @@ const char * const known_sans_fonts[] = { "avant", "berasans", "biolinum-type1",
 "kurierc", "kurierl", "kurierlc", "lmss", "tgadventor", "tgheros", 0};
 
 const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt",
-"courier", "lmtt", "luximono", "fourier", "lmodern", "mathpazo", "mathptmx",
-"newcent", "tgcursor", "txtt", 0};
+"courier", "lmtt", "luximono", "fourier", "libertineMono-type1", "lmodern",
+"mathpazo", "mathptmx", "newcent", "tgcursor", "txtt", 0};
 
 const char * const known_math_fonts[] = { "eulervm", "newtxmath", 0};
 
@@ -306,7 +303,7 @@ const char * const Preamble::polyglossia_languages[] = {
 "irish", "portuges", "thai", "bahasai", "english", "italian", "romanian", "turkish",
 "bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
 "samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "tibetan", "urdu",
-"brazil", "brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton", 
+"brazil", "brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton",
 "french", "lsorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar",
 "slovak", "welsh", "catalan", "german", "malayalam", "slovenian", "coptic", "greek",
 "marathi", "spanish", "austrian",
@@ -332,6 +329,12 @@ const char * const Preamble::coded_polyglossia_languages[] = {
 "polutonikogreek", 0};
 
 
+bool Preamble::usePolyglossia() const
+{
+       return h_use_non_tex_fonts && h_language_package == "default";
+}
+
+
 bool Preamble::indentParagraphs() const
 {
        return h_paragraph_separation == "indent";
@@ -396,6 +399,15 @@ Author const & Preamble::getAuthor(std::string const & name) const
 }
 
 
+int Preamble::getSpecialTableColumnArguments(char c) const
+{
+       map<char, int>::const_iterator it = special_columns_.find(c);
+       if (it == special_columns_.end())
+               return -1;
+       return it->second;
+}
+
+
 void Preamble::add_package(string const & name, vector<string> & options)
 {
        // every package inherits the global options
@@ -464,7 +476,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_font_typewriter         = "default";
        h_font_math               = "auto";
        h_font_default_family     = "default";
-       h_use_non_tex_fonts       = "false";
+       h_use_non_tex_fonts       = false;
        h_font_sc                 = "false";
        h_font_osf                = "false";
        h_font_sf_scale           = "100";
@@ -662,7 +674,7 @@ void Preamble::handle_package(Parser &p, string const & name,
 
        if (is_known(name, known_xetex_packages)) {
                xetex = true;
-               h_use_non_tex_fonts = "true";
+               h_use_non_tex_fonts = true;
                registerAutomaticallyLoadedPackage("fontspec");
                if (h_inputencoding == "auto")
                        p.setEncoding("UTF-8");
@@ -704,7 +716,7 @@ void Preamble::handle_package(Parser &p, string const & name,
                else if (opts == "osf")
                        h_font_osf = "true";
        }
-       
+
        if (name == "mathdesign") {
                if (opts.find("charter") != string::npos)
                        h_font_roman = "md-charter";
@@ -727,14 +739,19 @@ void Preamble::handle_package(Parser &p, string const & name,
        // sansserif fonts
        if (is_known(name, known_sans_fonts)) {
                h_font_sans = name;
-               if (options.size() == 1) {
+               if (options.size() >= 1) {
                        if (scale_as_percentage(opts, h_font_sf_scale))
                                options.clear();
                }
        }
 
-       if (name == "biolinum-type1")
+       if (name == "biolinum-type1") {
                h_font_sans = "biolinum";
+               // biolinum can have several options, e.g. [osf,scaled=0.97]
+               string::size_type pos = opts.find("osf");
+               if (pos != string::npos)
+                       h_font_osf = "true";
+       }
 
        // typewriter fonts
        if (is_known(name, known_typewriter_fonts)) {
@@ -742,13 +759,17 @@ void Preamble::handle_package(Parser &p, string const & name,
                // fourier as typewriter is handled in handling of \ttdefault
                if (name != "fourier") {
                        h_font_typewriter = name;
-                       if (options.size() == 1) {
+                       if (options.size() >= 1) {
                                if (scale_as_percentage(opts, h_font_tt_scale))
                                        options.clear();
                        }
                }
        }
 
+       if (name == "libertineMono-type1") {
+               h_font_typewriter = "libertine-mono";
+       }
+
        // font uses old-style figure
        if (name == "eco")
                h_font_osf = "true";
@@ -768,6 +789,14 @@ void Preamble::handle_package(Parser &p, string const & name,
                        h_font_math = "minion-ntxm";
        }
 
+       if (name == "iwona")
+               if (opts == "math")
+                       h_font_math = "iwona-math";
+
+       if (name == "kurier")
+               if (opts == "math")
+                       h_font_math = "kurier-math";
+
        // after the detection and handling of special cases, we can remove the
        // fonts, otherwise they would appear in the preamble, see bug #7856
        if (is_known(name, known_roman_fonts) || is_known(name, known_sans_fonts)
@@ -832,7 +861,7 @@ void Preamble::handle_package(Parser &p, string const & name,
        else if (name == "polyglossia") {
                h_language_package = "default";
                h_default_output_format = "pdf4";
-               h_use_non_tex_fonts = "true";
+               h_use_non_tex_fonts = true;
                xetex = true;
                registerAutomaticallyLoadedPackage("xunicode");
                if (h_inputencoding == "auto")
@@ -958,6 +987,9 @@ void Preamble::handle_package(Parser &p, string const & name,
                h_cite_engine_type = "authoryear";
        }
 
+       else if (name == "bibtopic")
+               h_use_bibtopic = "true";
+
        else if (name == "hyperref")
                handle_hyperref(options);
 
@@ -1107,7 +1139,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
           << "\\font_typewriter " << h_font_typewriter << "\n"
           << "\\font_math " << h_font_math << "\n"
           << "\\font_default_family " << h_font_default_family << "\n"
-          << "\\use_non_tex_fonts " << h_use_non_tex_fonts << "\n"
+          << "\\use_non_tex_fonts " << (h_use_non_tex_fonts ? "true" : "false") << '\n'
           << "\\font_sc " << h_font_sc << "\n"
           << "\\font_osf " << h_font_osf << "\n"
           << "\\font_sf_scale " << h_font_sf_scale << "\n"
@@ -1214,7 +1246,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                      TeX2LyXDocClass & tc)
 {
        // initialize fixed types
-       special_columns['D'] = 3;
+       special_columns_['D'] = 3;
        bool is_full_document = false;
        bool is_lyx_file = false;
        bool in_lyx_preamble = false;
@@ -1442,7 +1474,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                h_preamble << ss.str();
                        }
                }
-               
+
                else if (t.cs() == "AtBeginDocument") {
                        string const name = p.verbatim_item();
                        // only non-lyxspecific stuff
@@ -1679,7 +1711,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                istringstream is(string(opts, 1));
                                is >> nargs;
                        }
-                       special_columns[name[0]] = nargs;
+                       special_columns_[name[0]] = nargs;
                        h_preamble << "\\newcolumntype{" << name << "}";
                        if (nargs)
                                h_preamble << "[" << nargs << "]";
@@ -1714,7 +1746,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                else if (content == "\\bigskipamount")
                                        h_defskip = "bigskip";
                                else
-                                       h_defskip = content;
+                                       h_defskip = translate_len(content);
                        } else
                                h_preamble << "\\setlength{" << name << "}{" << content << "}";
                }