Edit: This question has been thoroughly reedited to highlight the problem at hand.
I am trying to mimic \overline to create similar symbols. According to Overline thickness on TeX.SX, and Appendix D in the unicode-math manual, I gathered the following information:
| | Type 1 | OpenType + LuaTeX | OpenType + XeTeX |
|------|---------------------|-------------------|------------------|
| kern | fontdim 8 fam 3 | \Umathoverbarkern | fontdim 55 fam 2 |
| rule | fontdim 8 fam 3 | \Umathoverbarrule | fontdim 54 fam 2 |
| vgap | 3 × fontdim 8 fam 3 | \Umathoverbarvgap | fontdim 53 fam 2 |
However, when I tried to implement this, I found out that the following is actually used for OpenType under XeTeX:
| | OpenType + XeTeX |
|------|----------------------|
| kern | fontdim 54 fam 2 |
| rule | fontdim 54 fam 2 |
| vgap | 3 × fontdim 54 fam 2 |
Furthermore, the above “wrong” table does not work well with Fira Math on CTAN, although this may be a font problem (see Fira Math Issue 29).
Question
Is this a XeTeX engine bug? How can I find out which font dimensions are being used? XeTeX does not seem to provide any reference manual on these subjects.
MWE
% !TeX program = LuaLaTeX % <- Everything lines up perfectly
% !TeX program = XeLaTeX % <- Not good for Fira Math
\documentclass{article}
\usepackage{unicode-math}
\setmathfont[version=L]{Latin Modern Math}
\setmathfont[version=P]{TeX Gyre Pagella Math}
\setmathfont[version=T]{TeX Gyre Termes Math}
\setmathfont[version=F]{Fira Math}
\makeatletter
\def\test@overbarkern@fontdimen{55}% Not used. XeTeX mistake?
\def\test@overbarrule@fontdimen{54}
\def\test@overbarvgap@fontdimen{53}% Not used. XeTeX mistake?
\def\test@@family{2}
\def\test@overbarkern#1{\fontdimen\test@overbarrule@fontdimen
\ifx#1\displaystyle\textfont
\else\ifx#1\textstyle\textfont
\else\ifx#1\scriptstyle\scriptfont
\else\scriptscriptfont\fi\fi\fi \test@@family}
\def\test@overbarrule#1{\fontdimen\test@overbarrule@fontdimen
\ifx#1\displaystyle\textfont
\else\ifx#1\textstyle\textfont
\else\ifx#1\scriptstyle\scriptfont
\else\scriptscriptfont\fi\fi\fi \test@@family}
\def\test@overbarvgap#1{\thr@@\fontdimen\test@overbarrule@fontdimen
\ifx#1\displaystyle\textfont
\else\ifx#1\textstyle\textfont
\else\ifx#1\scriptstyle\scriptfont
\else\scriptscriptfont\fi\fi\fi \test@@family}
\ifx\XeTeXcharclass\@undefined
% LuaTeX primitives
\global\let\test@overbarkern\Umathoverbarkern
\global\let\test@overbarrule\Umathoverbarrule
\global\let\test@overbarvgap\Umathoverbarvgap
\fi
\newcommand*\test{\mathpalette\test@stuff{xyz}}
\def\test@stuff#1#2{%
\vbox{\hrule\@height0.1\p@\hbox{$\m@th#1\overline{#2}$}}\,%
\vbox{%
\hrule\@height0.1\p@
\kern\test@overbarkern#1%
\hrule\@height\test@overbarrule#1%
\hbox{\vbox{%
\kern\test@overbarvgap#1%
\hbox{$\m@th#1#2$}%
}}%
},%
}
\newcommand*\dotest[1]{%
\begingroup
\mathversion{#1}%
$\displaystyle\test$ $\textstyle\test$ $\scriptstyle\test$ $\scriptscriptstyle\test$%
\endgroup
}
\makeatother
\begin{document}
\dotest{L}\par
\dotest{P}\par
\dotest{T}\par
\dotest{F}
\end{document}
XeLaTeX output:

With LuaLaTeX, everything lines up perfectly no matter which math font is used.
\__um_overbar_vgap:N #1yields the correct amount of vertical space across all fonts in my example. However, with XeTeX, it appears that the vertical space should be3 \__um_overbar_rule:N #1, which works for all fonts but Fira Math. This appears to be the long standing problem with XeTeX using the wrong font dimensions… – Ruixi Zhang Jan 04 '19 at 13:09