In the font I'm using to set italics, the apostrophe / right single quote is outputting poorly kerned:
The kerning of the first apostrophe in 'n' and the apostrophes in they've and they're is acceptable. But elsewhere it is too close to the following character and too far from the preceding one—consider it's, isn't, the second apostrophe in 'n' and both the right single quotes.
The kerning in the roman font is fine. So, using LuaLaTeX, what is the best way to adjust the kerning for the apostrophes only for the italic font?
It may be the case that the kerning of the font is for whatever reason not being applied. For in the MWE given below, if times.ttf is changed to, say, Helvetica, and timesi.ttf is left the same, the following (much better) output is obtained:
Additionally, if I leave the font files the same but add the following code, adapted from this answer, to the preamble of the MWE:
\usepackage{luacode}
\begin{luacode*}
local function fix_italic_kern(fontdata)
if fontdata then
local chars = fontdata.characters
if chars then
local ch = chars[39] -- apostrophe
if ch then
if not ch.kerns then
ch.kerns = { }
end
ch.kerns[115] = 1 -- lowercase s
ch.kerns[116] = 1 -- lowercase t
end
end
end
end
luatexbase.add_to_callback("luaotfload.patch_font",
fix_italic_kern, "fix_italic_kern")
\end{luacode*}
I obtain nicer output for it's and isn't (though not elsewhere), despite the kern only being 1.
Here Khaled Hosny suggests to use RawFeature={+itlc}, but this has no effect.
What accounts for the inconsistency in how the italics are kerned, and how can I select the kerning that results in better output while having times.ttf as my main font?
Here is the MWE:
\documentclass{minimal}
\usepackage{fontspec}
\setmainfont{times.ttf}[
ItalicFont = timesi.ttf ,
Ligatures = Discretionary ,
]
\begin{document}
`It's time to rock 'n' roll,' he said. \par
`They've said they're coming for us. Isn't that right?' \par
\textit{`It's time to rock 'n' roll,' he said.} \par
\textit{`They've said they're coming for us. Isn't that right?'}
\end{document}
I'm using MacTeX2019 and macOS 10.14.5.






Times New Romanas the font, but not if I choose the "basic"Timessystem font. – Mico Jul 28 '19 at 05:19Timesdoesn't have adequate glyph coverage for my needs. – solisoc Jul 28 '19 at 05:42\textit{...}, but your examples show problems within\textit{...}. Unless I’ve misunderstood you, your complaint is about the kerning in this particular font, not about italic correction in luatex (which is not to say that there are no questions to be asked about italic correction in luatex). – Thérèse Jul 28 '19 at 12:18timesi.ttfchanges depending on whethertimes.ttfor e.g.Helveticais the mandatory argument of\setmainfont? And how do I achieve the kerning that is used whenHelveticais selected in place of the kerning that is used whentimes.ttfis selected? – solisoc Jul 28 '19 at 14:06minimalclass is not for minimal working examples). – Thérèse Jul 28 '19 at 14:19\setmainfont{Helvetica}[ItalicFont=timesi.ttf]? What exactly is the code that gives you the results you prefer? – Thérèse Jul 28 '19 at 14:22minimal. And yes, I have tried that: you can see the output in the second image in the OP. Basically, I want the kerning fortimesi.ttfthat obtains whenHelveticais set as the main font, as in your most recent snippet, but obviously I don't wantHelveticato actually be the main font, I want it to betimes.ttf. Sorry if I explained this poorly in the post. – solisoc Jul 28 '19 at 14:26times.ttftoHelvetica. For some reason this results in a change of the kerning oftimesi.ttf. To be clear, this new kerning is the desired kerning. However, I want to be able to achieve it withtimes.ttfset as the main font. – solisoc Jul 28 '19 at 14:34Helvetica, as explained above? Or even how to alter the bounding boxes in LuaLaTeX? – solisoc Jul 28 '19 at 14:41timesi.ttfchanges when the main font is changed betweenHelveticaandtimes.ttf—observe the difference between the first two images in the post. This is very unexpected, and I think it might be causing misunderstandings. See my replies to Thérèse. The kerning of Helvetica Italic is not relevant. – solisoc Jul 28 '19 at 14:54