In this question, which I posted a few weeks ago to TeX Stack Exchange, I asked how one should go about disabling specific ligatures (such as ff
, fi
, fl
, and ffl
) automatically for a list of pre-defined words. The answer I received was based on ConTeXt, which can access lua(tex) commands directly. In particular, the code that @Aditya came up with includes the commands
\usemodule[translate]
\translateinput[halflife][half|*|life]
The ConTeXt command \usemodule
is similar to the LaTeX command \usepackage
. The \translateinput
command provided by the translate
module (which is contained in the file m-translate.mkiv
) relies on the lua
function resolvers.openers.helpers.textlineactions
, which hooks into the function that luatex
uses to read files. According to @Aditya,
no one has written similar functionality for
lualatex
. Perhaps, you could ask it as a separate question, and one of thelualatex
experts will be able to answer with a solution.
Here, then, is my question: Can someone provide the lualatex
equivalent of the following ConTeXt code (which may involve re-writing/adapting the translate
module to lualatex
):
\usemodule[translate]
\translateinput[shelfful][shelf|*|ful]
\translateinput[selfish][self|*|ish]
\translateinput[halflife][half|*|life]
\translateinput[cufflink][cuff|*|link]
\definetextmodediscretionary * {\prewordbreak\discretionary{-}{}%
{\kern0.0pt}\prewordbreak}
\starttext
Ligatures not disabled:\\
shelfful selfish halflife cufflink
\medskip
\enableinputtranslation
Ligatures disabled:\\
shelfful selfish halflife cufflink
\stoptext
(Note that while a 0-kern separator seems to be appropriate for the words shelfful and selfish typeset with CM, it's not quite adequate for the f-l
and ff-l
ligatures. However, I'll leave the question of how to define commands that allow for distinct kerning amounts for various combinations of ligated letters for a different, future question…)
Best Answer
This is more a proof-of-concept than a real bulletproof style file, but it does what you request:
The style file (
filterltx.sty
)and the test document (
test.tex
):Run with
lualatex test
.The output: