[XeTeX] section styling breaks with sections, intercharclasses and fontspec

Michiel Kamermans pomax at nihongoresources.com
Sat Nov 14 11:40:39 CET 2009


Hi Will,
> Write your font switches in terms of font families instead:
>
> \newfontfamily{\cjkfont}{Code2000} % pick any font with Japanese 
> support if you lack Code2000
> \newfontfamily{\rmfont}{Times New Roman}
> \setmainfont{Times New Roman} 

I tried

\documentclass{article}
\usepackage{fontspec}
\newfontfamily{\cjkfont}{Code2000}
\newfontfamily{\rmfont}{Times New Roman}
\setmainfont{Times New Roman}
\XeTeXinterchartokenstate = 1
\XeTeXinterchartoks 0 1 = {\cjkfont}
\XeTeXinterchartoks 0 2 = {\cjkfont}
\XeTeXinterchartoks 0 3 = {\cjkfont}
\XeTeXinterchartoks 255 1 = {\cjkfont}
\XeTeXinterchartoks 255 2 = {\cjkfont}
\XeTeXinterchartoks 255 3 = {\cjkfont}
\XeTeXinterchartoks 1 0 = {\rmfont}
\XeTeXinterchartoks 2 0 = {\rmfont}
\XeTeXinterchartoks 3 0 = {\rmfont}
\XeTeXinterchartoks 1 255 = {\rmfont}
\XeTeXinterchartoks 2 255 = {\rmfont}
\XeTeXinterchartoks 3 255 = {\rmfont}
\begin{document}
\section{English, then 日本語, then English} % "English, then Japanese, 
then English"
Padding text for section
\section{日本語, then English} % Japanese, then English
Padding text for section
\end{document}

Whlie this works for my real font (Kozuka Mincho Pro), when I tried it 
with Code2000 the Japanese came out as completely different glyphs 
(generating U+6436, U+657D, U+88EF instead of U+65E5, U+672C, U+8A9E) I 
assume this is a  Code2000 problem, since there's a warning "TrueType 
post table name index 32768 > 32767", but then it's odd that it does 
find the right glyphs in the earlier example.

But that aside, thank you very much for pointing out the correct syntax, 
now my sections look proper =)

- Mike


More information about the XeTeX mailing list