[XeTeX] XeTeX, fontspec, OTF, and fontdimens

mskala at ansuz.sooke.bc.ca mskala at ansuz.sooke.bc.ca
Sat Feb 19 19:57:53 CET 2011


On Sat, 19 Feb 2011, Peter Dyballa wrote:
> XeTeX (and original TeX) do not put SPACE characters into the output, i.e., if
> a SPACE glyph would exist in a font it is not used to separate words or such.

I'm well aware of that.  I explained it myself on this very list a few
days ago in answer to someone else's question about word boundary
detection in OpenType features.

However, even though XeTeX and original TeX do not send space glyphs to
the output, they still need to know how wide an interword space should be
for each font, so that they know where to put those non-space glyphs they
do send.  With an original-TeX font, whether the engine is TeX or XeTeX,
that information would be in the TFM file and loaded into fontdimens 2, 3,
and 4.  With an OTF font, it appears that XeTeX looks at the "space" glyph
in the font - even though it will not send that glyph to the output - and
puts the width of that glyph into fontdimen2.  And that's fine as far as
it goes.  The problem is that XeTeX also adds stretchability and
shrinkability to the word space, which is an inappropriate thing to do
when the font is monospace, and there doesn't seem to be a way to remove
the stretchability and shrinkability in a way that will survive the LaTeX
font-size commands.

A side issue is that it also hardcodes a puntuation space that is much
too small, in \fontdimen7 - I asked about that here last month - but that
issue is easier to work around and would probably be solved by the same
things that could solve the stretchability issue.

> Presumingly the space between two words is comprised of the right bearing of
> the right-most character of the left word + some inter-word space from TeX +
> the left bearing of the left-most character of the right word. Only this
> inter-word space is effected.

Yes, and that "some inter-word space from TeX" is, in the case of OTF
fonts with XeTeX, equal to the width of the space glyph plus a hardcoded
proportion of stretchability and shrinkability.  But it's not important
that the main size comes from the space glyph width; the issue is the
stretchability, which seems not to come from the font but to be provided
by either the engine or the fontspec package.  (I think it comes from the
engine, but couldn't find it in the source code when I looked just now.)

> Instead of exotic fonts you can use from TeX Live 2010 the GNU Freefonts in:

No, I can't.  The document in question is a type specimen, and written in
a mixture of English and Japanese.  Using a different font would defeat
the entire purpose; and it should be obvious that "use a different font!"
is not, in general, an acceptable solution to font-support problems.
Furthermore, the fonts you just named don't contain any Japanese or
Han-unified characters and therefore would be useless for my document even
if I were free to change the font.

But even if I pretend that the GNU FreeFonts are acceptable, when I try it
with the OTF version of FreeMono XeTeX still makes the interword space
stretchable after each LaTeX size command.  Do you have an installation
that does not do that - where you can use a plain LaTeX font size command
and have the interword space afterward be scaled to the new size but NOT
stretchable?  If so, I'd really like to know the version numbers and the
TeX code you're using to accomplish that.

A major goal of XeTeX is to support languages other than English -
including languages such as Japanese that are written in the Han script.
地球の人々は全部英語を読みません。Typesetting in such languages is
traditionally monospace; "don't use monospace fonts" or "accept that
spacing will be stretchable and therefore wrong when you use monospace
fonts" are not limitations XeTeX can sustain.  "You must reset the spacing
after every size change" is a workaround I can live with in the short
term, but it is not a solution.

It seems clear to me that this is a bug, though I'm not sure yet whether
it's better considered as a bug in the XeTeX engine or in the fontspec
package, because it's not clear where the stretchability is being set.
-- 
Matthew Skala
mskala at ansuz.sooke.bc.ca                 People before principles.
http://ansuz.sooke.bc.ca/


More information about the XeTeX mailing list