font-imp-notused.lua /size: 6036 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['font-imp-notused'] = {
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
11-- local next = next
12-- local utfbyte = utf.byte
13--
14-- local fonts              = fonts
15--
16-- local handlers           = fonts.handlers
17-- local otf                = handlers.otf
18-- local afm                = handlers.afm
19--
20-- local registerotffeature = otf.features.register
21-- local registerafmfeature = afm.features.register
22
23-- local function initialize(tfmdata)
24--     local resources    = tfmdata.resources
25--     local gposfeatures = resources.features.gpos
26--     local characters   = tfmdata.characters
27--     local descriptions = tfmdata.descriptions
28--     local sequences    = resources.sequences
29--     local coverage     = { }
30--     local units        = tfmdata.shared.rawdata.metadata.units
31--     for k, v in next, characters do
32--         local w = descriptions[k].width
33--         local d = units - w
34--         coverage[k] = { -d/2, 0, units, 0 }
35--     end
36--     local f = { dflt = { dflt = true } }
37--     local s = #sequences + 1
38--     local t = {
39--         features = { fakemono = f },
40--         flags    = { false, false, false, false },
41--         index    = s,
42--         name     = "p_s_" .. s,
43--         nofsteps = 1,
44--         order    = { "fakemono" },
45--         skiphash = false,
46--         type     = "gpos_single",
47--         steps    = {
48--             {
49--                 format   = "single",
50--                 coverage = coverage,
51--             }
52--         }
53--     }
54--     gposfeatures["fakemono"] = f
55--     sequences[s] = t
56-- end
57--
58-- registerotffeature {
59--     name         = "fakemono",
60--     description  = "fake monospaced",
61--     initializers = {
62--         node     = initialize,
63--     },
64-- }
65
66-- -- for notosans but not general
67--
68-- local v_local = interfaces and interfaces.variables and interfaces.variables["local"] or "local"
69--
70-- local function initialize(tfmdata,key,value)
71--     local characters = tfmdata.characters
72--     local parameters = tfmdata.parameters
73--     local oldchar    = 32
74--     local newchar    = 32
75--     if value == "locl" or value == v_local then
76--         newchar = fonts.handlers.otf.getsubstitution(tfmdata,oldchar,"locl",true) or oldchar
77--     elseif value == true then
78--         -- use normal space
79--     elseif value then
80--         newchar = utfbyte(value)
81--     else
82--         return
83--     end
84--     local newchar  = newchar and characters[newchar]
85--     local newspace = newchar and newchar.width
86--     if newspace > 0 then
87--         parameters.space         = newspace
88--         parameters.space_stretch = newspace/2
89--         parameters.space_shrink  = newspace/3
90--         parameters.extra_space   = parameters.space_shrink
91--     end
92-- end
93--
94-- registerotffeature {
95--     name        = 'space', -- true|false|locl|character
96--     description = 'space settings',
97--     manipulators = {
98--         base = initialize,
99--         node = initialize,
100--     }
101-- }
102
103-- -- historic stuff, move from font-ota (handled differently, typo-rep)
104--
105-- local delete_node = nodes.delete
106-- local fontdata    = fonts.hashes.identifiers
107--
108-- local nodecodes  = nodes.nodecodes
109-- local glyph_code = nodecodes.glyph
110--
111-- local strippables = allocate()
112-- fonts.strippables = strippables
113--
114-- strippables.joiners = table.tohash {
115--     0x200C, -- zwnj
116--     0x200D, -- zwj
117-- }
118--
119-- strippables.all = table.tohash {
120--     0x000AD, 0x017B4, 0x017B5, 0x0200B, 0x0200C, 0x0200D, 0x0200E, 0x0200F, 0x0202A, 0x0202B,
121--     0x0202C, 0x0202D, 0x0202E, 0x02060, 0x02061, 0x02062, 0x02063, 0x0206A, 0x0206B, 0x0206C,
122--     0x0206D, 0x0206E, 0x0206F, 0x0FEFF, 0x1D173, 0x1D174, 0x1D175, 0x1D176, 0x1D177, 0x1D178,
123--     0x1D179, 0x1D17A, 0xE0001, 0xE0020, 0xE0021, 0xE0022, 0xE0023, 0xE0024, 0xE0025, 0xE0026,
124--     0xE0027, 0xE0028, 0xE0029, 0xE002A, 0xE002B, 0xE002C, 0xE002D, 0xE002E, 0xE002F, 0xE0030,
125--     0xE0031, 0xE0032, 0xE0033, 0xE0034, 0xE0035, 0xE0036, 0xE0037, 0xE0038, 0xE0039, 0xE003A,
126--     0xE003B, 0xE003C, 0xE003D, 0xE003E, 0xE003F, 0xE0040, 0xE0041, 0xE0042, 0xE0043, 0xE0044,
127--     0xE0045, 0xE0046, 0xE0047, 0xE0048, 0xE0049, 0xE004A, 0xE004B, 0xE004C, 0xE004D, 0xE004E,
128--     0xE004F, 0xE0050, 0xE0051, 0xE0052, 0xE0053, 0xE0054, 0xE0055, 0xE0056, 0xE0057, 0xE0058,
129--     0xE0059, 0xE005A, 0xE005B, 0xE005C, 0xE005D, 0xE005E, 0xE005F, 0xE0060, 0xE0061, 0xE0062,
130--     0xE0063, 0xE0064, 0xE0065, 0xE0066, 0xE0067, 0xE0068, 0xE0069, 0xE006A, 0xE006B, 0xE006C,
131--     0xE006D, 0xE006E, 0xE006F, 0xE0070, 0xE0071, 0xE0072, 0xE0073, 0xE0074, 0xE0075, 0xE0076,
132--     0xE0077, 0xE0078, 0xE0079, 0xE007A, 0xE007B, 0xE007C, 0xE007D, 0xE007E, 0xE007F,
133-- }
134--
135-- strippables[true] = strippables.joiners
136--
137-- local function processformatters(head,font)
138--     local subset = fontdata[font].shared.features.formatters
139--     local vector = subset and strippables[subset]
140--     if vector then
141--         local current, done = head, false
142--         while current do
143--             if current.id == glyph_code and current.subtype<256 and current.font == font then
144--                 local char = current.char
145--                 if vector[char] then
146--                     head, current = delete_node(head,current)
147--                     done = true
148--                 else
149--                     current = current.next
150--                 end
151--             else
152--                 current = current.next
153--             end
154--         end
155--         return head, done
156--     else
157--         return head, false
158--     end
159-- end
160--
161-- registerotffeature {
162--     name        = "formatters",
163--     description = "hide formatting characters",
164--     methods = {
165--         base = processformatters,
166--         node = processformatters,
167--     }
168-- }
169