1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
|
if not modules then modules = { } end modules ['font-enh'] = {
version = 1.001,
comment = "companion to font-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
-- This module is already stripped from old stuff but more might go away
-- in lmtx. Stay tuned.
local next = next
local trace_unicoding = false
trackers.register("fonts.defining", function(v) trace_unicoding = v end)
trackers.register("fonts.unicoding", function(v) trace_unicoding = v end)
local report_unicoding = logs.reporter("fonts","unicoding")
local fonts = fonts
local constructors = fonts.constructors
local afmfeatures = constructors.features.afm
local otffeatures = constructors.features.otf
local registerafmfeature = afmfeatures.register
local registerotffeature = otffeatures.register
local function initialize(tfmdata)
local goodies = tfmdata.goodies
local newcoding = nil
for i=1,#goodies do
local remapping = goodies[i].remapping
if remapping and remapping.unicodes then
newcoding = remapping.unicodes -- names to unicodes
end
end
if newcoding then
local characters = tfmdata.characters
local descriptions = tfmdata.descriptions
local oldcoding = tfmdata.resources.unicodes
local originals = { }
for name, newcode in next, newcoding do
local oldcode = oldcoding[name]
if characters[newcode] and not originals[newcode] then
originals[newcode] = {
character = characters [newcode],
description = descriptions[newcode],
}
end
if oldcode then
local original = originals[oldcode]
local character, description
if original then
character = original.character
description = original.description
else
character = characters [oldcode]
description = descriptions[oldcode]
end
characters [newcode] = character
descriptions[newcode] = description
character .unicode = newcode
description.unicode = newcode
else
oldcoding[name] = newcode
end
if trace_unicoding then
if oldcode then
report_unicoding("aliasing glyph %a from %U to %U",name,oldcode,newcode)
else
report_unicoding("aliasing glyph %a to %U",name,newcode)
end
end
end
end
end
local specification = {
name = "unicoding",
description = "adapt unicode table",
initializers = {
base = initialize,
node = initialize,
},
}
registerotffeature(specification)
registerafmfeature(specification)
|