]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Remove unneeded method.
[lyx.git] / src / BufferParams.cpp
index 862c3ede40cbe739d54ebdef7a36fcbf3662786e..e1a279f3e1761dada9c7a8b8c33fd5ae3b179efc 100644 (file)
@@ -102,7 +102,6 @@ static char const * const tex_graphics[] = {
 };
 
 
-
 namespace lyx {
 
 // Local translators
@@ -420,12 +419,14 @@ BufferParams::BufferParams()
        use_microtype = false;
        use_dash_ligatures = true;
        fonts_expert_sc = false;
-       fonts_old_figures = false;
+       fonts_roman_osf = false;
+       fonts_sans_osf = false;
+       fonts_typewriter_osf = false;
        fonts_sans_scale[0] = 100;
        fonts_sans_scale[1] = 100;
        fonts_typewriter_scale[0] = 100;
        fonts_typewriter_scale[1] = 100;
-       inputenc = "auto";
+       inputenc = "utf8";
        lang_package = "default";
        graphics_driver = "default";
        default_output_format = "default";
@@ -435,6 +436,7 @@ BufferParams::BufferParams()
        columns = 1;
        listings_params = string();
        pagestyle = "default";
+       tablestyle = "default";
        suppress_date = false;
        justification = true;
        // no color is the default (white)
@@ -463,6 +465,7 @@ BufferParams::BufferParams()
        output_sync = false;
        use_refstyle = true;
        use_minted = false;
+       use_lineno = false;
 
        // map current author
        author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
@@ -754,15 +757,6 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                origin.replace(0, sysdirprefix.length() - 1,
                                        package().system_support().absFileName());
                }
-               string const builddirprefix = "/buildlyxdir/";
-               if (prefixIs(origin, builddirprefix)) {
-                       string docsys;
-                       if (inSystemDir(filepath, docsys))
-                               origin.replace(0, builddirprefix.length() - 1, docsys);
-                       else
-                               origin.replace(0, builddirprefix.length() - 1,
-                                       package().system_support().absFileName());
-               }
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
        } else if (token == "\\begin_local_layout") {
@@ -840,14 +834,24 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> useNonTeXFonts;
        } else if (token == "\\font_sc") {
                lex >> fonts_expert_sc;
-       } else if (token == "\\font_osf") {
-               lex >> fonts_old_figures;
+       } else if (token == "\\font_roman_osf") {
+               lex >> fonts_roman_osf;
+       } else if (token == "\\font_sans_osf") {
+               lex >> fonts_sans_osf;
+       } else if (token == "\\font_typewriter_osf") {
+               lex >> fonts_typewriter_osf;
+       } else if (token == "\\font_roman_opts") {
+               lex >> font_roman_opts;
        } else if (token == "\\font_sf_scale") {
                lex >> fonts_sans_scale[0];
                lex >> fonts_sans_scale[1];
+       } else if (token == "\\font_sans_opts") {
+               lex >> font_sans_opts;
        } else if (token == "\\font_tt_scale") {
                lex >> fonts_typewriter_scale[0];
                lex >> fonts_typewriter_scale[1];
+       } else if (token == "\\font_typewriter_opts") {
+               lex >> font_typewriter_opts;
        } else if (token == "\\font_cjk") {
                lex >> fonts_cjk;
        } else if (token == "\\use_microtype") {
@@ -1061,6 +1065,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                sides = sidestranslator().find(psides);
        } else if (token == "\\paperpagestyle") {
                lex >> pagestyle;
+       } else if (token == "\\tablestyle") {
+               lex >> tablestyle;
        } else if (token == "\\bullet") {
                readBullets(lex);
        } else if (token == "\\bulletLaTeX") {
@@ -1113,6 +1119,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> use_refstyle;
        } else if (token == "\\use_minted") {
                lex >> use_minted;
+       } else if (token == "\\use_lineno") {
+               lex >> use_lineno;
+       } else if (token == "\\lineno_options") {
+               lex.eatLine();
+               lineno_opts = trim(lex.getString());
        } else {
                lyxerr << "BufferParams::readToken(): Unknown token: " <<
                        token << endl;
@@ -1151,10 +1162,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        string const relpath =
                to_utf8(makeRelPath(from_utf8(filepath), from_utf8(sysdir)));
        if (!prefixIs(relpath, "../") && !FileName::isAbsolute(relpath))
-               filepath = (prefixIs(docsys, package().build_support().realPath())) ?
-                                       addPath("/buildlyxdir", relpath)
-                                     : addPath("/systemlyxdir", relpath);
-
+               filepath = addPath("/systemlyxdir", relpath);
        else if (!save_transient_properties || !lyxrc.save_origin)
                filepath = "unavailable";
        os << "\\origin " << quoteIfNeeded(filepath) << '\n';
@@ -1255,15 +1263,22 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\font_default_family " << fonts_default_family
           << "\n\\use_non_tex_fonts " << convert<string>(useNonTeXFonts)
           << "\n\\font_sc " << convert<string>(fonts_expert_sc)
-          << "\n\\font_osf " << convert<string>(fonts_old_figures)
-          << "\n\\font_sf_scale " << fonts_sans_scale[0]
-          << ' ' << fonts_sans_scale[1]
-          << "\n\\font_tt_scale " << fonts_typewriter_scale[0]
-          << ' ' << fonts_typewriter_scale[1]
-          << '\n';
-       if (!fonts_cjk.empty()) {
+          << "\n\\font_roman_osf " << convert<string>(fonts_roman_osf)
+          << "\n\\font_sans_osf " << convert<string>(fonts_sans_osf)
+          << "\n\\font_typewriter_osf " << convert<string>(fonts_typewriter_osf);
+       if (!font_roman_opts.empty())
+               os << "\n\\font_roman_opts \"" << font_roman_opts << "\"";
+       os << "\n\\font_sf_scale " << fonts_sans_scale[0]
+          << ' ' << fonts_sans_scale[1];
+       if (!font_sans_opts.empty())
+               os << "\n\\font_sans_opts \"" << font_sans_opts << "\"";
+       os << "\n\\font_tt_scale " << fonts_typewriter_scale[0]
+          << ' ' << fonts_typewriter_scale[1];
+       if (!font_typewriter_opts.empty())
+               os << "\n\\font_typewriter_opts \"" << font_typewriter_opts << "\"";
+       os << '\n';
+       if (!fonts_cjk.empty())
                os << "\\font_cjk " << fonts_cjk << '\n';
-       }
        os << "\\use_microtype " << convert<string>(use_microtype) << '\n';
        os << "\\use_dash_ligatures " << convert<string>(use_dash_ligatures) << '\n';
        os << "\\graphics " << graphics_driver << '\n';
@@ -1318,7 +1333,12 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\justification " << convert<string>(justification)
           << "\n\\use_refstyle " << use_refstyle
           << "\n\\use_minted " << use_minted
+          << "\n\\use_lineno " << use_lineno
           << '\n';
+
+       if (!lineno_opts.empty())
+               os << "\\lineno_options " << lineno_opts << '\n';
+
        if (isbackgroundcolor == true)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
        if (isfontcolor == true)
@@ -1408,7 +1428,8 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\dynamic_quotes " << dynamic_quotes
           << "\n\\papercolumns " << columns
           << "\n\\papersides " << sides
-          << "\n\\paperpagestyle " << pagestyle << '\n';
+          << "\n\\paperpagestyle " << pagestyle
+          << "\n\\tablestyle " << tablestyle << '\n';
        if (!listings_params.empty())
                os << "\\listings_params \"" <<
                        InsetListingsParams(listings_params).encodedString() << "\"\n";
@@ -1716,8 +1737,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                                language_options << ',';
                        language_options << language->babel();
                }
-               if (global && !features.needBabelLangOptions()
-                   && !language_options.str().empty())
+               if (global && !language_options.str().empty())
                        clsoptions << language_options.str() << ',';
        }
 
@@ -1750,7 +1770,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                os << from_ascii(ams);
 
        if (useNonTeXFonts) {
-               if (!features.isProvided("fontspec"))
+               // Babel (as of 2017/11/03) loads fontspec itself
+               if (!features.isProvided("fontspec")
+                   && !(features.useBabel() && features.isAvailable("babel-2017/11/03")))
                        os << "\\usepackage{fontspec}\n";
                if (features.mustProvide("unicode-math")
                    && features.isAvailable("unicode-math"))
@@ -1768,8 +1790,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        // font selection must be done before loading fontenc.sty
+       // but after babel with non-TeX fonts
        string const fonts = loadFonts(features);
-       if (!fonts.empty())
+       if (!fonts.empty() && (!features.useBabel() || !useNonTeXFonts))
                os << from_utf8(fonts);
 
        if (fonts_default_family != "default")
@@ -1777,12 +1800,14 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                   << from_ascii(fonts_default_family) << "}\n";
 
        // set font encoding
-       // XeTeX and LuaTeX (with OS fonts) do not need fontenc
+       // non-TeX fonts use font encoding TU (set by fontspec)
        if (!useNonTeXFonts && !features.isProvided("fontenc")
            && main_font_encoding() != "default") {
                // get main font encodings
                vector<string> fontencs = font_encodings();
                // get font encodings of secondary languages
+               // FIXME: some languages (hebrew, ...) assume a standard font encoding as last
+               // option (for text in other languages).
                features.getFontEncodings(fontencs);
                if (!fontencs.empty()) {
                        os << "\\usepackage["
@@ -1796,9 +1821,12 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                os << "\\usepackage{textcomp}\n";
        if (features.mustProvide("pmboxdraw"))
                os << "\\usepackage{pmboxdraw}\n";
-
+       
        // handle inputenc etc.
-       writeEncodingPreamble(os, features);
+       // (In documents containing text in Thai language, 
+       // we must load inputenc after babel, see lib/languages).
+       if (!contains(features.getBabelPostsettings(), from_ascii("thai.ldf")))
+               writeEncodingPreamble(os, features);
 
        // includeonly
        if (!features.runparams().includeall && !included_children_.empty()) {
@@ -2083,7 +2111,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                        os << features.getBabelPresettings();
                        // FIXME UNICODE
                        os << from_utf8(babelCall(language_options.str(),
-                                                 features.needBabelLangOptions())) + '\n';
+                                                                         !lyxrc.language_global_options)) + '\n';
                        os << features.getBabelPostsettings();
        }
 
@@ -2125,6 +2153,14 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                // hyperref loads this automatically
                os << "\\usepackage{nameref}\n";
 
+       if (use_lineno){
+               os << "\\usepackage";
+               if (!lineno_opts.empty())
+                       os << "[" << lineno_opts << "]";
+               os << "{lineno}\n";
+               os << "\\linenumbers\n";
+       }
+
        // bibtopic needs to be loaded after hyperref.
        // the dot provides the aux file naming which LyX can detect.
        if (features.mustProvide("bibtopic"))
@@ -2279,9 +2315,18 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                os << features.getBabelPresettings();
                // FIXME UNICODE
                os << from_utf8(babelCall(language_options.str(),
-                                         features.needBabelLangOptions())) + '\n';
+                                         !lyxrc.language_global_options)) + '\n';
                os << features.getBabelPostsettings();
        }
+       // In documents containing text in Thai language, 
+       // we must load inputenc after babel (see lib/languages).
+       if (contains(features.getBabelPostsettings(), from_ascii("thai.ldf")))
+               writeEncodingPreamble(os, features);
+
+       // font selection must be done after babel with non-TeX fonts
+       if (!fonts.empty() && features.useBabel() && useNonTeXFonts)
+               os << from_utf8(fonts);
+
        if (features.isRequired("bicaption"))
                os << "\\usepackage{bicaption}\n";
        if (!listings_params.empty()
@@ -2322,8 +2367,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // esint and the other packages that provide special glyphs
        if (features.mustProvide("tipa") && useNonTeXFonts
            && !features.isProvided("xunicode")) {
-               // The package officially only supports XeTeX, but also works
-               // with LuaTeX. Thus we work around its XeTeX test.
+               // The `xunicode` package officially only supports XeTeX,
+               //  but also works with LuaTeX. We work around its XeTeX test.
                if (features.runparams().flavor != OutputParams::XETEX) {
                        os << "% Pretend to xunicode that we are XeTeX\n"
                           << "\\def\\XeTeXpicfile{}\n";
@@ -2448,6 +2493,7 @@ void BufferParams::useClassDefaults()
        sides = tclass.sides();
        columns = tclass.columns();
        pagestyle = tclass.pagestyle();
+       tablestyle = tclass.tablestyle();
        use_default_options = true;
        // Only if class has a ToC hierarchy
        if (tclass.hasTocLevels()) {
@@ -2464,6 +2510,7 @@ bool BufferParams::hasClassDefaults() const
        return sides == tclass.sides()
                && columns == tclass.columns()
                && pagestyle == tclass.pagestyle()
+               && tablestyle == tclass.tablestyle()
                && use_default_options
                && secnumdepth == tclass.secnumdepth()
                && tocdepth == tclass.tocdepth();
@@ -2637,13 +2684,15 @@ FormatList const & BufferParams::exportableFormats(bool only_viewable) const
        if (useNonTeXFonts) {
                excludes.insert("latex");
                excludes.insert("pdflatex");
-       }
-       FormatList result =
-               theConverters().getReachable(backs[0], only_viewable, true, excludes);
+       } else if (inputenc != "ascii" && inputenc != "utf8-plain")
+                 // XeTeX with TeX fonts requires input encoding ascii (#10600).
+                 excludes.insert("xetex");
+       FormatList result = theConverters().getReachable(backs[0], only_viewable,
+                                                                                                        true, excludes);
        for (vector<string>::const_iterator it = backs.begin() + 1;
             it != backs.end(); ++it) {
                FormatList r = theConverters().getReachable(*it, only_viewable,
-                               false, excludes);
+                                                                                                       false, excludes);
                result.insert(result.end(), r.begin(), r.end());
        }
        sort(result.begin(), result.end(), Format::formatSorter);
@@ -2667,7 +2716,9 @@ vector<string> BufferParams::backends() const
                                v.push_back("pdflatex");
                                v.push_back("latex");
                        }
-                       v.push_back("xetex");
+                       if (useNonTeXFonts 
+                               || inputenc == "ascii" || inputenc == "utf8-plain")
+                               v.push_back("xetex");
                        v.push_back("luatex");
                        v.push_back("dviluatex");
                }
@@ -3200,8 +3251,7 @@ string BufferParams::babelCall(string const & lang_opts, bool const langoptions)
        // other languages are used (lang_opts is then empty)
        if (lang_opts.empty())
                return string();
-       // either a specific language (AsBabelOptions setting in
-       // lib/languages) or the prefs require the languages to
+       // The prefs may require the languages to
        // be submitted to babel itself (not the class).
        if (langoptions)
                return "\\usepackage[" + lang_opts + "]{babel}";
@@ -3230,15 +3280,11 @@ docstring BufferParams::getGraphicsDriver(string const & package) const
 void BufferParams::writeEncodingPreamble(otexstream & os,
                                         LaTeXFeatures & features) const
 {
-       // XeTeX/LuaTeX: (see also #9740)
-       // With Unicode fonts we use utf8-plain without encoding package.
-       // With TeX fonts, we cannot use utf8-plain, but "inputenc" fails.
-       // XeTeX must use ASCII encoding (see Buffer.cpp),
-       //  for LuaTeX, we load "luainputenc" (see below).
-       if (useNonTeXFonts || features.runparams().flavor == OutputParams::XETEX)
+       // With no-TeX fonts we use utf8-plain without encoding package.
+       if (useNonTeXFonts)
                return;
 
-       if (inputenc == "auto") {
+       if (inputenc == "auto-legacy") {
                string const doc_encoding =
                        language->encoding()->latexName();
                Encoding::Package const package =
@@ -3247,13 +3293,14 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                // Create list of inputenc options:
                set<string> encoding_set;
                // luainputenc fails with more than one encoding
-               if (!features.runparams().isFullUnicode()) // if we reach this point, this means LuaTeX with TeX fonts
+               if (features.runparams().flavor != OutputParams::LUATEX
+                       && features.runparams().flavor != OutputParams::DVILUATEX)
                        // list all input encodings used in the document
                        encoding_set = features.getEncodingSet(doc_encoding);
 
-               // If the "japanese" package (i.e. pLaTeX) is used,
-               // inputenc must be omitted.
-               // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
+               // The "japanese" babel-language requires  the pLaTeX engine
+               // which conflicts with "inputenc".
+               // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
                if ((!encoding_set.empty() || package == Encoding::inputenc)
                    && !features.isRequired("japanese")
                    && !features.isProvided("inputenc")) {
@@ -3277,12 +3324,13 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                        else
                                os << "]{inputenc}\n";
                }
-       } else if (inputenc != "default") {
+       } else if (inputenc != "auto-legacy-plain") {
                switch (encoding().package()) {
                case Encoding::none:
                case Encoding::CJK:
                case Encoding::japanese:
-                       if (encoding().iconvName() != "UTF-8")
+                       if (encoding().iconvName() != "UTF-8"
+                               && !features.runparams().isFullUnicode())
                          // don't default to [utf8]{inputenc} with TeXLive >= 18
                          os << "\\ifdefined\\UseRawInputEncoding\n"
                                 << "  \\UseRawInputEncoding\\fi\n";
@@ -3302,7 +3350,7 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
                        break;
                }
        }
-       if (inputenc == "default" || features.isRequired("japanese")) {
+       if (inputenc == "auto-legacy-plain" || features.isRequired("japanese")) {
                // don't default to [utf8]{inputenc} with TeXLive >= 18
                os << "\\ifdefined\\UseRawInputEncoding\n";
                os << "  \\UseRawInputEncoding\\fi\n";
@@ -3351,36 +3399,86 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
                // variants are understood by both engines. However,
                // we want to provide support for at least TeXLive 2009
                // (for XeTeX; LuaTeX is only supported as of v.2)
+               // As of 2017/11/03, Babel has its own higher-level
+               // interface on top of fontspec that is to be used.
+               bool const babelfonts = features.useBabel()
+                               && features.isAvailable("babel-2017/11/03");
                string const texmapping =
                        (features.runparams().flavor == OutputParams::XETEX) ?
                        "Mapping=tex-text" : "Ligatures=TeX";
                if (fontsRoman() != "default") {
-                       os << "\\setmainfont[" << texmapping;
-                       if (fonts_old_figures)
+                       if (babelfonts)
+                               os << "\\babelfont{rm}[";
+                       else
+                               os << "\\setmainfont[";
+                       if (!font_roman_opts.empty())
+                               os << font_roman_opts << ',';
+                       os << texmapping;
+                       if (fonts_roman_osf)
                                os << ",Numbers=OldStyle";
                        os << "]{" << parseFontName(fontsRoman()) << "}\n";
                }
                if (fontsSans() != "default") {
                        string const sans = parseFontName(fontsSans());
-                       if (fontsSansScale() != 100)
-                               os << "\\setsansfont[Scale="
-                                  << float(fontsSansScale()) / 100
-                                  << "," << texmapping << "]{"
+                       if (fontsSansScale() != 100) {
+                               if (babelfonts)
+                                       os << "\\babelfont{sf}";
+                               else
+                                       os << "\\setsansfont";
+                               os << "[Scale="
+                                  << float(fontsSansScale()) / 100 << ',';
+                               if (fonts_sans_osf)
+                                       os << "Numbers=OldStyle,";
+                               if (!font_sans_opts.empty())
+                                       os << font_sans_opts << ',';
+                               os << texmapping << "]{"
                                   << sans << "}\n";
-                       else
-                               os << "\\setsansfont[" << texmapping << "]{"
+                       } else {
+                               if (babelfonts)
+                                       os << "\\babelfont{sf}[";
+                               else
+                                       os << "\\setsansfont[";
+                               if (fonts_sans_osf)
+                                       os << "Numbers=OldStyle,";
+                               if (!font_sans_opts.empty())
+                                       os << font_sans_opts << ',';
+                               os << texmapping << "]{"
                                   << sans << "}\n";
+                       }
                }
                if (fontsTypewriter() != "default") {
                        string const mono = parseFontName(fontsTypewriter());
-                       if (fontsTypewriterScale() != 100)
-                               os << "\\setmonofont[Scale="
-                                  << float(fontsTypewriterScale()) / 100
-                                  << "]{"
-                                  << mono << "}\n";
-                       else
-                               os << "\\setmonofont{"
+                       if (fontsTypewriterScale() != 100) {
+                               if (babelfonts)
+                                       os << "\\babelfont{tt}";
+                               else
+                                       os << "\\setmonofont";
+                               os << "[Scale="
+                                  << float(fontsTypewriterScale()) / 100;
+                               if (fonts_typewriter_osf)
+                                       os << ",Numbers=OldStyle";
+                               if (!font_typewriter_opts.empty())
+                                       os << ',' << font_typewriter_opts;
+                               os << "]{"
                                   << mono << "}\n";
+                       } else {
+                               if (babelfonts)
+                                       os << "\\babelfont{tt}";
+                               else
+                                       os << "\\setmonofont";
+                               if (!font_typewriter_opts.empty() || fonts_typewriter_osf) {
+                                       os << '[';
+                                       if (fonts_typewriter_osf)
+                                               os << "Numbers=OldStyle";
+                                       if (!font_typewriter_opts.empty()) {
+                                               if (fonts_typewriter_osf)
+                                                       os << ',';
+                                               os << font_typewriter_opts;
+                                       }
+                                       os << ']';
+                               }
+                               os << '{' << mono << "}\n";
+                       }
                }
                return os.str();
        }
@@ -3393,22 +3491,22 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 
        // ROMAN FONTS
        os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsRoman())).getLaTeXCode(
-               dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
-               nomath);
+               dryrun, ot1, complete, fonts_expert_sc, fonts_roman_osf,
+               nomath, font_roman_opts);
 
        // SANS SERIF
        os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsSans())).getLaTeXCode(
-               dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
-               nomath, fontsSansScale());
+               dryrun, ot1, complete, fonts_expert_sc, fonts_sans_osf,
+               nomath, font_sans_opts, fontsSansScale());
 
        // MONOSPACED/TYPEWRITER
        os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsTypewriter())).getLaTeXCode(
-               dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
-               nomath, fontsTypewriterScale());
+               dryrun, ot1, complete, fonts_expert_sc, fonts_typewriter_osf,
+               nomath, font_typewriter_opts, fontsTypewriterScale());
 
        // MATH
        os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsMath())).getLaTeXCode(
-               dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
+               dryrun, ot1, complete, fonts_expert_sc, fonts_roman_osf,
                nomath);
 
        return os.str();
@@ -3418,16 +3516,12 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 Encoding const & BufferParams::encoding() const
 {
        // Main encoding for LaTeX output.
-       //
-       // Exception: XeTeX with 8-bit TeX fonts requires ASCII (see #9740).
-       // As the "flavor" is only known once export started, this
-       // cannot be handled here. Instead, runparams.encoding is set
-       // to ASCII in Buffer::makeLaTeXFile (for export)
-       // and Buffer::writeLaTeXSource (for preview).
        if (useNonTeXFonts)
                return *(encodings.fromLyXName("utf8-plain"));
-       if (inputenc == "auto" || inputenc == "default")
+       if (inputenc == "auto-legacy" || inputenc == "auto-legacy-plain")
                return *language->encoding();
+       if (inputenc == "utf8" && language->lang() == "japanese")
+               return *(encodings.fromLyXName("utf8-platex"));
        Encoding const * const enc = encodings.fromLyXName(inputenc);
        if (enc)
                return *enc;
@@ -3556,4 +3650,20 @@ void BufferParams::copyForAdvFR(const BufferParams & bp)
        setBaseClass(doc_class);
 }
 
+
+void BufferParams::setBibFileEncoding(string const & file, string const & enc)
+{
+       bib_encodings[file] = enc;
+}
+
+
+string const BufferParams::bibFileEncoding(string const & file) const
+{
+       if (bib_encodings.find(file) == bib_encodings.end())
+               return string();
+       return bib_encodings.find(file)->second;
+}
+
+
+
 } // namespace lyx