diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2016-07-14 07:36:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-14 07:36:01 +0200 |
commit | 8bb332a20022d100dcbd64fc416a35673a0ba879 (patch) | |
tree | f972c96ccf326053729544d32fda11fc14de2115 /src/fontloader/misc/fontloader-fonts-enc.lua | |
parent | 2b26f1507fb78927be50bea4ff5b13c5d897cc53 (diff) | |
parent | 6ae6f2dec61a216b584e59b6953f0576f51c3902 (diff) | |
download | luaotfload-8bb332a20022d100dcbd64fc416a35673a0ba879.tar.gz |
Merge pull request #369 from phi-gamma/master
New TFM code
Diffstat (limited to 'src/fontloader/misc/fontloader-fonts-enc.lua')
-rw-r--r-- | src/fontloader/misc/fontloader-fonts-enc.lua | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/src/fontloader/misc/fontloader-fonts-enc.lua b/src/fontloader/misc/fontloader-fonts-enc.lua index 2e1c6a4..c076d59 100644 --- a/src/fontloader/misc/fontloader-fonts-enc.lua +++ b/src/fontloader/misc/fontloader-fonts-enc.lua @@ -11,19 +11,66 @@ if context then os.exit() end -local fonts = fonts -fonts.encodings = { } -fonts.encodings.agl = { } -fonts.encodings.known = { } +local fonts = fonts +local encodings = { } +fonts.encodings = encodings +encodings.agl = { } +encodings.known = { } -setmetatable(fonts.encodings.agl, { __index = function(t,k) +setmetatable(encodings.agl, { __index = function(t,k) if k == "unicodes" then texio.write(" <loading (extended) adobe glyph list>") local unicodes = dofile(resolvers.findfile("font-age.lua")) - fonts.encodings.agl = { unicodes = unicodes } + encodings.agl = { unicodes = unicodes } return unicodes else return nil end end }) +-- adapted for generic + +encodings.cache = containers.define("fonts", "enc", encodings.version, true) + +function encodings.load(filename) + local name = file.removesuffix(filename) + local data = containers.read(encodings.cache,name) + if data then + return data + end + local vector, tag, hash, unicodes = { }, "", { }, { } + local foundname = resolvers.findfile(filename,'enc') + if foundname and foundname ~= "" then + local ok, encoding, size = resolvers.loadbinfile(foundname) + if ok and encoding then + encoding = string.gsub(encoding,"%%(.-)\n","") + local unicoding = encodings.agl.unicodes + local tag, vec = string.match(encoding,"/(%w+)%s*%[(.*)%]%s*def") + local i = 0 + for ch in string.gmatch(vec,"/([%a%d%.]+)") do + if ch ~= ".notdef" then + vector[i] = ch + if not hash[ch] then + hash[ch] = i + else + -- duplicate, play safe for tex ligs and take first + end + local u = unicoding[ch] + if u then + unicodes[u] = i + end + end + i = i + 1 + end + end + end + local data = { + name = name, + tag = tag, + vector = vector, + hash = hash, + unicodes = unicodes + } + return containers.write(encodings.cache, name, data) +end + |