[XeTeX] New feature planned for xetex

Jonathan Kew jfkthame at gmail.com
Thu Feb 25 10:56:59 CET 2016

On 23/2/16 23:49, Bobby de Vos wrote:
> On 2016-02-19 03:31, Jonathan Kew wrote:
>> Note that the new features in xetex do not in any way enforce a
>> particular way of writing (for Urdu or anything else). The inter-word
>> spacing is primarily under the control of the font designer;
>> \XeTeXinterwordspaceshaping merely makes it possible for xetex to more
>> accurately follow what the font designer specified.
> IIRC, the Wikipedia feature Download as PDF uses some sort of TeX engine
> to create the PDFs. For such a usage (assuming XeTeX, and where the
> author of the macros used does not know the content of the text being
> typeset) would setting \XeTeXinterwordspaceshaping = 2 be recommended?
> If the font does not take advantage of \XeTeXinterwordspaceshaping,
> would then setting \XeTeXinterwordspaceshaping have no effect? That is,
> could \XeTeXinterwordspaceshaping be enabled all the time, rather than
> being enabled only if the font would make use of that setting?

Note that \XeTeXinterwordspaceshaping = 2 may have some side-effects, so 
choosing whether/when to enable it needs to be a decision for the author 
or package writer, who can decide whether the results are suitable, or 
take precautions (at the macro level) to avoid interference with other 

The main issue is that when \XeTeXinterwordspaceshaping = 2 "merges" a 
run of words and intervening spaces within a line (or hbox) into a 
single node, so as to allow opentype shaping to act across the entire 
string, it will move certain other node types -- in particular \special, 
\openout, \write, \closeout -- found within the run of text, so that 
they appear at the end of it.

This may or may not matter, depending how they're being used; in many 
cases (e.g. if \write is generating material for an index or TOC), it 
won't make any significant difference. But if \special, for example, was 
being used to change the text color, the change will in effect be 
"deferred" until the end of the line/text run. Which is probably not 
what the author wants.

As xetex has no idea what \special, for instance, is doing, it can't 
know which cases are OK to move and which really need to be preserved. 
So -- in order to provide the best text-shaping result -- it goes ahead 
and moves all these nodes (which are "invisible" to the text layout 
process, in that they have no width, etc). If, as an author or 
macro-package writer, you know that a particular \special or \write or 
whatever needs to stay in place, even at the expense of interrupting 
inter-word shaping, then adding \kern0pt before it will ensure this, 
because an explicit kern serves as an indication that the author wants 
special control of spacing at this point, overriding whatever the 
opentype font might do.


More information about the XeTeX mailing list