1if not modules then modules = { } end modules ['luatex-font-enc'] = {
2 version = 1.001,
3 comment = "companion to luatex-*.tex",
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 context then
10 os.exit()
11end
12
13local fonts = fonts
14local encodings = { }
15fonts.encodings = encodings
16encodings.agl = { }
17encodings.known = { }
18
19encodings.glyphlistfilename = "font-age.lua"
20
21setmetatable(encodings.agl, { __index = function(t,k)
22 if k == "unicodes" then
23 logs.report("fonts","loading (extended) adobe glyph list")
24 local foundname = resolvers.findfile(encodings.glyphlistfilename) or ""
25 local unicodes = foundname ~= "" and dofile(foundname)
26 if type(unicodes) ~= "table" then
27 logs.report("fonts","missing or invalid (extended) adobe glyph list")
28
29 unicodes = { }
30 end
31 encodings.agl = { unicodes = unicodes }
32 return unicodes
33 else
34 return nil
35 end
36end })
37
38
39
40encodings.cache = containers.define("fonts", "enc", encodings.version, true)
41
42function encodings.load(filename)
43 local name = file.removesuffix(filename)
44 local data = containers.read(encodings.cache,name)
45 if data then
46 return data
47 end
48 local vector, tag, hash, unicodes = { }, "", { }, { }
49 local foundname = resolvers.findfile(filename,'enc')
50 if foundname and foundname ~= "" then
51 local ok, encoding, size = resolvers.loadbinfile(foundname)
52 if ok and encoding then
53 encoding = string.gsub(encoding,"%%(.-)\n","")
54 local unicoding = encodings.agl.unicodes
55 local tag, vec = string.match(encoding,"/(%w+)%s*%[(.*)%]%s*def")
56 local i = 0
57 for ch in string.gmatch(vec,"/([%a%d%.]+)") do
58 if ch ~= ".notdef" then
59 vector[i] = ch
60 if not hash[ch] then
61 hash[ch] = i
62 else
63
64 end
65 local u = unicoding[ch]
66 if u then
67 unicodes[u] = i
68 end
69 end
70 i = i + 1
71 end
72 end
73 end
74 local data = {
75 name = name,
76 tag = tag,
77 vector = vector,
78 hash = hash,
79 unicodes = unicodes
80 }
81 return containers.write(encodings.cache, name, data)
82end
83
84 |