diff options
author | Hans Hagen <pragma@wxs.nl> | 2008-03-10 23:20:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2008-03-10 23:20:00 +0100 |
commit | e4c575ea1e6cb242b3b8441eb4febc0e469412f2 (patch) | |
tree | 5ddbbc41a6aea426dac1386905e1a0953b2ca3b6 /tex/context/base/font-enc.lua | |
parent | f0302311dd47bf250c0e2b5f8be46f21437f43d8 (diff) | |
download | context-e4c575ea1e6cb242b3b8441eb4febc0e469412f2.tar.gz |
stable 2008.03.10 23:20
Diffstat (limited to 'tex/context/base/font-enc.lua')
-rw-r--r-- | tex/context/base/font-enc.lua | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/tex/context/base/font-enc.lua b/tex/context/base/font-enc.lua index 2d1005ad2..73b4ae5d8 100644 --- a/tex/context/base/font-enc.lua +++ b/tex/context/base/font-enc.lua @@ -52,42 +52,48 @@ will be used.</p> function fonts.enc.load(filename) local name = file.removesuffix(filename) local data = containers.read(fonts.enc.cache,name) - if not data then - local vector, tag, hash, unicodes = { }, "", { }, { } - local foundname = input.find_file(texmf.instance,filename,'enc') - if foundname and foundname ~= "" then - local ok, encoding, size = input.loadbinfile(texmf.instance,foundname) - if ok and encoding then - local enccodes = characters.context.enccodes - encoding = encoding:gsub("%%(.-)\n","") - local tag, vec = encoding:match("/(%w+)%s*%[(.*)%]%s*def") - local i = 0 - for ch in vec:gmatch("/([%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 - if enccodes[ch] then - unicodes[enccodes[ch]] = i - end + if data then + return data + end + if name == "unicode" then + data = fonts.enc.make_unicode_vector() -- special case, no tex file for this + end + if data then + return data + end + local vector, tag, hash, unicodes = { }, "", { }, { } + local foundname = input.find_file(texmf.instance,filename,'enc') + if foundname and foundname ~= "" then + local ok, encoding, size = input.loadbinfile(texmf.instance,foundname) + if ok and encoding then + local enccodes = characters.context.enccodes + encoding = encoding:gsub("%%(.-)\n","") + local tag, vec = encoding:match("/(%w+)%s*%[(.*)%]%s*def") + local i = 0 + for ch in vec:gmatch("/([%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 + if enccodes[ch] then + unicodes[enccodes[ch]] = i end - i = i + 1 end + i = i + 1 end end - local data = { - name=name, - tag=tag, - vector=vector, - hash=hash, - unicodes=unicodes - } - data = containers.write(fonts.enc.cache, name, data) end - return data + local data = { + name=name, + tag=tag, + vector=vector, + hash=hash, + unicodes=unicodes + } + return containers.write(fonts.enc.cache, name, data) end --[[ldx-- @@ -110,5 +116,5 @@ function fonts.enc.make_unicode_vector() for name, code in pairs(characters.synonyms) do vector[code], hash[name] = name, code end - containers.write(fonts.enc.cache, 'unicode', { name='unicode', tag='unicode', vector=vector, hash=hash }) + return containers.write(fonts.enc.cache, 'unicode', { name='unicode', tag='unicode', vector=vector, hash=hash }) end |