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 function initialize ( tfmdata )
22 for i = 1 , # extraprivates do
23 local e = extraprivates [ i ]
24 local c = e [ 2 ] ( tfmdata )
25 if c then
26 addprivate ( tfmdata , e [ 1 ] , c )
27 end
28 end
29end
30
31constructors . newfeatures . otf . register {
32 name = " extraprivates " ,
33 description = " extra privates " ,
34 default = true ,
35 manipulators = {
36 base = initialize ,
37 node = initialize ,
38 }
39}
40
41local tounicode = fonts . mappings . tounicode
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 |