1if not modules then modules = { } end modules ['math-mps'] = {
2 version = 1.001,
3 comment = "companion to math-frc.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local tostring = tostring
10
11local takebox = tex.takebox
12
13
14
15
16local function renderextensible(target,fnt,chr,size,width,height,depth,linewidth,axis,exheight,emwidth)
17 local properties = mathematics.getextensibledata(target)
18 if properties then
19 local mp = properties.mp
20 if mp and mp ~= "" then
21 local uc = properties.unicode
22 if uc then
23 mp = string.formatters["%s:%05X"](mp,uc)
24 end
25 token.expandmacro(
26 "math_extensible_mp",
27 true,mp,
28 true,tostring(width),
29 true,tostring(height),
30 true,tostring(depth),
31 true,tostring(linewidth),
32 true,tostring(axis),
33 true,tostring(exheight),
34 true,tostring(emwidth)
35 )
36 local result = takebox("globalscratchbox")
37 nodes.setattrlist(result,target)
38 return result
39 end
40 end
41end
42
43mathematics.renderextensible = renderextensible
44
45interfaces.implement {
46 name = "set_extensible_data",
47 arguments = { {
48 { "mp" },
49 { "left", "integer" },
50 { "right", "integer" },
51 { "middle", "integer" },
52 { "unicode", "integer" },
53 } },
54 actions = mathematics.setextensibledata,
55}
56
57interfaces.implement {
58 name = "registermpextensible",
59 arguments = "integer",
60 public = true,
61 protected = true,
62 actions = function(unicode)
63 mathematics.registerextensible {
64 method = "mp",
65 action = renderextensible,
66 unicode = unicode,
67 }
68 end,
69}
70
71local status_mathfun = logs.messenger("mathfun")
72
73local patterns = {
74 "math-mps-imp-%s.mkxl",
75 "meta-mps-imp-%s.tex",
76}
77
78local function action(name,foundname)
79 commands.loadlibrary(name,foundname,false)
80 status_mathfun("library %a is loaded",name)
81end
82
83local function failure(name)
84 report_mathfun("library %a is unknown or invalid",name)
85end
86
87interfaces.implement {
88 name = "usemathpluginlibrary",
89
90 arguments = "optional",
91 public = true,
92 protected = true,
93 actions = function(name)
94 resolvers.uselibrary {
95 name = name,
96 patterns = patterns,
97 action = action,
98 failure = failure,
99 onlyonce = true,
100 }
101 end
102}
103
104 |