diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-08-07 08:49:07 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-08-07 08:49:07 +0200 |
commit | d81410bb506e5627d3529b1cd1467a0610d3fdae (patch) | |
tree | 4cc2d883006aaf3c1a92917a7e650eefd9d813d6 /fonttable.lua | |
parent | 0a7b11d11360cac5b20f29da6bca28cc3f5f3ffb (diff) | |
download | oldstandard-d81410bb506e5627d3529b1cd1467a0610d3fdae.tar.gz |
added font table
Diffstat (limited to 'fonttable.lua')
-rw-r--r-- | fonttable.lua | 36 |
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 | ||
2 | ft = {} | ||
3 | function 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 | ||
36 | end | ||