[XeTeX] Typographical question: xetex' default wordspacing (\fontdimen2--7)

Jonathan Kew jonathan_kew at sil.org
Sat Jun 24 12:22:47 CEST 2006

On 23 Jun 2006, at 11:55 pm, Toralf Senger wrote:

> Hi,
> While I was chasing the problem that XeTeX still did not produce  
> the same output as pdftex, I stumbled over fontdimes being the  
> culprit: XeTeX defines them as follows:
> \fontdimen2 (space)  =width of space <--thats fine
> \fontdimen3 (stretch)=2/3 of space   <--too much?
> \fontdimen4 (shrink) =1/3 of space   <--thats fine
> \fontdimen7 (extra spaces)= 2/3 of space  <--way to much?
> I converted some of D.E. Knuths Computer Modern Font TFMs (e.g.  
> cmr12.tfm) to readable *.pl and found, what you can also read for  
> example here http://www.delorie.com/gnu/docs/fontutils/fontu_63.html :
> \fontdimen2 (space)  =width of space
> \fontdimen3 (stretch)=1/2 of space  <---different to XeTeX
> \fontdimen4 (shrink) =1/3 of space
> \fontdimen7 (extra spaces)= 1/6 of space  <---different to XeTeX

Interesting.... I don't recall the origins of what it currently does;  
that's code that dates back to the early days of TeXGX, sometime in  
the mid-90s, I guess. The figures were probably pretty much ad-hoc  
guesswork, and as I normally use \frenchspacing with the materials I  
actually typeset, they've never really been looked at since!

I'm quite prepared to make changes here, especially as xetex has not  
promised absolute stability of results; it's still a pre-release  
"moving target". :)

However, I'm puzzled by the figures you quote. I just tried asking  
TeX to report some fontdimens, and found for example:

	This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5)
	\write18 enabled.
	entering extended mode
	fontdimen2 = 3.33333pt
	fontdimen3 = 1.66666pt
	fontdimen4 = 1.11111pt
	fontdimen7 = 1.11111pt
	CMR12 at 10pt:
	fontdimen2 = 3.26385pt
	fontdimen3 = 1.63193pt
	fontdimen4 = 1.08795pt
	fontdimen7 = 1.08795pt
	No pages of output.
	Transcript written on test1.log.

So in both cmr10 and cmr12, the extra-space value seems to be the  
same as the shrink value, at 1/3 of the space width (not 1/6, as  
suggested above).

I also looked at Times Roman as seen by xetex (non-TFM), and compared  
with existing TFMs (I don't know the origins of these, they're  
whatever is included in teTeX/gwTeX). I've annotated the values with  
the fractions of a space that they represent (approximated, in some  

	This is XeTeX, Version 3.141592-2.2-0.994a (Web2C 7.5.5)
	entering extended mode
	Times Roman at 10pt:
	fontdimen2 = 2.5pt
	fontdimen3 = 1.66666pt		2/3
	fontdimen4 = 0.83333pt		1/3
	fontdimen7 = 1.66666pt		2/3
	ptmr at 10pt:
	fontdimen2 = 2.5pt
	fontdimen3 = 1.99998pt		4/5
	fontdimen4 = 1.0pt		2/5
	fontdimen7 = 1.11pt		approx 4/9
	ptmr8r at 10pt:
	fontdimen2 = 2.5pt
	fontdimen3 = 1.49998pt		3/5
	fontdimen4 = 0.59998pt		approx 1/4
	fontdimen7 = 0.59998pt		approx 1/4
	No pages of output.
	Transcript written on test1.log.

What's interesting about this (besides the fact that xetex's extra- 
space value does look excessive!) is the considerable difference  
between the fontdimens from ptmr.tfm and ptmr8r.tfm. And neither of  
the ptmr*.tfm versions corresponds with the ratios suggested above!

So where does that leave us? Well, I've never expected xetex to  
produce the exact same line-breaks and layout as pdftex when using a  
font "natively", rather than via a TFM file; besides the spacing  
parameters, there are likely to be lig/kern differences too,  
depending on the type of font. (If it's an old Type 1 font, xetex  
doesn't currently support kerning -- maybe some day -- while if it's  
OpenType, there may be all kinds of layout features such as  
ligatures, contextual glyph variants, kerning, etc., that aren't  
necessarily present in a TFM.) You just have to think of "Times  
Roman", loaded as an OpenType font by xetex, and "ptmr" or any such  
variant, loaded as a TFM, as being two different fonts. As far as  
layout is concerned, they're entirely distinct.

However, it does look as though a change to xetex's default fontdimen  
calculations would be appropriate. At least, fontdimen 7 (extra  
space) should be made the same as fontdimen 4 (shrink); 1/3*space is  
probably a reasonable value for this. How about fontdimen 3  
(stretch).... should we reduce this from 2/3 to 1/2? This would tend  
to give more consistent spacing, but would also increase the  
likelihood of xetex reporting overfull/underfull boxes where it is  
unable to achieve a good enough paragraph layout.

I'd be interested to hear from any who have an opinion on this. Those  
with very particular requirements can, of course, adjust fontdimens  
after loading a font; but what should the default spacing behavior be  
-- the current level of stretchability, or a stricter setting that  
aims for better consistency at the cost of perhaps needing  
intervention more often?


More information about the XeTeX mailing list