Debian Codegraph @

texmf-dist/tex/luatex/blopentype/blot-base.lua

raw
1 require"gates.lua"
2
3 pitex = gates.new("pitex")
4 pitex.misc = gates.new("pitex.misc")
5
6 function pitex.log (message, ...)
7 texio.write_nl(string.format("\n" .. message .. "\n", ...))
8 end
9 function pitex.error (...)
10 tex.error ("! PiTeX error: " .. string.format(...) .. ".")
11 end
12
13 pitex.callback = gates.new("pitex.callback")
14
15 -- Creates a gate with a callback's name and put it in that callback, if not
16 -- already there. Adds the subgate(s).
17 function pitex.callback.register (c, f)
18 if pitex.callback.type(c) == 2 then
19 pitex.callback.add(f, c)
20 else
21 pitex.callback.list{c}
22 pitex.callback.add(f, c)
23 callback.register(c, pitex.callback.execute[c])
24 end
25 end
26
27 -- Latin1 to UTF-8.
28 local char = unicode.utf8.char
29 local function convert_char (ch)
30 -- return char(string.byte(ch))
31 end
32 function pitex.callback.convert (buf)
33 return string.gsub(buf,".",convert_char)
34 end
35
36 pitex.callback.register("process_input_buffer", "convert")
37
38 function remove_conversion ()
39 pitex.callback.close("convert", "process_input_buffer")
40 end
41 function restore_conversion ()
42 pitex.callback.open("convert", "process_input_buffer")
43 end
44
45 --[[
46
47 require("nodeinspector")
48 new_inspection = nodeinspector.new_inspection
49
50 local french_highmarks = {
51 string.byte("?"),
52 string.byte("!"),
53 string.byte(":"),
54 string.byte(";"),
55 }
56 local french_marks = {
57 string.byte("?"),
58 string.byte("!"),
59 string.byte(":"),
60 string.byte(";"),
61 string.byte(","),
62 string.byte("."),
63 string.byte("("),
64 string.byte("["),
65 string.byte("{"),
66 }
67
68 local function french_punctuation (head, ...)
69 for _, glue in ipairs(arg) do
70 if glue.id == 10 then
71 head = node.remove(head, glue)
72 node.free(glue)
73 end
74 end
75 local kern = node.new(11, 1)
76 kern.kern = tex.sp(".15em")
77 node.insert_after(head, arg[1], kern)
78 end
79
80 pitex.callback.french_punctuation = new_inspection(
81 french_punctuation,
82 {{id = 37, _char = french_marks}, {true, id = 37, char = french_highmarks}},
83 {{id = 10, subtype = 0}, {id = 11, subtype = 0}})
84
85 pitex.callback.register("kerning", "french_punctuation")
86 pitex.callback.original_kerning = node.kerning
87 pitex.callback.register("kerning", "original_kerning")
88 --]]