[XeTeX] XeTeX, fontspec, OTF, and fontdimens

mskala at ansuz.sooke.bc.ca mskala at ansuz.sooke.bc.ca
Sun Feb 27 15:26:42 CET 2011


On Sun, 27 Feb 2011, Will Robertson wrote:
> The code here is

>  \tl_put_right:Nx \l_fontspec_postadjust_tl {

My copy of fontspec.sty actually has a \tl_set:Nx instead of \tl_put_right
at this point.

> So it seems like I should be writing something more like
>
>  \tl_put_right:Nn \l_fontspec_postadjust_tl {
>    \fontdimen2\font=#1\fontdimen2\font
>    \fontdimen3\font=#2\fontdimen3\font
>    \fontdimen4\font=#3\fontdimen4\font
>  }

If I edit the fontspec.sty file to include the above definition instead of
the existing one, then inter-word spaces scale correctly.  Inter-sentence
spaces don't.  Ideally there would be similar code addressing \fontdimen7
in relation to the PunctuationSpace option.

To avoid a multiplication of threads I'll respond to your other message
here too:

> Could we measure the width of an "i" and an "m", and if they're the same
> we'd be 99% sure it's a monospace font? If there are fontdimen features that
> could be set more appropriately for such cases, I'd be happy to add an
> automatic feature for this.

That has obvious problems (in particular, what about a font that isn't
designed for the Latin script and doesn't have "i" or "m"?) but it's
probably the best that can be done.  As has been discussed elsewhere in
this thread, OTF files do include a flag saying whether the font is
monospace, but that flag's value may not really be the right thing to look
at.  I'm not sure that fontspec would have any way of checking the flag
value.  It also appears that it's only supposed to be turned on when the
font has absolutely no variation in glyph width, whereas some "monospace"
fonts actually have glyphs of different widths; and the monospace flag may
also be turned on incorrectly even on some non-monospace fonts.  As long
as it's easy for the user to override the auto-detected setting, I think
the "i"/"m" comparison is a reasonable way to set the default.

One little gotcha:  the current WordSpace option syntax accepts
multipliers to be applied to the defaults.  If fontspec for whatever
reason defaulted to zero - which I think it should, in the case of
stretchability for a monospace font - then it's not clear how the user
could override that and make the spaces stretchable after all, should they
want to.  Any multiplier they entered would just be multiplied by zero; it
needs some other semantics.  My suggestion would be to make the multiplier
be a multiple of the default \fontdimen2, which would presumably never be
zero, rather than a multiple of the default for that particular setting.

Don't forget to include the inter-sentence extra space among things
affected by monospace; as I mentioned elsewhere on the thread, people
argue about whether the inter-sentence space (word space plus extra)
should be one word space (no extra) or two word spaces (one word space
plus one extra) in a monospace setting, but I think everybody who cares
agrees that the current default of one word space plus 1/3 word space,
which might be appropriate for propotional spacing, isn't appropriate for
monospace.
-- 
Matthew Skala
mskala at ansuz.sooke.bc.ca                 People before principles.
http://ansuz.sooke.bc.ca/


More information about the XeTeX mailing list