In the italic font I am using, the apostrophe appears too far right in its bounding box, and therefore a space between an apostrophe and a glyph appears smaller than a space between two glyphs. I adapted code from Kerning against word space in LuaTeX in order to increase this space. However, the code applies to all fonts used in the document, but I want it to apply to only the italic font. Is there a way to do this?
Current output:
Desired output:
(the spaces have been exaggerated for purposes of demonstration)
MWE:
\documentclass{article}
\usepackage{fontspec}
\directlua{
function kernspace(head)
for space in node.traverse_id(node.id('glue'), head) do
if space.subtype == 13 then
local prev = node.prev(space)
local next = node.next(space)
if prev.id == 29 and next.id == 29 then
if prev.char == 8217 then
space.width = space.width + 1000000
end
end
end
end
return true
end
luatexbase.add_to_callback("pre_linebreak_filter", kernspace, "kernspace");
}
\setmainfont{times.ttf}[
ItalicFont = timesi.ttf
]
\begin{document}
`It's time to rock 'n' roll,' he said. \par
\textit{`It's time to rock 'n' roll,' he said.}
\end{document}