I'm modifying a .sty file that's used with documents that includes Latin, Arabic and Japanese text intermingled without specific markup. I am using xeCJK
to identify the Japanese text and ucharclasses
to identify the Arabic. I'm not bound to these, but I need something that switches fonts without markup in the document.
However I've noticed that the ucharclasses
package causes additional spaces around Japanese text in certain (fairly obscure) circumstances. Here's a MWE:
\documentclass{article}
\usepackage[no-math]{fontspec}
\setmainfont{Noto Serif}
\usepackage{xeCJK}
\setCJKmainfont{Noto Sans CJK JP}
%\usepackage[Latin,Arabic]{ucharclasses}
\begin{document}
``\texttt{めいじ}''
\end{document}
With the ucharclasses
line commented out I get the first line of the image below, which is what I expect; with it enabled, I get the second line, which has too much space around the hiragana characters:
The spacing is possibly consistent with xelatex trying to use a double-width monospaced quotation mark, despite it being outwith the \texttt
block, but that may be a red herring. However the problem doesn't exhibit without a \texttt
block. Obviously in the MWE I can simply drop the \texttt
as it does nothing; but in the actual documents its part of a more complex macro that I cannot readily drop.
The problem is not specific to the Noto fonts. If I use Computer Modern as the main font and Takao Mincho as the CJK main font, it still happens.
Is my usage wrong? I thought adding a CJK
option to the ucharclasses
package might fix it, but it seems to break Japanese rendering via xeCJK
entirely.