mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
CJK package is never used with non-TeX fonts.
Prepare for languages that use CJK with TeX fonts and Polyglossia with non-TeX fonts. Korean is already supported by Polyglossia, LyX support will follow (file version change).
This commit is contained in:
parent
45c5b39692
commit
c83765163f
@ -526,7 +526,8 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
|
||||
|
||||
if (closeLanguage
|
||||
&& language() != base.language() && language() != next.language()
|
||||
&& language()->encoding()->package() != Encoding::CJK) {
|
||||
&& (language()->encoding()->package() != Encoding::CJK
|
||||
|| bparams.useNonTeXFonts)) {
|
||||
os << '}';
|
||||
++count;
|
||||
bool const using_begin_end =
|
||||
|
@ -2542,23 +2542,17 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
open_font = false;
|
||||
}
|
||||
|
||||
string const running_lang = runparams.use_polyglossia ?
|
||||
running_font.language()->polyglossia() : running_font.language()->babel();
|
||||
// close babel's font environment before opening CJK.
|
||||
string const lang_end_command = runparams.use_polyglossia ?
|
||||
"\\end{$$lang}" : lyxrc.language_command_end;
|
||||
bool const using_begin_end = runparams.use_polyglossia ||
|
||||
!lang_end_command.empty();
|
||||
if (!running_lang.empty() &&
|
||||
(!using_begin_end || running_lang == openLanguageName()) &&
|
||||
current_font.language()->encoding()->package() == Encoding::CJK) {
|
||||
string end_tag = subst(lang_end_command,
|
||||
"$$lang",
|
||||
running_lang);
|
||||
os << from_ascii(end_tag);
|
||||
column += end_tag.length();
|
||||
if (using_begin_end)
|
||||
popLanguageName();
|
||||
// if necessary, close language environment before opening CJK
|
||||
string const running_lang = running_font.language()->babel();
|
||||
string const lang_end_command = lyxrc.language_command_end;
|
||||
if (!lang_end_command.empty() && !bparams.useNonTeXFonts
|
||||
&& !running_lang.empty()
|
||||
&& running_lang == openLanguageName()
|
||||
&& current_font.language()->encoding()->package() == Encoding::CJK) {
|
||||
string end_tag = subst(lang_end_command, "$$lang", running_lang);
|
||||
os << from_ascii(end_tag);
|
||||
column += end_tag.length();
|
||||
popLanguageName();
|
||||
}
|
||||
|
||||
// Switch file encoding if necessary (and allowed)
|
||||
@ -2706,7 +2700,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
}
|
||||
}
|
||||
try {
|
||||
d->latexSpecialChar(os, bparams, rp, running_font,
|
||||
d->latexSpecialChar(os, bparams, rp, running_font,
|
||||
alien_script, style, i, end_pos, column);
|
||||
} catch (EncodingException & e) {
|
||||
if (runparams.dryrun) {
|
||||
@ -2740,7 +2734,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
if (!alien_script.empty()) {
|
||||
os << "}";
|
||||
alien_script.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// If we have an open font definition, we have to close it
|
||||
if (open_font) {
|
||||
|
@ -959,10 +959,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
langModule->languageCO->setModel(language_model);
|
||||
langModule->languageCO->setModelColumn(0);
|
||||
|
||||
langModule->encodingCO->addItem(qt_("Unicode (utf8) [default]"), toqstr("utf8"));
|
||||
langModule->encodingCO->addItem(qt_("Unicode (utf8)"), toqstr("utf8"));
|
||||
langModule->encodingCO->addItem(qt_("Traditional (auto-selected)"),
|
||||
toqstr("auto-legacy"));
|
||||
langModule->encodingCO->addItem(qt_("ASCII"), toqstr("ascii"));
|
||||
// langModule->encodingCO->addItem(qt_("ASCII"), toqstr("ascii"));
|
||||
langModule->encodingCO->addItem(qt_("Custom"), toqstr("custom"));
|
||||
|
||||
QMap<QString,QString> encodingmap;
|
||||
@ -2190,7 +2190,8 @@ void GuiDocument::languageChanged(int i)
|
||||
// some languages only work with Polyglossia
|
||||
Language const * lang = lyx::languages.getLanguage(
|
||||
fromqstr(langModule->languageCO->itemData(i).toString()));
|
||||
if (lang->babel().empty() && !lang->polyglossia().empty()) {
|
||||
if (lang->babel().empty() && !lang->polyglossia().empty()
|
||||
&& lang->requires() != "CJK" && lang->requires() != "japanese") {
|
||||
// If we force to switch fontspec on, store
|
||||
// current state (#8717)
|
||||
if (fontModule->osFontsCB->isEnabled())
|
||||
@ -4031,7 +4032,8 @@ void GuiDocument::paramsToDialog()
|
||||
fromqstr(langModule->languageCO->itemData(
|
||||
langModule->languageCO->currentIndex()).toString()));
|
||||
bool const need_fontspec =
|
||||
lang->babel().empty() && !lang->polyglossia().empty();
|
||||
lang->babel().empty() && !lang->polyglossia().empty()
|
||||
&& lang->requires() != "CJK" && lang->requires() != "japanese";
|
||||
bool const os_fonts_available =
|
||||
bp_.baseClass()->outputType() == lyx::LATEX
|
||||
&& LaTeXFeatures::isAvailable("fontspec");
|
||||
|
@ -307,7 +307,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
|
||||
data.cjk_nested = false;
|
||||
if (!bparams.useNonTeXFonts
|
||||
&& (bparams.inputenc == "auto-legacy"
|
||||
|| bparams.inputenc == "auto-legacy-plain")
|
||||
|| bparams.inputenc == "auto-legacy-plain")
|
||||
&& data.par_language->encoding()->package() == Encoding::CJK
|
||||
&& state->open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
|
||||
if (prev_par_language->encoding()->package() == Encoding::CJK) {
|
||||
@ -967,7 +967,9 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << "\\L{";
|
||||
}
|
||||
// With CJK, the CJK tag has to be closed first (see below)
|
||||
if ((runparams.encoding->package() != Encoding::CJK || runparams.for_search)
|
||||
if ((runparams.encoding->package() != Encoding::CJK
|
||||
|| bparams.useNonTeXFonts
|
||||
|| runparams.for_search)
|
||||
&& (par_lang != openLanguageName(state) || localswitch)
|
||||
&& !par_lang.empty()) {
|
||||
string bc = use_polyglossia ?
|
||||
@ -1202,7 +1204,9 @@ void TeXOnePar(Buffer const & buf,
|
||||
os << '\n';
|
||||
|
||||
// when the paragraph uses CJK, the language has to be closed earlier
|
||||
if ((font.language()->encoding()->package() != Encoding::CJK) || runparams_in.for_search) {
|
||||
if ((font.language()->encoding()->package() != Encoding::CJK)
|
||||
|| bparams.useNonTeXFonts
|
||||
|| runparams_in.for_search) {
|
||||
if (lang_end_command.empty()) {
|
||||
// If this is a child, we should restore the
|
||||
// master language after the last paragraph.
|
||||
@ -1294,11 +1298,11 @@ void TeXOnePar(Buffer const & buf,
|
||||
|
||||
// if this is a CJK-paragraph and the next isn't, close CJK
|
||||
// also if the next paragraph is a multilingual environment (because of nesting)
|
||||
if (nextpar
|
||||
&& (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8"
|
||||
&& bparams.encoding().package() != Encoding::CJK )
|
||||
if (nextpar && state->open_encoding_ == CJK
|
||||
&& bparams.encoding().iconvName() != "UTF-8"
|
||||
&& bparams.encoding().package() != Encoding::CJK
|
||||
&& (nextpar_language->encoding()->package() != Encoding::CJK
|
||||
|| (nextpar->layout().isEnvironment() && nextpar->isMultiLingual(bparams)))
|
||||
|| (nextpar->layout().isEnvironment() && nextpar->isMultiLingual(bparams)))
|
||||
// inbetween environments, CJK has to be closed later (nesting!)
|
||||
&& (!style.isEnvironment() || !nextpar->layout().isEnvironment())) {
|
||||
os << "\\end{CJK}\n";
|
||||
@ -1572,6 +1576,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
finishEnvironment(os, runparams, data);
|
||||
}
|
||||
|
||||
// FIXME: uncomment the content or remove this block
|
||||
if (pit == runparams.par_end) {
|
||||
// Make sure that the last paragraph is
|
||||
// correctly terminated (because TeXOnePar does
|
||||
|
Loading…
Reference in New Issue
Block a user