Using LuaLaTeX I want to make use of Feature Files / lua code in order to adjust the kerning of certain glyph pairs, see the MWEs below.

Since my kerning corrections may not be appropriate for the different styles/weights of a font, I'd like to know: Is it possible to only apply the corrections to a certain font style/weight, e.g. only to \normalfont?

MWE: Using \normalfont I want to the the glyphs "A" and "V" but not using italics.

The first version works on older versions of LuaTeX; the second is intended for newer versions, e.g. TeXLive 2016.

First version:

\documentclass[ngerman,parskip=full]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\usepackage{filecontents}
\begin{filecontents*}{mykern.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

feature kern {
  pos \A \V -100;
} kern;
\end{filecontents*}
\setmainfont[FeatureFile=mykern.fea,Ligatures=TeX]{Linux Libertine O}
\begin{document}

AV \textit{AV}

\end{document}

Second Version:

\documentclass[ngerman,parskip=full]{scrartcl}
\usepackage{fontspec}
\usepackage[ngerman]{babel}
\directlua{
fonts.handlers.otf.addfeature {
    name = "ktest",
    {
        type = "kern",
        data = {
          ["A"] = { ["V"] =  -1000 },
        }
    },
    "extra kerns"
  }
}
\setmainfont[RawFeature=+ktest,Ligatures=TeX]{Linux Libertine O}
\begin{document}

AV \textit{AV}

\end{document}
up vote 6 down vote accepted

You can use the UprightFeatures to limit the effect only to the upright fonts.

\documentclass{article}

\usepackage{fontspec}

\directlua{
fonts.handlers.otf.addfeature {
    name = "ktest",
    {
        type = "kern",
        data = {
          ["A"] = { ["V"] =  -1000 },
        }
    },
    "extra kerns"
  }
}

\setmainfont[UprightFeatures={RawFeature=+ktest},Ligatures=TeX]{Linux Libertine O}

\begin{document}

\noindent AV\par
\noindent \textit{AV}

\end{document}

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.