[luatex] positioning math accents over text fonts
Ulrike Fischer
luatex at nililand.de
Fri Nov 17 10:46:30 CET 2017
On tex.sx there is a question about using a special text font as
math italic and the positioning of math accents in this case.
https://tex.stackexchange.com/questions/401653/fontspec-unicode-math-mixing-fonts-math-accents
Reading the luatex manual I thought that one need a top_accent field
and value for the relevant chars and so I tried to patch a text font
to add it and got a curious results:
Adding the top_accent field seems to have no effect at all for text
fonts (Arial in my example) but it has an effect if the "text font"
is a math font (Stix Two Math).
Has someone an idea why the accent is ignoring top_accent in the
first case?
The example is a latex example but if needed I could try to convert
it to plain. I tried with the default font loader and also with a
rather new version of the generic font loader from context which I
created myself (fontloader-reference-2017-10-11.lua).
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
local patch_arial = function (fontdata)
if fontdata.psname == "ArialMT"
then
fontdata.characters[108]["top_accent"]=300380
-- fontdata.characters[108]["width"]=3300380 -- to test patch
end
end
local patch_stix = function (fontdata)
if fontdata.psname == "STIXTwoMath"
then
fontdata.characters[108]["top_accent"]=300380
end
end
luatexbase.add_to_callback
(
"luaotfload.patch_font",
patch_arial,
"change_arial"
)
luatexbase.add_to_callback
(
"luaotfload.patch_font",
patch_stix,
"change_stix"
)
\end{luacode}
\usepackage{unicode-math}
\setmainfont{STIXTwoMath} %displaces accents
%\setmainfont{Arial} %doesn't work
\setmathfont{Cambria Math}
\begin{document}
$\rm a $ %load text font in math context once for init
$\Umathaccent fixed 7 \symoperators "00302 {\rm l}$
$\hat{\rm l}$
$\Umathaccent fixed 7 \symoperators "00302 {\rm l}$
$\hat{\rm l}$
\end{document}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
More information about the luatex
mailing list