[XeTeX] XeTeX, fontspec, OTF, and fontdimens

Ulrike Fischer news3 at nililand.de
Sun Feb 20 16:31:50 CET 2011


Am Sat, 19 Feb 2011 11:21:03 -0600 (CST) schrieb
mskala at ansuz.sooke.bc.ca:


 
>> If your monospaced font has stretchable word space then simply reset
>> \fontdimen3 + \fontdimen4.
> 
> Like most monospace fonts, mine doesn't have stretchable word space; but
> XeTeX assumes stretchable word space for all OTF fonts.  I'm trying to
> remove the stretchability.

>From the other posting I gathered that you use \raggedright anyway.
Does the stretchability has actually any effect?

> 
> Manually setting \fontdimen3 and \fontdimen4 seems to correctly change the
> space stretchability - and in fact is the workaround I'm using for the
> time being - but it must be repeated after every size change and so it
> breaks semantic markup.  That is the case even with no use of WordSpace in
> the document at all.

You could try the following. (I copied the code of the WordSpace
option an removed the settings for \fontdimen2.). SetStretchSpace
take one or two argument. I'm not sure that you always get something
sensible if you set them to something different then 0. 



\documentclass{article}

\usepackage{fontspec}

\ExplSyntaxOn
\makeatletter
\define at key[zf]{options}{SetStretchSpace}{
  \fontspec_update_fontid:n {+setstretchspace:#1}
  \bool_if:NF \l_fontspec_firsttime_bool {
    \_fontspec_parse_setstretchspace:w #1,,\q_stop
  }
}
\cs_set:Npn \_fontspec_parse_setstretchspace:w #1,#2,#3 \q_stop {
  \tl_if_empty:nTF {#3}
  {
    \dim_set:Nn \@tempdimb {#1\fontdimen3\zf at basefont}
    \dim_set:Nn \@tempdimc {\@tempdimb}
  }{
    \dim_set:Nn \@tempdimb {#1\fontdimen3\zf at basefont}
    \dim_set:Nn \@tempdimc {#2\fontdimen4\zf at basefont}
  }
  \tl_put_right:Nx \l_fontspec_postadjust_tl {
    \fontdimen3\font\the\@tempdimb
    \fontdimen4\font\the\@tempdimc
  }
}
\ExplSyntaxOff
\makeatother

\setmonofont[SetStretchSpace={0}]{DejaVu Sans Mono}
\begin{document}
\ttfamily
\the\fontdimen2\font,
\the\fontdimen3\font,
\the\fontdimen4\font


\large
\the\fontdimen2\font,
\the\fontdimen3\font,
\the\fontdimen4\font

\end{document}

-- 
Ulrike Fischer 



More information about the XeTeX mailing list