You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The font change (in my case to the Kaiti style) doesn't seem to be applied unless a \babelfont command (even an incorrect one) has been called beforehand. I'm not sure if this is intended or documented behavior, nor whether the issue originates from ctex... It also seems that using \selectlanguage{chinese} before instead of \foreignlanguage{chinese}{...} can sometimes result in a different, but expected, behavior, though it's difficult for me to fully understand why (several mechanisms at play).
Furthermore, if the language set with \babelfont is the document's main language, the \addfontfeatures command (with options) placed before the language/font change appears to reset the font. I believe this behavior is not intended. Also, how can font features be added in this case?
Finally, and I’m not sure if this is related, some font options (such as Color=...) seem to cause the compilation to fail. It worked with TexLive 2023…
\documentclass{book}
\usepackage[french]{babel}
\usepackage{ctex}
\usepackage{xcolor}
\babelprovide[import=zh-Hans]{chinese}
% Enable any of the 3 lines will generate good behaviour for « test »…%\babelfont[french]{rm}{EBGaramond} % … but enable this line (language same as Babel default, it could be « english ») will generate bad behaviour for one « extra test » (\addfontfeatures{…} will generate warnings and reset the font).%\babelfont[chinese]{rm}{STKaiti}%\babelfont[xx]{yy}{zz} % It works with bad values!\setCJKfamilyfont{chineserm}[AutoFakeBold=1.5]{STKaiti} % Add « Color=blue » in options will generate errors, by the way…\NewDocumentCommand\tfra { m } {\foreignlanguage{french}{#1}}
\NewDocumentCommand\tcmn { m } {{\foreignlanguage{chinese}{#1}}}
\NewDocumentCommand\tcmnbis { m } {{\CJKfamily{chineserm}#1}}
\ExplSyntaxOn\tl_put_right:cn {extraschinese} {
\RenewDocumentCommand\CJKrmdefault {} {chineserm}
}
\ExplSyntaxOff% Following hints from warnings for \addfontfeatures, without success.%\setfontfamily \chinesermfont {STKaiti} %\RenewDocumentCommand \tcmnbis { m } {{\fontspec{STKaiti}\chinesermfont\CJKfamily{chineserm}#1}} \NewDocumentCommand\showlanguage { m } {\quad\textcolor{blue}{\emph{#1}}}
\begin{document}
\chapter*{\tcmn{楷体} \showlanguage{cmn} (test)}
\section{Section \showlanguage{none}}
\section{\tfra{Section} \showlanguage{fra}}
\section{楷体 \showlanguage{none}}
\section{\tfra{楷体} \showlanguage{fra}}
\section{\tcmnbis{楷体} \showlanguage{cmnbis} (control: always Kaiti)}
\section{\tcmn{楷体} \showlanguage{cmn} (test)}
\Large
control: \tcmnbis{楷体}
test: \tcmn{楷体}
extra control (font features): {\tcmn{\addfontfeatures{}楷体}}
extra test (font features outside): {\addfontfeatures{Scale=2}\tcmn{楷体}}
extra test (font features inside): {\tcmn{\addfontfeatures{Scale=2}楷体}}
\end{document}
Some screenshots:
Test without any \babelfont
Test with a non-main-language \babelfont
Test with main-language \babelfont
The text was updated successfully, but these errors were encountered:
(Sorry for using English.)
The font change (in my case to the Kaiti style) doesn't seem to be applied unless a
\babelfont
command (even an incorrect one) has been called beforehand. I'm not sure if this is intended or documented behavior, nor whether the issue originates from ctex... It also seems that using\selectlanguage{chinese}
before instead of\foreignlanguage{chinese}
{...} can sometimes result in a different, but expected, behavior, though it's difficult for me to fully understand why (several mechanisms at play).Furthermore, if the language set with
\babelfont
is the document's main language, the\addfontfeatures
command (with options) placed before the language/font change appears to reset the font. I believe this behavior is not intended. Also, how can font features be added in this case?Finally, and I’m not sure if this is related, some font options (such as
Color=...
) seem to cause the compilation to fail. It worked with TexLive 2023…I used some advices provided in #628.
MWE
Some screenshots:
Test without any \babelfont
Test with a non-main-language \babelfont
Test with main-language \babelfont
The text was updated successfully, but these errors were encountered: