# Automatic kerning

With the font I am using, the f touches a following closing quotation mark. I am præventing that from happening by periodically replacing all instances of f' with f\,'. Is there a better way to do this? I am already using XeTeX character classes for automatic language switching.

• One could over limited domains of text make f active to behave automatically in the way desired. But active f would break any macro invocation containing an f and possibly other things, too. If this idea is appealing, I would create \kernfON and \kernfOFF to make f active and normal, respectively. Then you could turn it on before a text block, and turn it off afterwards. If you want to see an answer to this effect, please let me know. – Steven B. Segletes Oct 15 '15 at 16:41
• @StevenB.Segletes, I think having to do this all the time would be more cumbersome than automatic replacements, which could also be done with a script together with compilation (or built into a saving command in vim). – Toothrot Oct 15 '15 at 17:30
• Are you using an OpenType font? Then you could take care of this in a feature file. – Mark van Atten Oct 15 '15 at 18:25
• Forget my comment -- you say you are using XeTeX, which does not have feature files. Is it an option for you to use LuaLaTeX? – Mark van Atten Oct 15 '15 at 18:54
• @MarkvanAtten, I don’t know anything about LuaLaTeX, and at the moment I don’t have time for big rearrangements. Anyway, this is not a huge problem, just wanted to see if anyone had a more elegant solution than mine. (I suppose I could always modify the otf with Fontforge.) – Toothrot Oct 15 '15 at 18:59

As explained in this answer you could use the XeTeX interchar classes to add custom kerning between f and '. I didn't find a font where f and ' touch, but the spacing between f and ' is fairly tight in Adobe Garamond Pro, and for a word ending in ff they do touch.

\documentclass{article}
\usepackage{fontspec}
\newXeTeXintercharclass\charclassf
\newXeTeXintercharclass\charclassprime
\XeTeXcharclass\f\charclassf
\XeTeXcharclass\'\charclassprime
\XeTeXinterchartoks\charclassf\charclassprime={\kern.15em}
\begin{document}
bluff' surf'

\XeTeXinterchartokenstate=1
bluff' surf'
\end{document}


Remark for people using Garamond: While looking for a font where the f touches the ' (and while previously search for a font where f and b touch) I found that EB Garamond has ligatures for all these combinations, which are a pain to kern by hand in other fonts. EB Garamond is great!