# Fix for CJK punctuation kerning in xetex?

When using xelatex with xeCJK to typeset a document in English with Japanese quotations, I get rather unsightly kerning with Japanese punctuation. In general, punctuation is shifted to the left, so that a left bracket 「 is extremely close to the previous character, and a right bracket 」 is extremely far from the next character. Another example is ・ which should be seen in the following example as very clearly not centered.

\documentclass{article}
\usepackage{fontspec,xeCJK}

\setmainfont{Garamond Premier Pro}
\setCJKmainfont[Scale=0.9,ItalicFont=*]{Hiragino Mincho Pro}

\begin{document}

Some text in English and あ・あ and again English;
now we write あ「あ」あ then end.

すべての人間は、生れながらにして自由であり、かつ、尊厳と権利とについて平等である。

\end{document}


Removing \XeTeXlinebreaklocale "en" solves the problem (though it would be nice to have the option to have full-width punctuation), but that is apparently needed to force line breaks in Japanese text.

This is a problem that I have encountered for a long time now, but I don't believe I had ever actually found a solution for. Interestingly, using a Japanese font as the main font for the document (without xeCJK) does not result in this, but this is not ideal.

At least on my system (Mac 10.8 with TexLive 2012 64bit), does not appear limited to Adobe fonts. Is this a font-related issue, or something with the system implementation?

-

I also sugguest our xeCJK package for XeTeX, or you can use luatexja package for LuaLaTeX, if you need. luatexja is developed by a Japanese group. Besides our xeCJK, there're also solutions by native Japanese. For example, ZXjatype package by 八登崇之 (Takayuki YATO), which is based on xeCJK. If you're a native Japanese, you may be interested in these solutions.

To explain more about the bad kerning without xeCJK: This is because the different typesetting rules, the CJK font design and the font support. For western typesetting, there is a space after every word (including the punctuation), but Chinese and Japanese do not use spaces. However, TeX's line breaking and kerning algorithms (\sfcode for example) are for western language typesetting, that's the problem.

To solve the problem, one may change the algorithms of TeX in bottom layers, via LuaTeX's callbacks (some Korean projects did this); or one may use macros like CJK, CJKpunct and xeCJK do.

-
I did not know about zxjatype and I will have to look into it further, but it gives many errors. I believe you work on xeCJK. Do you have any idea why it would produce this strange kerning (i.imgur.com/t3t2h.png) on my system and not on another? My install of MacTex 2012 is clean of outside packages. –  afb Oct 26 '12 at 7:26
I see. Well then the question is how can I get xeCJK to work correctly, as presumably the intended behavior is to correct for this. Since there appears to be some confusion, I have edited the original post to show the code that produces the output in the attached image. –  afb Oct 27 '12 at 11:23
@afb: I'm sorry but I don't have Hiragino Mincho Pro font. With all Japanese fonts on my computer, there's no kerning problem. I can't reproduce the problem and maybe you need try to change another Japanese font? BTW, make sure you're using latest version of the packages (xeCJK, fontspec, l3kernel, l3packages). –  Leo Liu Oct 27 '12 at 13:46
Yes, changing the Japanese font fixed this. I had tried many Roman fonts thinking that might solve it, but not the Japanese fonts, especially since the post by egreg showed correct kerning with Hiragino. –  afb Oct 28 '12 at 3:13
I find it hard to believe since TexLive 2010 I had seen this problem, but actually, updating with tlmgr solved this! I had just installed TexLive 2012 and the possibility that an update would fix this did not occur to me. –  afb Oct 28 '12 at 3:16

I'd use xeCJK:

\documentclass{article}
\usepackage{fontspec,xeCJK}

\setmainfont{Linux Libertine O}
\setCJKmainfont[Scale=0.9,ItalicFont=*]{Hiragino Mincho Pro}

\begin{document}

Some text in English and あ・あ and again English;
now we write あ「あ」あ then end.

すべての人間は、生れながらにして自由であり、かつ、尊厳と権利とについて平等である。

\end{document}


There doesn't seem to be necessary any usage of \XeTeXlinebreaklocale.

-
Thanks, unfortunately, as I wrote xeCJK has the same problem if \XeTeXlinebreaklocale "en" is used, which is needed (as far as I understand) to line break CJK text. –  afb Oct 24 '12 at 10:56
@afb To the contrary, the documentation of xeCJK seems to say that \XeTeXlinebreaklocale is not necessary. I've found a Japanese text in another answer and added it. –  egreg Oct 24 '12 at 12:32
I don't know what to say. With your example changing only the main font, I get the kerning error, yet it appears that now line breaking works. I am not sure what it is exactly that breaks that. Now I am using TexLive 2012, and there is no other version of xeCJK installed. i.imgur.com/t3t2h.png (and I can't seem to figure out how to get the image to display inline) –  afb Oct 24 '12 at 14:08
@afb Sorry, but I don't own Garamond Premiere Pro. Moreover, I get no bad kerning even if using \XeTeXlinebreaklocale "en" –  egreg Oct 24 '12 at 14:37
I have tried a variety of other fonts, all to the same effect. I do not have linux fonts, but I get the sense that there is something else at play here ... –  afb Oct 25 '12 at 1:08