luatex-basics-prepare.tex /size: 3610 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=luatex-fonts-prepare,
3%D        version=2006.03.18,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Generate data for generic,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This file generates a few resources needed for generic font processing. This
15%D is needed because we don't want to load the (mostly not used in generic) data
16%D files.
17
18%D Indicorder is not yet filled in completely. Some 'indic=m' are now 'indic=o'
19%D due to patches/analysis by Kai Eigner.
20
21\startluacode
22
23-- dofile("t:/sources/char-ini.lua")
24-- dofile("t:/sources/char-def.lua")
25
26local chardata   = characters.data
27
28local s_init = 1    local s_rphf =  7
29local s_medi = 2    local s_half =  8
30local s_fina = 3    local s_pref =  9
31local s_isol = 4    local s_blwf = 10
32local s_mark = 5    local s_pstf = 11
33local s_rest = 6
34
35local mappers = {
36    l = s_init,  -- left
37    d = s_medi,  -- double
38    c = s_medi,  -- joiner
39    r = s_fina,  -- right
40    u = s_isol,  -- nonjoiner
41}
42
43local first_arabic,  last_arabic  = characters.blockrange("arabic")
44local first_syriac,  last_syriac  = characters.blockrange("syriac")
45local first_mandiac, last_mandiac = characters.blockrange("mandiac")
46local first_nko,     last_nko     = characters.blockrange("nko")
47
48local classifiers = { }
49local indicgroups = characters.indicgroups
50
51for k, c in next, chardata do
52    if k > 0 then
53        local c = chardata[k]
54        if c then
55            local arabic = c.arabic
56            if arabic then
57                classifiers[k] = mappers[arabic]
58            elseif k >= first_arabic  and k <= last_arabic  or k >= first_syriac  and k <= last_syriac  or
59                   k >= first_mandiac and k <= last_mandiac or k >= first_nko     and k <= last_nko     then
60                if c.category == "mn" then
61                    classifiers[k] = s_mark
62                else
63                    classifiers[k] = s_rest
64                end
65            elseif c.category == "mn" then
66                classifiers[k] = s_mark
67            end
68        end
69    end
70end
71
72local template = string.formatters [ [[
73-- automatically generated from context data (luatex-basics-prepare.tex)
74
75characters = characters or { }
76
77-- dummies
78
79characters.blockrange = { }
80
81-- classifiers needed for analysis
82
83%s
84
85%s
86
87-- done
88
89return characters.indicgroups
90]] ]
91
92io.savedata("luatex-basics-chr.lua",template(
93    table.serialize(classifiers,"characters.classifiers"),
94    table.serialize(indicgroups,"characters.indicgroups")
95))
96
97
98-- -- code for comparing patched tables (info we feed back in char-def.lua)
99
100-- local hans = table.load("t:/sources/luatex-basics-chr.lua")
101-- local kai  = table.load("e:/tmp/indic/luatex-basics-chr.lua")
102--
103-- for name, h in table.sortedhash(hans) do
104--     for kk, vv in table.sortedhash(kai[name]) do
105--         if h[kk] ~= vv and vv then
106--             local _h = h[kk]
107--             local _k = vv
108--             if type(_h) ~= "table" or type(_k) ~= "table" or not table.identical(_h,_k) then
109--                 print("what", name)
110--                 print("index",kk)
111--                 print("hex  ",string.format("%04X",kk))
112--                 print("hans ",h[kk])
113--                 print("kai  ", vv)
114--                 print("")
115--             end
116--         end
117--     end
118-- end
119
120\stopluacode
121
122
123
124\startTEXpage[offset=10pt]
125    \tttf generated file: luatex-basics-chr.lua
126\stopTEXpage
127