summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-basics-prepare.tex
blob: 069f772f77cf25d455a39f9414424e9ac83852cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%D \module
%D   [      file=luatex-fonts-prepare,
%D        version=2006.03.18,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Generate data for generic,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This file generates a few resources needed for generic font processing. This
%D is needed because we don't want to load the (mostly not used in generic) data
%D files.

%D Indicorder is not yet filled in completely. Some 'indic=m' are now 'indic=o'
%D due to patches/analysis by Kai Eigner.

\startluacode

-- dofile("t:/sources/char-ini.lua")
-- dofile("t:/sources/char-def.lua")

local chardata   = characters.data

local s_init = 1    local s_rphf =  7
local s_medi = 2    local s_half =  8
local s_fina = 3    local s_pref =  9
local s_isol = 4    local s_blwf = 10
local s_mark = 5    local s_pstf = 11
local s_rest = 6

local mappers = {
    l = s_init,  -- left
    d = s_medi,  -- double
    c = s_medi,  -- joiner
    r = s_fina,  -- right
    u = s_isol,  -- nonjoiner
}

local first_arabic,  last_arabic  = characters.blockrange("arabic")
local first_syriac,  last_syriac  = characters.blockrange("syriac")
local first_mandiac, last_mandiac = characters.blockrange("mandiac")
local first_nko,     last_nko     = characters.blockrange("nko")

local classifiers = { }
local indicgroups = characters.indicgroups

for k, c in next, chardata do
    if k > 0 then
        local c = chardata[k]
        if c then
            local arabic = c.arabic
            if arabic then
                classifiers[k] = mappers[arabic]
            elseif k >= first_arabic  and k <= last_arabic  or k >= first_syriac  and k <= last_syriac  or
                   k >= first_mandiac and k <= last_mandiac or k >= first_nko     and k <= last_nko     then
                if c.category == "mn" then
                    classifiers[k] = s_mark
                else
                    classifiers[k] = s_rest
                end
            elseif c.category == "mn" then
                classifiers[k] = s_mark
            end
        end
    end
end

local template = string.formatters [ [[
-- automatically generated from context data (luatex-basics-prepare.tex)

characters = characters or { }

-- dummies

characters.blockrange = { }

-- classifiers needed for analysis

%s

%s

-- done

return characters.indicgroups
]] ]

io.savedata("luatex-basics-chr.lua",template(
    table.serialize(classifiers,"characters.classifiers"),
    table.serialize(indicgroups,"characters.indicgroups")
))


-- -- code for comparing patched tables (info we feed back in char-def.lua)

-- local hans = table.load("t:/sources/luatex-basics-chr.lua")
-- local kai  = table.load("e:/tmp/indic/luatex-basics-chr.lua")
--
-- for name, h in table.sortedhash(hans) do
--     for kk, vv in table.sortedhash(kai[name]) do
--         if h[kk] ~= vv and vv then
--             local _h = h[kk]
--             local _k = vv
--             if type(_h) ~= "table" or type(_k) ~= "table" or not table.identical(_h,_k) then
--                 print("what", name)
--                 print("index",kk)
--                 print("hex  ",string.format("%04X",kk))
--                 print("hans ",h[kk])
--                 print("kai  ", vv)
--                 print("")
--             end
--         end
--     end
-- end

\stopluacode



\startTEXpage[offset=10pt]
    \tttf generated file: luatex-basics-chr.lua
\stopTEXpage