[XeTeX] Automatic font switching

David M. Jones dmj at ams.org
Mon Mar 31 19:45:38 CEST 2008


> From: Jonathan Kew <jonathan_kew at sil.org>
> Date: Sun, 30 Mar 2008 21:56:15 +0100
> Reply-To: Unicode-based TeX for Mac OS X and other platforms <xetex at tug.org>

> It's difficult to do a completely "universal" built-in solution to  
> this, because of characters (especially punctuation) that are  
> "shared" between multiple scripts, but ought to be rendered in the  
> appropriate font depending on the context where they're used.

Has anyone tried using \XeTeXcharclass 256 to make punctuation
characters invisible to the interchartoks mechanism?  I.e., modifying
the example from XeTeX-reference.ltx:

    \documentclass{article}
    
    \usepackage{color}
    
    \XeTeXinterchartokenstate = 1
    
    \XeTeXcharclass `\a 7
    \XeTeXcharclass `\A 8
    
    \XeTeXcharclass `\b 9
    \XeTeXcharclass `\B 10
    
    \XeTeXcharclass `\. 256
    
    % between "a" and "A":
    \XeTeXinterchartoks 7 8 = {\bgroup\color{red}}
    \XeTeXinterchartoks 8 7 = {\egroup}
    
    % between "a" and "B":
    \XeTeXinterchartoks 9 10 = {\bgroup\color{yellow}}
    \XeTeXinterchartoks 10 9 = {\egroup}
    
    \begin{document}
    
    aA.a bB.b
    
    \end{document}
    
This is still not completely general, but it seems like it would
handle most cases of shared punctuation between two characters with
the same character class.  Punctuation between characters with
different character classes would stick with the previous class, which
might or might not be correct.

David.


More information about the XeTeX mailing list