From 7da76b1b9fbb8f88afe13195505b4e46e0f08e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Milde?= Date: Mon, 28 Jan 2019 17:26:52 +0100 Subject: [PATCH] Load CJK support package before font selection. --- development/autotests/unreliableTests | 4 --- lib/examples/ja/multilingual.lyx | 26 -------------------- src/BufferParams.cpp | 35 +++++++++------------------ 3 files changed, 12 insertions(+), 53 deletions(-) diff --git a/development/autotests/unreliableTests b/development/autotests/unreliableTests index c5b8e6e385..189a0182c7 100644 --- a/development/autotests/unreliableTests +++ b/development/autotests/unreliableTests @@ -121,10 +121,6 @@ export/templates/acmart_pdf # the name of the day in English instead of Japanese. export/examples/ja/multilingual_lyx.* -# CJKutf8 uses $\mu$ for \textmu unless overwritten by textcomp. -# libertine loads textcomp and is loaded before CJKutf8 -export/export/latex/CJK/micro-sign_utf8-cjk_libertine.* - # No localization of auto-strings with Chinese language: export/export/latex/CJK/zh_CN-toc.* diff --git a/lib/examples/ja/multilingual.lyx b/lib/examples/ja/multilingual.lyx index 4c83cacbe8..072465d25e 100644 --- a/lib/examples/ja/multilingual.lyx +++ b/lib/examples/ja/multilingual.lyx @@ -219,32 +219,6 @@ Then, the following should work: \begin_layout Enumerate Short texts may be written without setting the language (hyphenation will be missing and spell-checking complain): Greetings; Grüße; Приветы; χαιρετισμός -\lang greek - -\begin_inset Foot -status open - -\begin_layout Plain Layout - -\lang english -CJKutf8 (4.8.4) maps the Greek letter -\lang greek -μ -\lang english - to a mathematical (italic) symbol -\begin_inset Formula $\mu$ -\end_inset - - unless the package -\family typewriter -textcomp -\family default - is loaded. -\end_layout - -\end_inset - - \end_layout \begin_layout Enumerate diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 7b2c0886a1..57c75762ed 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1745,6 +1745,17 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, os << "\\usepackage{unicode-math}\n"; } + // load CJK support package before font selection + // (see autotests/export/latex/CJK/micro-sign_utf8-cjk-libertine.lyx) + if (!useNonTeXFonts && encoding().package() != Encoding::none + && (encoding().package() == Encoding::CJK || features.mustProvide("CJK"))) { + if (encoding().iconvName() == "UTF-8" + && LaTeXFeatures::isAvailable("CJKutf8")) + os << "\\usepackage{CJKutf8}\n"; + else + os << "\\usepackage[encapsulated]{CJK}\n"; + } + // font selection must be done before loading fontenc.sty string const fonts = loadFonts(features); if (!fonts.empty()) @@ -3240,16 +3251,10 @@ void BufferParams::writeEncodingPreamble(otexstream & os, else os << "]{inputenc}\n"; } - if (package == Encoding::CJK || features.mustProvide("CJK")) { - if (language->encoding()->name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) - os << "\\usepackage{CJKutf8}\n"; - else - os << "\\usepackage{CJK}\n"; - } } else if (inputenc != "default") { switch (encoding().package()) { case Encoding::none: + case Encoding::CJK: case Encoding::japanese: break; case Encoding::inputenc: @@ -3265,22 +3270,6 @@ void BufferParams::writeEncodingPreamble(otexstream & os, else os << "]{inputenc}\n"; break; - case Encoding::CJK: - if (encoding().name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) - os << "\\usepackage{CJKutf8}\n"; - else - os << "\\usepackage{CJK}\n"; - break; - } - // Load the CJK package if needed by a secondary language. - // If the main encoding is some variant of UTF8, use CJKutf8. - if (encoding().package() != Encoding::CJK && features.mustProvide("CJK")) { - if (language->encoding()->name() == "utf8-cjk" - && LaTeXFeatures::isAvailable("CJKutf8")) - os << "\\usepackage{CJKutf8}\n"; - else - os << "\\usepackage{CJK}\n"; } } }