[XeTeX] accent circumflex with unicode-math

Khaled Hosny khaledhosny at eglug.org
Mon Nov 22 14:43:02 CET 2010


On Mon, Nov 22, 2010 at 10:16:38AM +0000, Philipp Stephani wrote:
> ----- Ursprüngliche Mail ----
> 
> > Von: Tobias Schoel <liesdiedatei at googlemail.com>
> > An: Unicode-based TeX for Mac OS X and other platforms <xetex at tug.org>
> > Gesendet: Montag, den 22. November 2010, 7:18:19 Uhr
> > Betreff: [XeTeX] accent circumflex with unicode-math
> >
> > The accents have different width.  This might be wanted in text mode, but in 
> >math mode it looks rather  strange.
> > 
> > What's the reason for this behaviour
> 
> it is in fact inherited from original TeX: TeX always looks for horizontal 
> variants ("successors") when typesetting math accents. The font tables contain 
> lists of similar accents of increasing width. TeX traverses this list to find an 
> accent whose width is large enough to cover the base character/expression. The 
> Computer Modern fonts simply have two circumflex accents: one without successors 
> in CMR that can't grow and is used for \hat, and one with successors in CMEX 
> that is used for \widehat. If you use a Unicode Math font like Asana Math, there 
> is only one circumflex accent character because Unicode encodes characters, not 
> glyphs. That accent does have horizontal variants, so curcumflexes always grow 
> regardless whether you use \hat or \widehat (the unicode-math package even 
> defines \widehat and \hat to be equivalent).
> 
> > and how to change  it?
> 
> Currently there is no way to change this behavior. It must be fixed at the 
> engine level, i.e. the engine has to provide accent primitives that circumvent 
> the growth mechanism (similar to delimiters which use different syntax for 
> growing and non-growing versions). I've proposed a patch for LuaTeX 
> (https://github.com/phst/unimath-extras/blob/master/luatex-patches/fixed-accents.patch)
>  which is not integrated yet (but is working fine, so if you are willing to use 
> a patched development version of LuaTeX you can use it).

A bit simpler workaround that imitates TeX behaviour (unless someone is
going to write a similar patch for XeTeX too, of course) is to ask Asana
Math author to provide a modifier accents as well (Unicode has combining
accents and modifier accents, Cambria and XITS provide both with the
former having wider variants, Asana provides only combining ones) then
one can set unicode-math to use modifier accents for non growing ones:

\documentclass{minimal}

\usepackage{fontspec}
\usepackage{unicode-math}

 \setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
%\setmathfont[Scale=MatchUppercase]{Asana Math}   % shows boxes
%\setmathfont[Scale=MatchUppercase]{Cambria Math} % fine
 \setmathfont[Scale=MatchUppercase]{XITS Math}

\ExplSyntaxOn
\long\edef\hat{\Umathaccent 7 \symum_allsym "002C6\scan_stop:}
\ExplSyntaxOff

\begin{document}

\[\hat u\hat\imath\]

\end{document}

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer


More information about the XeTeX mailing list