With LuaTeX, there’s a kerning
callback provided, which we can use for exactly this purpose. There is no built-in equivalent of \XeTeXinterchartoks
, but the appeal of LuaTeX is that a lot of such functionality we can implement ourselves, in Lua. We can get:

with (compile the below with lualatex
)
\documentclass{article}
\usepackage{lipsum}
\directlua{dofile('randomkern.lua')}
\begin{document}
\lipsum[1]
\end{document}
where randomkern.lua
is:
function rekern(head)
local i = head
while i~=nil do
j = i.next
-- Skip over discretionary (hyphen) nodes
while j~=nil and node.type(j.id)=='disc' do
j = j.next
end
-- Insert a kern node between successive glyph nodes
if node.type(i.id)=='glyph' and j~=nil and node.type(j.id)=='glyph' then
k = node.new(node.id('kern'))
head, i = node.insert_after(head, i, k)
assert(node.type(i.id)=='kern')
end
-- Tweak existing kerns (including ones we inserted) by a random amount
if node.type(i.id)=='kern' then
i.kern = i.kern + math.random(65536*-1, 65536*2)
end
i = i.next
end
end
luatexbase.add_to_callback('kerning', rekern, 'Introduce random kern nodes')
The idea is that the kerning
callback gets a list of nodes: for example,
temp
local_par
hlist indent {}
glyph L
glyph o
glyph r
glyph e
glyph m
glue <spaceskip: 218235 plus 109117^0 minus 72745^0>
glyph i
glyph p
disc
glyph s
glyph u
glyph m
glue <spaceskip: 218235 plus 109117^0 minus 72745^0>
glyph d
glyph o
disc
glyph l
glyph o
glyph r
glue <spaceskip: 218235 plus 109117^0 minus 72745^0>
glyph s
glyph i
glyph t
and so on. We simply traverse this list, and between every two consecutive glyph
nodes (possibly with a disc
node between them), we insert a kern
node, and give it a random value. (TeX stores all dimensions (lengths, etc.) internally in scaled points, where 65536 sp = 1 pt.)
Note that this version handles hyphenation automatically: only the kerning changes; the set of valid hyphenation or line-break points remains the same.
chickenize
– egreg Feb 6 '18 at 13:33chickenize
involves sacrificing live chickens to pagan deities by the light of the full moon. Otherwise, I cannot imagine how TeX could possibly work. – user139954 Feb 6 '18 at 19:07