1if not modules then modules = { } end modules ['type-ini'] = {
2 version = 1.001,
3 comment = "companion to type-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 gsub = string.gsub
10local lpegmatch, P, Cs = lpeg.match, lpeg.P, lpeg.Cs
11
12
13
14local commands = commands
15local context = context
16local implement = interfaces.implement
17
18local uselibrary = resolvers.uselibrary
19
20local p_strip = Cs((P("type-") * (P("imp-")^0))^0/"" * P(1)^0)
21
22local report = logs.reporter("fonts","typescripts")
23
24local function action(name,foundname)
25 context.loadfoundtypescriptfile(name,foundname)
26end
27
28local patterns = {
29 "type-imp-%s.mkxl",
30 "type-imp-%s.mkiv",
31 "type-imp-%s.tex"
32}
33
34local function failure(name)
35 if name == "loc" then
36
37 else
38 report("unknown library %a",name)
39 end
40end
41
42implement {
43 name = "loadtypescriptfile",
44 arguments = "string",
45 actions = function(name)
46 uselibrary {
47 name = lpegmatch(p_strip,name) or name,
48 patterns = patterns,
49 action = action,
50 failure = failure,
51 onlyonce = false,
52 }
53 end
54}
55
56local patterns = {
57 "type-imp-%s.mkxl",
58 "type-imp-%s.mkiv",
59 "type-imp-%s.tex",
60
61 "type-%s.mkiv",
62 "type-%s.tex"
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
100implement {
101 name = "doprocesstypescriptfile",
102 arguments = "string",
103 actions = function(name)
104 uselibrary {
105 name = lpegmatch(p_strip,name) or name,
106 patterns = patterns,
107 action = action,
108 failure = failure,
109 onlyonce = false,
110 }
111 end
112}
113 |