Kerning with selnolig

A major, and frankly vexing, practical issue when breaking up typographically inappropriate fl and ffl ligatures is how much whitespace (if any) should be inserted between f (or ff) and l. This issue doesn't come up when breaking up ff ligatures (cf "shelfful" and the screenshot below), and it's generally a less-vexing issue when breaking up fi (e.g., "aufisst" in German) and ffi (e.g., "Stoffisolierung") ligatures.

The "right" amount of whitespace that should be inserted between f (or ff) and l happens to depend crucially on the exact shapes of the f and ff glyphs. For some fonts, such as Palatino, Aldus, and Dante, no extra whitespace is needed at all, as these fonts' f and ff glyphs have fairly short "arms" which don't collide with the l glyph even if no whitespace is inserted. (Aside: this is probably a deliberate design feature of these fonts.) The babel package's "| method is programmed to insert 0.03em of whitespace. While this amount is OK for Computer Modern and Latin Modern, it is actually way too much for Palatino on the one hand and not enough for fonts such as EB Garamond, Caslon, Sabon, and Linux Liberine O on the other. For EB Garamond, for instance, it looks like 0.1em -- or more than three times the amount inserted with babel's "| method -- is the amount of whitespace that must be inserted if the f and l glyphs absolutely, positively must not touch each other. In my opinion, the typeset word "Verzweiflung" looks just awful if 0.1em of whitespace is inserted: One problem -- the inappropriate fl ligature -- has been replaced with a problem -- the unsightly gap inside the word -- that's nearly as bad! (Another aside: Maybe the "typographic rule" you mention, that adjacent non-ligated glyphs must not touch, has to be reconsidered.)

The real solution when breaking up fl and ffl ligatures, then, is to use variants of the glyphs f and ff that have "short" arms, i.e., arms that don't protrude (much) to the right and hence don't collide with a "tall" glyph such as l. Unfortunately, very few fonts currently offer such short-armed glyphs. I'm aware of only EB Garamond and Linux Libertine as font families that provide them. (Tediously, the "slots" where EB Garamond and Linux Libertine store their short-armed f-variants aren't the same. This makes programming up an automated use of the short-armed glyphs rather tedious and error-prone. This is also why I haven't gotten around to implement the short-f approach in the selnolig package...)

Another solution, which may or may not be available to you, is to use a font such as Palatino whose f and ff glyphs have short arms and thus don't collide with trailing l glyphs.


The following table compares the outputs of various methods for breaking up fl ligatures. Note that the "new" method used below is similar to the one David Carlisle used in his answer, except that it uses a so-called "discretionary" to continue to allow line breaks (with hyphens) to occur in the word "Verzweiflung". Note also that no whitespace has to be inserted between the 2 f glyphs in shelfful, for any of the fonts considered here.

enter image description here

\documentclass[english,ngerman]{article}
\usepackage{fontspec,babel,selnolig,booktabs,array,geometry}
\providecommand\xx{}
\newcolumntype{L}{>{\xx}l}
\newcolumntype{R}{>{\xx}r}
\setlength\tabcolsep{4pt}

\usepackage{luacode}
\begin{luacode}
function breaklig (s)
    s = s:gsub ( 'Verzweiflung' ,
        'Ver\\-zweif\\discretionary{-}{}{\\kern0.10em}lung' )
    return s
end
luatexbase.add_to_callback( 'process_input_buffer' ,
    breaklig , 'break ligatures in specified words' )
\end{luacode}

\begin{document}

\begin{tabular}{@{}lRLLLLLL@{}} 
&&    \multicolumn{2}{c}{\ttfamily selnolig}  &
      \multicolumn{1}{c}{\ttfamily babel "|}     &
      \multicolumn{1}{c}{\ttfamily "new"\ meth.} &
      \multicolumn{1}{c@{}}{\ttfamily f.short}\\
&&   \multicolumn{2}{c}{\ttfamily ("whatsit")} &
     \multicolumn{1}{c}{\ttfamily (0.03em)}  &
     \multicolumn{1}{c}{\ttfamily (0.10em)}  &
     \multicolumn{1}{c@{}}{(if available)} \\

\cmidrule(lr){3-4} \cmidrule(lr){5-5} \cmidrule(lr){6-6} \cmidrule(l){7-7}

% start with default font (Latin Modern)
\setmainfont{Latin Modern Roman}
Latin Modern
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung \\

\gdef\xx{\setmainfont{EB Garamond}[Scale=MatchLowercase]}
\xx EB Garamond
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung & 
Verzwei\symbol{983911}lung\\

\gdef\xx{\setmainfont{Adobe Caslon Pro}[Scale=MatchLowercase]}
\xx Caslon
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung \\

\gdef\xx{\setmainfont{Sabon Next LT Pro}[Scale=MatchLowercase]}
\xx Sabon
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung \\

\gdef\xx{\setmainfont{Palatino Linotype}[Scale=MatchLowercase]}
\xx Palatino
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung \\

\gdef\xx{\setmainfont{Linux Libertine O}[Scale=MatchLowercase]}
\xx Linux Lib.\ O
&ff fl & shelfful & {V}erzweiflung & Verzweif"|lung & Verzweiflung &
Verzwei\symbol{57568}\-lung\\
\end{tabular}

\bigskip
\setmainfont{EB Garamond}
Another comparison of the methods' outputs (EB Garmond only):

\begin{tabular}{@{}llll@{}}
\uselig{höflich} & \uselig{trefflich} & \uselig{aufisst} & bad!\\
höflich & trefflich & aufisst & selnolig \\
höf"|lich & treff"|lich & auf"|isst & babel \verb+"|+ \\
höf\discretionary{-}{}{\kern0.10em}lich 
& treff\discretionary{-}{}{\kern0.10em}lich 
& auf\discretionary{-}{}{\kern0.10em}isst
&  ``new'' method --- not good either \\
hö\symbol{983911}\-lich 
& tre\symbol{983904}\-lich 
& au\symbol{983911}\-isst
&  f.short \& f\_f.short --- best!
\end{tabular}
\end{document}

I don't think you would ever do this in English but in other languages with a fondness for compound words it is more of an issue.

enter image description here

\documentclass{article}

\directlua{
function breaklig (s)
return 
string.gsub(
string.gsub(
s,
'leaflet','leaf\string\\kern.5em let'),
'shelfful','shelf\string\\kern.5em ful')
end
luatexbase.add_to_callback('process_input_buffer',breaklig,'break ligatures in specified words')
}
\begin{document}


I once wrote a leaflet that (or was it a pamphlet) that had a flipped flyleaf.
Actually I have a shelfful of them.

\end{document}