aboutsummaryrefslogtreecommitdiff
path: root/fonttable.lua
diff options
context:
space:
mode:
Diffstat (limited to 'fonttable.lua')
-rw-r--r--fonttable.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/fonttable.lua b/fonttable.lua
new file mode 100644
index 0000000..d50a314
--- /dev/null
+++ b/fonttable.lua
@@ -0,0 +1,36 @@
1-- the following is adapted from https://tex.stackexchange.com/a/380780
2ft = {}
3function ft.print_glyphs(maxCols,maxChars)
4 local id = font.current()
5 local fnt = font.getfont(id)
6 local col = 1
7 local maxU4 = 15*(16^3+16^2+16+1)
8 a = {}
9 for k, v in pairs(fnt.characters) do
10 a [#a + 1] = k
11 end
12 table.sort(a)
13 for i, k in ipairs(a) do
14 if i >= maxChars then break end
15 if col == 1 then
16 if k > maxU4 then
17 tex.sprint(string.format("U+%06x", k))
18 else
19 tex.sprint(string.format("U+%04x", k))
20 end
21 tex.sprint("&")
22 end
23 if (i) then
24 tex.sprint(string.format([[\char%i]], k))
25 else
26 tex.sprint("~")
27 end
28 if col == maxCols then
29 tex.sprint([[\\\cline{2-]] .. maxCols+1 .. "} ")
30 col = 1
31 else
32 tex.sprint("&")
33 col = col + 1
34 end
35 end
36end