[luatex] What are user-defined whatsit nodes?
Stephan Hennig
sh-list at posteo.net
Wed Nov 26 20:18:27 CET 2014
Am 24.11.2014 um 20:23 schrieb Khaled Hosny:
> The “official” Unicode was for suppressing a ligature is by inserting a
> ZWNJ character, so I guess inserting a whatsit is as close
That seems to work just as well (see attached example). But ideally,
I'd like to not do the low-level node handling myself. I'll post a
proposal of what I have in mind in a few days.
> (of course if one can get a ZWNJ to the output stream so that
> ligature suppression is maintained even when text is copied around,
> that would be even better IMO).
Doesn't look like that's happening, currently.
> BT
> /F1 9.96264 Tf 1 0 0 1 91.925 759.927 Tm [(butterflies)-333(butterflies)]TJ
> 1 0 0 1 303.509 105.18 Tm [(1)]TJ
> ET
Best regards,
Stephan Hennig
% -*- coding: utf-8 -*-
\pdfcompresslevel=0
\directlua{
% Declare constants.
local GLYPH = node.id('glyph')
local CHAR_f = string.byte('f')
local CHAR_l = string.byte('l')
local Ncopy = node.copy
local Nnew = node.new
local Ninsert_before = node.insert_before
local Ntraverse = node.traverse
% Create ZWNJ template.
local zwnj = Nnew(GLYPH)
zwnj.char = 0x200c
% Register callback.
callback.register('ligaturing',
function (head, tail)
% Iterate over node list.
for n in Ntraverse(head) do
if n.id == GLYPH and n.char == CHAR_l then
local p = n.prev
if p.id == GLYPH and p.char == CHAR_f then
local zwnjx = Ncopy(zwnj)
zwnjx.font = n.font
zwnjx.lang = n.lang
Ninsert_before(head, n, zwnjx)
end
end
end
node.ligaturing(head, tail)
end
)
}
\righthyphenmin=3
\showhyphens{butterflies}butterflies
\righthyphenmin=5
\showhyphens{butterflies}butterflies
\bye
More information about the luatex
mailing list