[XeTeX] Problem with Japanese font

Cyril Niklaus cyril.niklaus at gmail.com
Sun Feb 10 16:14:35 CET 2008


On 10 févr. 08, at 22:01, Gerrit Sangel wrote:

> Hello,
>
> hm, maybe you have to switch the encoding of the mail to UTF-8.
No, the problem is not with my mail reader, it's with the encoding of  
the font name. It does not appear in my font menu with the Japanese  
name. But that's irrelevant to the discussion at hand.
>
>
> I select them via setromanfont because I read it in some example  
> file... but
> this bugged me all time and I did not know a better way to select a  
> font.
>
> He does not revert back to the old font if I do this with  
> \newfontfamily and
> then \mincho{日本語} or so. After I have first written \mincho, he  
> does not use
> the Fraktur font anymore.
>
> So, how is the “correct” way to change the fonts?
> Thanks
Indeed it is not the correct way to change fonts as you found out. It  
will keep using the font you asked it to use until you change it back.  
As a matter of course if you just want to insert Japanese words into  
your text I suggest you simply use curly quotes:

%%%%
   \documentclass[12pt]{article}
   \usepackage{fontspec, xltxtra, xunicode}
   \setromanfont{Baskerville}
     \newfontfamily{\japanese}{Osaka}

   \begin{document}

This is a text in Baskerville and now something comes in
in Japanese {\japanese{日本語}} and back to Baskerville.
\end{document}
%%%%%

But if you want only Japanese, you could only use \japanese without  
quotes or simply:
%%%%%%%%%%%
   \documentclass[12pt]{article}
   \usepackage{fontspec, xltxtra, xunicode}
\setmainfont{Osaka}
     \XeTeXlinebreaklocale ja
   \begin{document}
%Excerpt from <http://headlines.yahoo.co.jp/hl?a=20080116-00000993-san-soci 
 >
約半年ぶりに本場所に復帰したモンゴル出身の横綱・ 
朝青龍。相変わらずの“ダーティー・ヒーロー”ぶり 
に、モンゴルの文化や生活を紹介する兵庫県豊岡市但 
東町の「日本・モンゴル民族博物館」が困惑してい 
る。今年のメーン展示にモンゴル相撲を企画したが、 
朝青龍騒動で「イメージが悪くなる」と見送った。同 
館は「朝青龍がダーティーなイメージを払拭(ふっ 
しょく)しない限り、実現は難しい」としている。
\end{document}
%%%%%%%%%%

Reading Will Robertson's fine fontspec manual will help you too.

Cyril


More information about the XeTeX mailing list