3 local id_glyph = node.id('glyph')
4 local has_attr = node.has_attribute
5 local identifiers = fonts.hashes.identifiers
6 local node_next = node.next
7 local node_remove = node.remove
9 local get_node_font, get_current_font
10 if luatexja then -- test if LuaTeX-ja is loaded
11 luatexja.load_module('charrange'); local ltjc = luatexja.charrange
12 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
13 local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
14 get_node_font = function(p)
15 return (ltjc_is_ucs_in_japanese_char(p) and (has_attr(p, attr_curjfnt) or 0) or p.font)
17 get_current_font = function() return tex.attribute[attr_curjfnt] or 0 end
19 get_node_font = function(p) return p.font end
20 get_current_font = font.current
23 local function do_ivs_repr(head)
28 local pf = get_node_font(p)
29 local pt = identifiers[pf]
30 pt = pt and pt.resources; pt = pt and pt.variants
32 local q = node_next(p) -- the next node of p
33 if q and q.id==id_glyph then
35 if qc>=0xE0100 and qc<0xE01F0 then -- q is an IVS selector
36 pt = pt[qc]; pt = pt and pt[p.char]
40 head = node_remove(head,q)
50 luatexbase.add_to_callback('hpack_filter',
51 function (head) return do_ivs_repr(head) end,'do_ivs', 1)
52 luatexbase.add_to_callback('pre_linebreak_filter',
53 function (head) return do_ivs_repr(head) end, 'do_ivs', 1)
58 local ubyte = unicode.utf8.byte
59 local uchar = unicode.utf8.char
60 local sort = table.sort
61 function ivs.list_ivs(s)
63 local pt = identifiers[get_current_font()]
64 pt = pt and pt.resources; pt = pt and pt.variants
67 for i,v in pairs(pt) do
68 if v[c] then t[1+#t]=i end
71 for _,v in ipairs(t) do
72 tex.sprint('\\oalign{' .. s .. uchar(v)
73 .. '\\crcr\\hss\\tiny' .. tostring(v-0xE0100) .. '\\hss\\crcr}')