In babel
, you can switch between different ideographic alphabets, including Japanese and traditional Chinese:
\documentclass{standalone} % Replace with the real class.
\usepackage[english]{babel}
\usepackage{fontspec}
% A bug in Babel 3.22 requires setting the script= option to CJK and Kana,
% respectively.
\babelprovide{chinese-traditional}
\babelprovide{japanese}
\defaultfontfeatures{Scale = MatchUppercase}
\babelfont{rm}[Scale = 1.0,
Ligatures = {Common, TeX},
Language = Default
]{Latin Modern Roman}
\babelfont{sf}[Ligatures = {Common, TeX},
Language = Default]{Latin Modern Sans}
\babelfont[chinese-traditional]{rm}{NotoSerifCJKtc-Regular}
\babelfont[chinese-traditional]{sf}{NotoSansCJKtc-Regular}
\babelfont[japanese]{rm}{NotoSerifCJKjp-Regular}
\babelfont[japanese]{sf}{NotoSansCJKjp-Regular}
\begin{document}
\otherlanguage{chinese-traditional}{東風}
\otherlanguage{japanese}{フォント}
\end{document}

This requires XeLaTeX and babel
3.27 or higher. (With babel
3.22, you must manually set Script=CJK
and Script=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 be ucharclasses
. 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:
\documentclass{standalone} % Replace with the real class.
\usepackage[english]{babel}
\usepackage[svgnames, HTML]{xcolor}
\usepackage{fontspec}
% A bug in Babel 3.22 requires setting the script= option to CJK and Kana,
% respectively.
\babelprovide[import, onchar=ids fonts]{japanese}
\babelprovide[import, onchar=ids fonts]{chinese-traditional}
\defaultfontfeatures{ Scale = MatchUppercase,
Ligatures=TeX }
\babelfont{rm}
[Scale = 1.0,
Ligatures = Common,
Language = Default
]{Latin Modern Roman}
\babelfont{sf}
[Ligatures = Common,
Language = Default
]{Latin Modern Sans}
\babelfont[chinese-traditional]{rm}
[Renderer=HarfBuzz, Color=DarkGreen]{NotoSerifCJKtc-Regular}
\babelfont[chinese-traditional]{sf}
[Renderer=HarfBuzz, Color=DarkGreen]{NotoSansCJKtc-Regular}
\babelfont[japanese]{rm}
[Renderer=HarfBuzz, Color=NavyBlue]{NotoSerifCJKjp-Regular}
\babelfont[japanese]{sf}
[Renderer=HarfBuzz, Color=NavyBlue]{NotoSansCJKjp-Regular}
\begin{document}
東風
\textsf{フォント}
\end{document}

Here, I set each language to a different color to make the language-switching more obvious.
\sf
is obsolete and will clobber other font settings\sffamily
or\textsf
are preferable. (You would be better off defining a\newfontfamily
or command with a name like\jp
even if you did need a hack like this.)