1if not modules then modules = { } end modules ['font-imp-unicode'] = {
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 = next
12
13local fonts = fonts
14local helpers = fonts.helpers
15local constructors = fonts.constructors
16local registerotffeature = fonts.handlers.otf.features.register
17
18local extraprivates = helpers.extraprivates
19local addprivate = helpers.addprivate
20
21local tounicode = fonts.mappings.tounicode
22
23local function initialize(tfmdata)
24 for i=1,#extraprivates do
25 local e = extraprivates[i]
26 local c = e[2](tfmdata)
27 if c then
28 addprivate(tfmdata, e[1], c)
29 end
30 end
31end
32
33constructors.newfeatures.otf.register {
34 name = "extraprivates",
35 description = "extra privates",
36 default = true,
37 manipulators = {
38 base = initialize,
39 node = initialize,
40 }
41}
42
43local function initialize(tfmdata,key,value)
44 if value == "ligatures" then
45 local private = fonts.constructors and fonts.constructors.privateoffset or 0xF0000
46 local collected = fonts.handlers.otf.readers.getcomponents(tfmdata.shared.rawdata)
47 if collected and next(collected)then
48 for unicode, char in next, tfmdata.characters do
49 local u = collected[unicode]
50 if u then
51 local n = #u
52 for i=1,n do
53 if u[i] > private then
54 n = 0
55 break
56 end
57 end
58 if n > 0 then
59 if n == 1 then
60 u = u[1]
61 end
62 char.unicode = u
63 char.tounicode = tounicode(u)
64 end
65 end
66 end
67 end
68 end
69end
70
71
72
73
74
75registerotffeature {
76 name = "forceunicodes",
77 description = "forceunicodes",
78 manipulators = {
79 base = initialize,
80 node = initialize,
81 }
82}
83
84local function initialize(tfmdata,key,value)
85 if value then
86
87
88
89
90 local c = tfmdata.descriptions[0x002D]
91 if c then
92 c.tounicode = tounicode(0x002D)
93 end
94 end
95end
96
97registerotffeature {
98 name = "hardhyphen",
99 description = "hardhyphen",
100 manipulators = {
101 base = initialize,
102 node = initialize,
103 }
104}
105 |