1if not modules then modules = { } end modules ['font-imp-math'] = {
2 version = 1.001,
3 comment = "companion to font-ini.mkiv and hand-ini.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
9if not context then return end
10
11local next, type, tonumber = next, type, tonumber
12
13local fonts = fonts
14local helpers = fonts.helpers
15local registerotffeature = fonts.handlers.otf.features.register
16
17local setmetatableindex = table.setmetatableindex
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
54local function initialize(tfmdata,value)
55 tfmdata.properties.nostackmath = value and true
56end
57
58registerotffeature {
59 name = "nostackmath",
60 description = "disable math stacking mechanism",
61 initializers = {
62 base = initialize,
63 node = initialize,
64 }
65}
66
67function fonts.helpers.mathscriptslots(tfmdata,textcode)
68 local rawdata = tfmdata.shared.rawdata
69 local rawresources = rawdata and rawdata.resources
70 local rawfeatures = rawresources and rawresources.features
71 local basesubstitutions = rawfeatures and rawfeatures.gsub
72 local sequences = basesubstitutions and tfmdata.resources.sequences
73 if sequences then
74 local characters = tfmdata.characters
75 if characters[textcode] then
76 for s=1,#sequences do
77 local sequence = sequences[s]
78 local sfeatures = sequence.features
79 if sfeatures and sfeatures.ssty then
80 local steps = sequence.steps
81 for i=1,#steps do
82 local coverage = steps[i].coverage
83 if coverage then
84 local okay = coverage[textcode]
85 if okay then
86 return okay
87 end
88 end
89 end
90 end
91 end
92 end
93 end
94end
95
96local function initialize(tfmdata,value)
97 if value then
98 local rawdata = tfmdata.shared.rawdata
99 local rawresources = rawdata and rawdata.resources
100 local mathconstants = rawresources.mathconstants
101 if mathconstants then
102 tfmdata.properties.oldmath = true
103 end
104 end
105end
106
107local specification = {
108 name = "oldmath",
109 description = "deal with fake opentype fonts",
110 initializers = {
111 base = initialize,
112 node = initialize,
113 }
114}
115
116registerotffeature(specification)
117 |