[XeTeX] again russian, german, english...

Jonathan Kew jonathan_kew at sil.org
Sat Feb 11 00:32:47 CET 2006


On 10 Feb 2006, at 10:36 pm, Jonathan Kew wrote:

> On 10 Feb 2006, at 2:28 pm, Martin Henning wrote:
>
>>
>> On Feb 10, 2006, at 11:12 AM, Will Robertson wrote:
>>
>>> I'm going to go out on a limb and say that babel is making things  
>>> a *lot* harder than they need to be; you should ditch it and do  
>>> the language selection with more low-level methods. (What they  
>>> are, I don't know. I do remember Jonathan complaining about  
>>> Babel's way of doing things before now, however.)
>>
>> right... the whole font encoding stuff seems to be a problem,  
>> that's why my fonts get substituted etc.

Having looked into babel.def, I think I have another solution to  
offer. Here's a hack to override Babel's font encoding ideas, and  
persuade it to leave your document in "U" encoding and the fonts you  
requested with fontspec.

In the preamble, AFTER the babel package is loaded, add the line:

	\AtBeginDocument{\renewcommand\latinencoding{U}}

Then you can use \selectlanguage{german} and \selectlanguage{english}  
(or, I assume, any other Latin-script language), and Babel will still  
use your Unicode fonts as specified with fontspec.

The main difference between this approach and the use of  
\hyphlanguage as suggested in my previous message is that  
\selectlanguage will also (I assume) change the text of labels such  
as Figure, Table, Contents, etc.

It may also change some details of punctuation and spacing  
conventions; I'm not sufficiently familiar with all the Babel options  
to know exactly what it achieves.

Anyhow, if you change your preamble to include:

% - - - - - (cut here) - - - - -
% workaround to set encoding BEFORE babel checks
\newcommand\cyrillicencoding{U}

% babel - hyphenation etc...
\usepackage[german,english,russian]{babel}

% for xetex/fontspec, override Babel's idea of latin encoding
% (this must come AFTER loading the babel package)
\AtBeginDocument{\renewcommand\latinencoding{U}}
% - - - - - (cut here) - - - - -

then you should get all three languages typeset in Charis SIL, with  
the appropriate hyphenation for each.

JK




More information about the XeTeX mailing list