I have set my main font for xeCJK to HanWangMingMedium, so that I can access old style characters. But, as a result, I no longer have access to Japanese kana: in the MWE, the katakana comes up as white space:
The default xeCJK font doesn’t create this problem, but doesn’t give me certain characters that I need (like 烝). How do I change xeCJK fonts within the body of the document, and what is the default xeCJK font called?
Possibly relevant to an answer: I’m writing about writing systems. So, I only need isolated characters. I don’t have long sections of Chinese text.
% !TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{fontspec}
\usepackage{xeCJK}
\setCJKmainfont{HanWangMingMedium}
\begin{document}
東風フォント
\end{document}
Update. Here's a hack: pretend the alternative font is the sans serif variant. But I'd still like a proper solution.
% !TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{fontspec}
\usepackage{xeCJK}
\setCJKmainfont{HanWangMingMedium}
\setCJKsansfont{AozoraMinchoRegular}
\begin{document}
東風\sf フォント.
\end{document}
Best Answer
In
babel
, you can switch between different ideographic alphabets, including Japanese and traditional Chinese:This requires XeLaTeX and
babel
3.27 or higher. (Withbabel
3.22, you must manually setScript=CJK
andScript=Kana
to work around a bug.) I substituted the Noto CJK fonts.A simpler option to Babel that doesn’t require you to write
\otherlanguage
all over the place would beucharclasses
. You could also declare a\newfontfamily
, give it the[Script = Kana, Language = Japanese]
options, and select that.Update
As of 2021, it’s possible to use multiple ideographic scripts in LuaLaTeX 1.12 or later. In theory, you can set your document up to switch between the languages without tagging. In practice, this does not reliably work for Chinese and Japanese, because the Unicode Consortium chose to use the same codepoints for Kanji and Chinese. (The original sin of Unicode was thinking they could fit everything into 16 bits.)
In this specific example, if the only Japanese we need is Hirigana and Katakana, and all ideographic characters are Chinese, we can make
babel
detect Japanese, Chinese and English correctly:Here, I set each language to a different color to make the language-switching more obvious.