[luatex] ligaturing callback in horizontal mode cannot replace tail

Vianney le Clément vleclement at gmail.com
Tue May 14 12:23:30 CEST 2013


Hi all,

I want to replace three consecutive dots by an ellipsis throughout the
whole document. The ligaturing callback seems like the right place to
do this. It works fine in the general case, but fails sometimes when
the ellipsis comes at the end of a paragraph.

I have narrowed the problem down to the following problem. When trying
to replace the tail node in the ligaturing callback, LuaTeX yields the
following error.

    ! This can't happen (linebreak_tail).

This only seems to happen in horizontal mode. In restricted horizontal
mode (in an \hbox), it works fine.

At the end of the mail, you will find an example that replaces the
last glyph by a new glyph "A". If the glyph to be replaced is not the
tail node of the list or we are in restricted horizontal mode,
everything is fine. But as soon as we want to replace the tail node in
horizontal mode, the error message shows up.

Am I overlooking something or is this a LuaTeX bug?

The manual says that "After the callback, the internal value of the
'tail of the list' will be recalculated." Maybe this is not done
correctly in horizontal mode?

Kind regards,
Vianney

--
\directlua{
callback.register('ligaturing', function(head, tail)
    local s = ""
    for n in node.traverse(head) do
        if n.id == 37 then
            s = s .. " " .. unicode.utf8.char(n.char)
        else
            s = s .. " " .. n.id
        end
    end
    texio.write_nl("Ligaturing" .. s .. ".")
    while tail do
        if tail.id == 37 then
            local n = node.new(37, 1)
            n.char = unicode.utf8.byte("A")
            n.font = tail.font
            n.lang = tail.lang
            n.next = tail.next
            tail.prev.next = n
            node.free(tail)
            return
        end
        tail = tail.prev
    end
end)
}

Test % OK (tail node is a glue and is not replaced)

\hbox{Test} % OK (works in restricted hmode)

\vbox{Test} % KO (tail node is the glyph)

Test% KO (tail node is the glyph)

\bye


More information about the luatex mailing list