1if not modules then modules = { } end modules ['font-oti'] = {
2 version = 1.001,
3 comment = "companion to font-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
9local lower = string.lower
10
11local fonts = fonts
12local constructors = fonts.constructors
13
14local otf = constructors.handlers.otf
15local otffeatures = constructors.features.otf
16local registerotffeature = otffeatures.register
17
18local otftables = otf.tables or { }
19otf.tables = otftables
20
21local allocate = utilities.storage.allocate
22
23registerotffeature {
24 name = "features",
25 description = "initialization of feature handler",
26 default = true,
27}
28
29
30
31local function setmode(tfmdata,value)
32 if value then
33 tfmdata.properties.mode = lower(value)
34 end
35end
36
37otf.modeinitializer = setmode
38
39local function setlanguage(tfmdata,value)
40 if value then
41 local cleanvalue = lower(value)
42 local languages = otftables and otftables.languages
43 local properties = tfmdata.properties
44 if not languages then
45 properties.language = cleanvalue
46 elseif languages[value] then
47 properties.language = cleanvalue
48 else
49 properties.language = "dflt"
50 end
51 end
52end
53
54local function setscript(tfmdata,value)
55 if value then
56 local cleanvalue = lower(value)
57 local scripts = otftables and otftables.scripts
58 local properties = tfmdata.properties
59 if not scripts then
60 properties.script = cleanvalue
61 elseif scripts[value] then
62 properties.script = cleanvalue
63 else
64 properties.script = "dflt"
65 end
66 end
67end
68
69registerotffeature {
70 name = "mode",
71 description = "mode",
72 initializers = {
73 base = setmode,
74 node = setmode,
75 plug = setmode,
76 }
77}
78
79registerotffeature {
80 name = "language",
81 description = "language",
82 initializers = {
83 base = setlanguage,
84 node = setlanguage,
85 plug = setlanguage,
86 }
87}
88
89registerotffeature {
90 name = "script",
91 description = "script",
92 initializers = {
93 base = setscript,
94 node = setscript,
95 plug = setscript,
96 }
97}
98
99
100
101otftables.featuretypes = allocate {
102 gpos_single = "position",
103 gpos_pair = "position",
104 gpos_cursive = "position",
105 gpos_mark2base = "position",
106 gpos_mark2ligature = "position",
107 gpos_mark2mark = "position",
108 gpos_context = "position",
109 gpos_contextchain = "position",
110 gsub_single = "substitution",
111 gsub_multiple = "substitution",
112 gsub_alternate = "substitution",
113 gsub_ligature = "substitution",
114 gsub_context = "substitution",
115 gsub_contextchain = "substitution",
116 gsub_reversecontextchain = "substitution",
117 gsub_reversesub = "substitution",
118}
119
120function otffeatures.checkeddefaultscript(featuretype,autoscript,scripts)
121 if featuretype == "position" then
122 local default = scripts.dflt
123 if default then
124 if autoscript == "position" or autoscript == true then
125 return default
126 else
127 report_otf("script feature %s not applied, enable default positioning")
128 end
129 else
130
131 end
132 elseif featuretype == "substitution" then
133 local default = scripts.dflt
134 if default then
135 if autoscript == "substitution" or autoscript == true then
136 return default
137 end
138 end
139 end
140end
141
142function otffeatures.checkeddefaultlanguage(featuretype,autolanguage,languages)
143 if featuretype == "position" then
144 local default = languages.dflt
145 if default then
146 if autolanguage == "position" or autolanguage == true then
147 return default
148 else
149 report_otf("language feature %s not applied, enable default positioning")
150 end
151 else
152
153 end
154 elseif featuretype == "substitution" then
155 local default = languages.dflt
156 if default then
157 if autolanguage == "substitution" or autolanguage == true then
158 return default
159 end
160 end
161 end
162end
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263 |