diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-enc.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/font-enc.lua | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-enc.lua b/Master/texmf-dist/tex/context/base/font-enc.lua index 874f7c3f4ed..a6f9250e758 100644 --- a/Master/texmf-dist/tex/context/base/font-enc.lua +++ b/Master/texmf-dist/tex/context/base/font-enc.lua @@ -6,18 +6,25 @@ if not modules then modules = { } end modules ['font-enc'] = { license = "see context related readme files" } +-- this module is obsolete + local match, gmatch, gsub = string.match, string.gmatch, string.gsub +local setmetatableindex = table.setmetatableindex + --[[ldx-- <p>Because encodings are going to disappear, we don't bother defining them in tables. But we may do so some day, for consistency.</p> --ldx]]-- -fonts.enc = fonts.enc or { } -fonts.enc.version = 1.03 -fonts.enc.cache = containers.define("fonts", "enc", fonts.enc.version, true) +local report_encoding = logs.reporter("fonts","encoding") + +local encodings = { } +fonts.encodings = encodings -fonts.enc.known = { -- sort of obsolete +encodings.version = 1.03 +encodings.cache = containers.define("fonts", "enc", fonts.encodings.version, true) +encodings.known = utilities.storage.allocate { -- sort of obsolete texnansi = true, ec = true, qx = true, @@ -25,11 +32,11 @@ fonts.enc.known = { -- sort of obsolete t2a = true, t2b = true, t2c = true, - unicode = true + unicode = true, } -function fonts.enc.is_known(encoding) - return containers.is_valid(fonts.enc.cache(),encoding) +function encodings.is_known(encoding) + return containers.is_valid(encodings.cache,encoding) end --[[ldx-- @@ -51,24 +58,25 @@ Latin Modern or <l n='tex'> Gyre) come in OpenType variants too, so these will be used.</p> --ldx]]-- -function fonts.enc.load(filename) +local enccodes = characters.enccodes or { } + +function encodings.load(filename) local name = file.removesuffix(filename) - local data = containers.read(fonts.enc.cache(),name) + local data = containers.read(encodings.cache,name) if data then return data end if name == "unicode" then - data = fonts.enc.make_unicode_vector() -- special case, no tex file for this + data = encodings.make_unicode_vector() -- special case, no tex file for this end if data then return data end local vector, tag, hash, unicodes = { }, "", { }, { } - local foundname = resolvers.find_file(filename,'enc') + local foundname = resolvers.findfile(filename,'enc') if foundname and foundname ~= "" then local ok, encoding, size = resolvers.loadbinfile(foundname) if ok and encoding then - local enccodes = characters.enccodes encoding = gsub(encoding,"%%(.-)\n","") local tag, vec = match(encoding,"/(%w+)%s*%[(.*)%]%s*def") local i = 0 @@ -89,13 +97,13 @@ function fonts.enc.load(filename) end end local data = { - name=name, - tag=tag, - vector=vector, - hash=hash, - unicodes=unicodes + name = name, + tag = tag, + vector = vector, + hash = hash, + unicodes = unicodes } - return containers.write(fonts.enc.cache(), name, data) + return containers.write(encodings.cache, name, data) end --[[ldx-- @@ -105,12 +113,13 @@ one.</p> -- maybe make this a function: -function fonts.enc.make_unicode_vector() +function encodings.make_unicode_vector() local vector, hash = { }, { } for code, v in next, characters.data do local name = v.adobename if name then - vector[code], hash[name] = name, code + vector[code] = name + hash[name] = code else vector[code] = '.notdef' end @@ -118,5 +127,21 @@ function fonts.enc.make_unicode_vector() for name, code in next, characters.synonyms do vector[code], hash[name] = name, code end - return containers.write(fonts.enc.cache(), 'unicode', { name='unicode', tag='unicode', vector=vector, hash=hash }) + return containers.write(encodings.cache, 'unicode', { name='unicode', tag='unicode', vector=vector, hash=hash }) +end + +if not encodings.agl then + + -- We delay delay loading this rather big vector that is only needed when a + -- font is loaded for caching. Once we're further along the route we can also + -- delay it in the generic version (which doesn't use this file). + + encodings.agl = { } + + setmetatableindex(encodings.agl, function(t,k) + report_encoding("loading (extended) adobe glyph list") + dofile(resolvers.findfile("font-agl.lua")) + return rawget(encodings.agl,k) + end) + end |