Hi all, I think this have been reported several times before; with OpenType math fonts accents over scripted glyphs are too wide as if the accent were to be placed over the scripts as well. With a bit of investigation, it turns out that with OpenType fonts, XeTeX is choosing the accent based on the width of the box after adding the scripts to it unlike how it does with legacy fonts, so unless there is really a good reason to do that (I don't think so), it should check against the width of the box before adding the scripts. The attached patch simplifies the code a tiny bit to use the correct width, fixing this issue.
Regards, Khaled P.S. \hat and \widehat are currently identical, but this is another issue not related to this.
Index: xetex.ch
===================================================================
--- xetex.ch (revision 25425)
+++ xetex.ch (working copy)
@@ -4728,17 +4728,16 @@
@ @<Switch to a larger accent if available and appropriate@>=
@y
@ @<Switch to a larger native-font accent if available and appropriate@>=
- wa:=width(x);
c:=native_glyph(p);
a:=0;
repeat
g:=get_ot_math_variant(f, c, a, addressof(w2), 1);
- if (w2>0) and (w2<=wa) then begin
+ if (w2>0) and (w2<=w) then begin
native_glyph(p):=g;
set_native_glyph_metrics(p, 1);
incr(a);
end;
- until (w2<0) or (w2>=wa);
+ until (w2<0) or (w2>=w);
{
|if (w2<0) then begin
ot_assembly_ptr:=get_ot_assembly_ptr(f, c, 1);
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{xits-math.otf}
\begin{document}
\[
\widehat{a}
\hat{a}
\widehat{aaaaaaaaaaaaaaaaaaaaa}
\hat{aaaaaaaaaaaaaaaaaaaaa}
\]
\[
\widehat{a}^{aaaaaaaaaaaaaaaaaaaa}
\hat{a}^{aaaaaaaaaaaaaaaaaaaa}
\]
\[
\widehat{a}_{aaaaaaaaaaaaaaaaaaaa}
\]
\[
\widehat{a}_{aaaaaaaaaaaaaaaaaaaa}^{aaaaaaaaaaaaaaaaaaaa}
\]
\end{document}
before.pdf
Description: Adobe PDF document
after.pdf
Description: Adobe PDF document
-------------------------------------------------- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
