summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/math-fnt.lmt
blob: a3ac1aea3f2c871858e30b1430f8b2e2c9473274 (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
if not modules then modules = { } end modules ['math-fnt'] = {
    version   = 1.001,
    comment   = "companion to math-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

local nuts       = nodes.nuts
local tonut      = nodes.tonut
local tonode     = nodes.tonode
local nodepool   = nuts.pool

local vlist_code = nodes.nodecodes.vlist

local new_hlist  = nodepool.hlist
local new_vlist  = nodepool.vlist
local new_glyph  = nodepool.glyph

local getattrlst = nuts.getattributelist
local setattrlst = nuts.setattributelist
local setwhd     = nuts.setwhd
local getwhd     = nuts.getwhd
local getid      = nuts.getid

local chardata   = fonts.hashes.characters

local function register_extensible(font,char,style,box)
    local bx = tonut(box)
    nodes.handlers.finalizelist(bx)
    local id = getid(bx)
    local al = getattrlst(bx)
    local wd, ht, dp = getwhd(bx)
    local private = fonts.helpers.setboxdirectly(font,chardata[font][char].unicode or char,box)
    local g = new_glyph(font,private)
    setattrlst(g,al)
    local n = new_hlist(g)
    setwhd(n,wd,ht,dp)
    setattrlst(n,al)
    if id == vlist_code then
        h = new_vlist(n)
        setwhd(n,wd,ht,dp)
        setattrlst(n,al)
    end
    return tonode(n)
end

experiments.register("math.extensibles", function(v)
    callback.register("register_extensible", v and register_extensible or nil)
end)