# How to use a lualatex FeatureFile to adjust sidebearings in math mode?

I am trying to use Linux Libertine as a letter font (and a bit more) in math with unicode-math and luaLaTeX.

It should be good to adjust some details, and I hoped to be able to do it with a .fea file, but unfortunately it does not work entirely. Have anybody some experience of this? Test file below.

%!TEX TS-program = lualatex
% !TEX encoding = UTF-8 Unicode
\documentclass[draft,10pt]{article}
\begin{filecontents*}{libertine-math.fea}
# Script and language coverage
languagesystem DFLT dflt;
languagesystem math dflt;
languagesystem latn dflt;
feature mb01 {
substitute v by v.alt;
} mb01;
feature mb02 {
position j <200 0 200 0>;
} mb02;
\end{filecontents*}
\usepackage{libertine}
\usepackage{unicode-math} \unimathsetup{math-style=TeX}
\AtBeginDocument{
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{Linux Libertine O}
\setmathfont[range=\mathbfup/{num,latin,Latin,greek,Greek}]
{Linux Libertine O Bold}
\setmathfont[range=\mathit/{num,latin,Latin,greek,Greek}]
{Linux Libertine O Italic}
\setmathfont[range=\mathbfit/{num,latin,Latin,greek,Greek}]
{Linux Libertine O Bold Italic}
\setmathfont[range=\mathpunct]{Linux Libertine O}
\setmathfont[range=\mathrel]{Linux Libertine O}
\setmathfont[range=\mathbin]{Linux Libertine O}
\setmathfont[range=\mathop]{xits-math.otf}
\setmathfont[range=\mathdelim]{xits-math.otf}
\setmathfont[range=\mathaccent]{xits-math.otf}
}
\setmathfont{xits-math.otf}
\defaultfontfeatures[Linux Libertine O Italic]
{FeatureFile=libertine-math.fea,RawFeature=+mb01;+mb02}

\begin{document}

The letter v substitution in math mode :
\begin{itemize}
\item    italic tex mode : \textit{v}
\item      math mode : $v$
\end{itemize}

But unfortunately, I found no way to adjust the left sidebearing of j in math mode!
$(j)$
\end{document}

-
You can’t. Besides, what you want is adding italic correction not changing the side bearings unconditionally. Furthermore, italic correction is the least of your worries (you can adjust the spacing manually, but you can’t, say, adjust accent positions). You can, however, edit the Lua representation of the font directly, but that requires a bit of Lua code. –  Khaled Hosny Jul 23 '13 at 16:33
@KhaledHosny Well, in the TFM world the italic correction in a math font is related to the superscript placement. I am not sure it is still pertinent in the opentype (math) world. On the other hand, if you want to convert an italic text font towards math, you will have to increase the left side bearing of the j letter (and the same for the f letter, at least). One can see that by comparing, say zits-italic and sits-math in a fontforge window. But you are right : mixing opentype fonts in math is probably not a good way if we have quality in mind. –  Michel Bovani Jul 24 '13 at 6:18