Rename legacy input encoding settings.

Format incremented to 573
This commit is contained in:
Günter Milde 2019-04-16 20:17:32 +02:00
parent e0f5641089
commit 27ba6f282d
34 changed files with 105 additions and 74 deletions

View File

@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be
-----------------------
2019-04-16 Günter Milde <milde@lyx.org>
* format incremented to 573: Rename legacy input encoding settings.
2019-04-07 Kornel Benko <kornel@lyx.org>
* format incremented to 572: Extended Noto fonts.

View File

@ -1,5 +1,5 @@
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 572
\begin_document
\begin_header
\save_transient_properties true
@ -14,7 +14,7 @@ logicalmkup
\language english
\language_package default
\inputencoding auto
\fontencoding global
\fontencoding auto
\font_roman "lmodern" "default"
\font_sans "lmss" "default"
\font_typewriter "lmtt" "default"
@ -87,6 +87,7 @@ logicalmkup
\papercolumns 1
\papersides 2
\paperpagestyle headings
\tablestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
@ -479,7 +480,7 @@ Add an entry to both format lists (for conversion and reversion) in
status collapsed
\begin_layout Plain Layout
lib/lyx2lyx/lyx_2_3.py
lib/lyx2lyx/lyx_2_4.py
\end_layout
\end_inset
@ -582,8 +583,11 @@ src/tex2lyx/TODO.txt
It would be nice if you could create a .lyx test file which contains instances
of all changed or added features.
This could then be used to test lyx2lyx and tex2lyx.
Unfortunately, it has not yet been decided how to collect such examples,
so please ask on the development list if you want to create one.
Test samples are collected under the corresponding subdirectories of
\family typewriter
/autotests
\family default
.
\end_layout
\begin_layout Enumerate

View File

@ -283,6 +283,22 @@ def revert_fonts(document, fm, fontmap):
###
###############################################################################
def convert_inputencoding_namechange(document):
" Rename inputencoding settings. "
i = find_token(document.header, "\\inputencoding", 0)
if i == -1:
return
s = document.header[i].replace("auto", "auto-legacy")
document.header[i] = s.replace("default", "auto-legacy-plain")
def revert_inputencoding_namechange(document):
" Rename inputencoding settings. "
i = find_token(document.header, "\\inputencoding", 0)
if i == -1:
return
s = document.header[i].replace("auto-legacy-plain", "default")
document.header[i] = s.replace("auto-legacy", "auto")
def convert_notoFonts(document):
" Handle Noto fonts definition to LaTeX "
@ -1635,10 +1651,11 @@ convert = [
[569, []],
[570, []],
[571, []],
[572, [convert_notoFonts]] # Added options thin, light, extralight for Noto
[572, [convert_notoFonts]], # Added options thin, light, extralight for Noto
[573, [convert_inputencoding_namechange]],
]
revert = [
revert = [[572, [revert_inputencoding_namechange]],
[571, [revert_notoFonts]],
[570, [revert_cmidruletrimming]],
[569, [revert_bibfileencodings]],

View File

@ -302,8 +302,8 @@ public:
OutputParams const &,
OutputWhat output = FullSource) const;
/** Export the buffer to LaTeX.
If \p os is a file stream, and params().inputenc is "auto" or
"default", and the buffer contains text in different languages
If \p os is a file stream, and params().inputenc is "auto-legacy" or
"auto-legacy-plain", and the buffer contains text in different languages
with more than one encoding, then this method will change the
encoding associated to \p os. Therefore you must not call this
method with a string stream if the output is supposed to go to a

View File

@ -436,7 +436,7 @@ BufferParams::BufferParams()
fonts_sans_scale[1] = 100;
fonts_typewriter_scale[0] = 100;
fonts_typewriter_scale[1] = 100;
inputenc = "auto";
inputenc = "auto-legacy";
lang_package = "default";
graphics_driver = "default";
default_output_format = "default";
@ -1786,6 +1786,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
// 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["
@ -1799,7 +1801,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
os << "\\usepackage{textcomp}\n";
if (features.mustProvide("pmboxdraw"))
os << "\\usepackage{pmboxdraw}\n";
// FIXME: With Thai as document or secondary language, we must load babel
// before inputenc (see lib/languages).
// handle inputenc etc.
writeEncodingPreamble(os, features);
@ -3245,7 +3249,7 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
if (useNonTeXFonts)
return;
if (inputenc == "auto") {
if (inputenc == "auto-legacy") {
string const doc_encoding =
language->encoding()->latexName();
Encoding::Package const package =
@ -3285,7 +3289,7 @@ 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:
@ -3315,7 +3319,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";
@ -3433,7 +3437,7 @@ Encoding const & BufferParams::encoding() const
// Main encoding for LaTeX output.
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"));

View File

@ -745,7 +745,7 @@ Encoding const * DocIterator::getEncoding() const
text.outerFont(sl.pit())).language();
// If we have a custom encoding for the buffer, we don't switch
// encodings (see output_latex::switchEncoding())
bool const customenc = bp.inputenc != "auto" && bp.inputenc != "default";
bool const customenc = bp.inputenc != "auto-legacy" && bp.inputenc != "auto-legacy-plain";
Encoding const * enc = customenc ? &bp.encoding() : lang->encoding();
// Some insets force specific encodings sometimes (e.g., listings in

View File

@ -101,9 +101,12 @@ void PDFOptions::writeLaTeX(OutputParams & runparams, otexstream & os,
if (!runparams.hyperref_driver.empty())
opt += runparams.hyperref_driver + ",";
// since LyX uses unicode, also set the PDF strings to unicode strings with the
// hyperref option "unicode"
opt += "unicode=true,";
// Since LyX uses unicode, also set the PDF strings to unicode strings
// with the hyperref option "unicode".
// (With Xe/LuaTeX and pTeX, unicode=true is the default
// and the option leads to errors with some Japanese document classes)
if (!runparams.isFullUnicode() && !runparams.use_japanese)
opt += "unicode=true,";
// only use the hyperref settings if hyperref is enabled by the user
// see bug #7052

View File

@ -3201,11 +3201,11 @@ void GuiDocument::applyView()
// language & quotes
if (langModule->defaultencodingRB->isChecked()) {
bp_.inputenc = "auto";
bp_.inputenc = "auto-legacy";
} else {
int i = langModule->encodingCO->currentIndex();
if (i == 0)
bp_.inputenc = "default";
bp_.inputenc = "auto-legacy-plain";
else {
QString const enc_gui =
langModule->encodingCO->currentText();
@ -3222,8 +3222,8 @@ void GuiDocument::applyView()
}
if (!found) {
// should not happen
lyxerr << "GuiDocument::apply: Unknown encoding! Resetting to default" << endl;
bp_.inputenc = "default";
lyxerr << "GuiDocument::apply: Unknown encoding! Resetting to utf8" << endl;
bp_.inputenc = "utf8";
}
}
}
@ -3719,9 +3719,9 @@ void GuiDocument::paramsToDialog()
langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
bool default_enc = true;
if (bp_.inputenc != "auto") {
if (bp_.inputenc != "auto-legacy") {
default_enc = false;
if (bp_.inputenc == "default") {
if (bp_.inputenc == "auto-legacy-plain") {
langModule->encodingCO->setCurrentIndex(0);
} else {
string enc_gui;
@ -4087,7 +4087,7 @@ void GuiDocument::paramsToDialog()
if (nn >= 0)
fontModule->fontsDefaultCO->setCurrentIndex(nn);
if (bp_.fontenc == "auto" || bp_.fontenc == "default") {
if (bp_.fontenc == "auto-legacy" || bp_.fontenc == "auto-legacy-plain") {
fontModule->fontencCO->setCurrentIndex(
fontModule->fontencCO->findData(toqstr(bp_.fontenc)));
fontModule->fontencLE->setEnabled(false);

View File

@ -321,8 +321,8 @@ void GuiSymbols::updateView()
chosenLE->clear();
string new_encoding = bufferview()->cursor().getEncoding()->name();
if (buffer().params().inputenc != "auto" &&
buffer().params().inputenc != "default")
if (buffer().params().inputenc != "auto-legacy" &&
buffer().params().inputenc != "auto-legacy-plain")
new_encoding = buffer().params().encoding().name();
if (new_encoding == encoding_)
// everything up to date

View File

@ -682,7 +682,7 @@ void InsetBibtex::parseBibTeXFiles(FileNameList & checkedFiles) const
if (ienc.empty() || ienc == "general")
ienc = to_ascii(params()["encoding"]);
if (!ienc.empty() && ienc != "default" && ienc != "auto" && encodings.fromLyXName(ienc))
if (!ienc.empty() && ienc != "auto-legacy-plain" && ienc != "auto-legacy" && encodings.fromLyXName(ienc))
encoding = encodings.fromLyXName(ienc)->iconvName();
ifdocstream ifs(bibfile.toFilesystemEncoding().c_str(),
ios_base::in, encoding);

View File

@ -979,10 +979,10 @@ void TeXOnePar(Buffer const & buf,
}
}
// Switch file encoding if necessary; no need to do this for "default"
// Switch file encoding if necessary; no need to do this for "auto-legacy-plain"
// encoding, since this only affects the position of the outputted
// \inputencoding command; the encoding switch will occur when necessary
if (bparams.inputenc == "auto"
if (bparams.inputenc == "auto-legacy"
&& !runparams.isFullUnicode() // Xe/LuaTeX use one document-wide encoding (see also switchEncoding())
&& runparams.encoding->package() != Encoding::japanese
&& runparams.encoding->package() != Encoding::none) {
@ -1339,11 +1339,11 @@ void TeXOnePar(Buffer const & buf,
// Information about local language is stored as a font feature.
// If this is the last paragraph of the inset and a local_font was set upon entering
// and we are mixing encodings ("auto" or "default" and no XeTeX or LuaTeX),
// and we are mixing encodings ("auto-legacy" or "auto-legacy-plain" and no XeTeX or LuaTeX),
// ensure the encoding is set back to the default encoding of the local language.
if (runparams.isLastPar && runparams_in.local_font != 0
&& runparams_in.encoding != runparams_in.local_font->language()->encoding()
&& (bparams.inputenc == "auto" || bparams.inputenc == "default")
&& (bparams.inputenc == "auto-legacy" || bparams.inputenc == "auto-legacy-plain")
&& !runparams.isFullUnicode()
) {
runparams_in.encoding = runparams_in.local_font->language()->encoding();
@ -1643,11 +1643,11 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
return make_pair(false, 0);
// Only switch for auto-selected legacy encodings (inputenc setting
// "auto" or "default").
// "auto-legacy" or "auto-legacy-plain").
// The "listings" environment can force a switch also with other
// encoding settings (it does not support variable width encodings
// (utf8, jis, ...) under 8-bit latex engines).
if (!force && ((bparams.inputenc != "auto" && bparams.inputenc != "default")
if (!force && ((bparams.inputenc != "auto-legacy" && bparams.inputenc != "auto-legacy-plain")
|| runparams.moving_arg))
return make_pair(false, 0);
@ -1668,7 +1668,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
<< oldEnc.name() << " to " << newEnc.name());
os << setEncoding(newEnc.iconvName());
if (bparams.inputenc == "default")
if (bparams.inputenc == "auto-legacy-plain")
return make_pair(true, 0);
docstring const inputenc_arg(from_ascii(newEnc.latexName()));

View File

@ -544,7 +544,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
h_html_math_output = "0";
h_index[0] = "Index";
h_index_command = "default";
h_inputencoding = "auto";
h_inputencoding = "auto-legacy";
h_justification = "true";
h_language = "english";
h_language_package = "none";
@ -735,7 +735,7 @@ void Preamble::handle_package(Parser &p, string const & name,
xetex = true;
h_use_non_tex_fonts = true;
registerAutomaticallyLoadedPackage("fontspec");
if (h_inputencoding == "auto")
if (h_inputencoding == "auto-legacy")
p.setEncoding("UTF-8");
}
@ -1102,15 +1102,15 @@ void Preamble::handle_package(Parser &p, string const & name,
h_use_non_tex_fonts = true;
xetex = true;
registerAutomaticallyLoadedPackage("xunicode");
if (h_inputencoding == "auto")
if (h_inputencoding == "auto-legacy")
p.setEncoding("UTF-8");
}
else if (name == "CJK") {
// set the encoding to "auto" because it might be set to "default" by the babel handling
// set the encoding to "auto-legacy" because it might be set to "auto-legacy-plain" by the babel handling
// and this would not be correct for CJK
if (h_inputencoding == "default")
h_inputencoding = "auto";
if (h_inputencoding == "auto-legacy-plain")
h_inputencoding = "auto-legacy";
registerAutomaticallyLoadedPackage("CJK");
}
@ -1128,7 +1128,7 @@ void Preamble::handle_package(Parser &p, string const & name,
else if (name == "inputenc" || name == "luainputenc") {
// h_inputencoding is only set when there is not more than one
// inputenc option because otherwise h_inputencoding must be
// set to "auto" (the default encoding of the document language)
// set to "auto-legacy" (the default encodings of the document's languages)
// Therefore check that exactly one option is passed to inputenc.
// It is also only set when there is not more than one babel
// language option.
@ -1572,8 +1572,8 @@ void Preamble::parse(Parser & p, string const & forceclass,
return;
while (is_full_document && p.good()) {
if (detectEncoding && h_inputencoding != "auto" &&
h_inputencoding != "default")
if (detectEncoding && h_inputencoding != "auto-legacy" &&
h_inputencoding != "auto-legacy-plain")
return;
Token const & t = p.get_token();
@ -1618,7 +1618,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
"% This document must be compiled with XeLaTeX ";
if (comment.size() > magicXeLaTeX.size()
&& comment.substr(0, magicXeLaTeX.size()) == magicXeLaTeX
&& h_inputencoding == "auto") {
&& h_inputencoding == "auto-legacy") {
if (!detectEncoding)
cerr << "XeLaTeX comment found, switching to UTF8\n";
h_inputencoding = "utf8";
@ -2439,7 +2439,7 @@ string Preamble::parseEncoding(Parser & p, string const & forceclass)
{
TeX2LyXDocClass dummy;
parse(p, forceclass, true, dummy);
if (h_inputencoding != "auto" && h_inputencoding != "default")
if (h_inputencoding != "auto-legacy" && h_inputencoding != "auto-legacy-plain")
return h_inputencoding;
return "";
}

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true
@ -19,7 +19,7 @@
\maintain_unincluded_children false
\language british
\language_package default
\inputencoding auto
\inputencoding auto-legacy
\fontencoding default
\font_roman "default" "Linux Libertine O"
\font_sans "default" "Linux Biolinum O"

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true
@ -20,7 +20,7 @@
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding auto
\inputencoding auto-legacy
\fontencoding default
\font_roman "default" "default"
\font_sans "default" "default"

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.4
\lyxformat 572
\lyxformat 573
\begin_document
\begin_header
\save_transient_properties true
@ -9,7 +9,7 @@
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding auto
\inputencoding auto-legacy
\fontencoding default
\font_roman "default" "default"
\font_sans "default" "default"

View File

@ -993,7 +993,7 @@ bool tex2lyx(FileName const & infilename, ostream & os, string encoding,
// actual encoding is different (bug 7509).
if (encoding.empty()) {
Encoding const * enc = 0;
if (preamble.inputencoding() == "auto") {
if (preamble.inputencoding() == "auto-legacy") {
ifdocstream is(setEncoding("ISO-8859-1"));
// forbid buffering on this stream
is.rdbuf()->pubsetbuf(0, 0);

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 572 // kornel: Noto fonts expanded to use more options
#define LYX_FORMAT_TEX2LYX 572
#define LYX_FORMAT_LYX 573 // gm: rename input encoding settings
#define LYX_FORMAT_TEX2LYX 573
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER