diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-03-02 22:35:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-03-02 22:35:00 +0100 |
commit | 5842399ccc8311f6e77c3139efc42994dc9a07af (patch) | |
tree | 27b3f62237e5a11626c27ace14349652a44c5e71 /tex/context/base/font-gds.lua | |
parent | 78d548db9ace31d50ecd43f7a98dcfb80d952e67 (diff) | |
download | context-5842399ccc8311f6e77c3139efc42994dc9a07af.tar.gz |
beta 2012.03.02 22:35
Diffstat (limited to 'tex/context/base/font-gds.lua')
-rw-r--r-- | tex/context/base/font-gds.lua | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua index 97e97a640..3b87e4c77 100644 --- a/tex/context/base/font-gds.lua +++ b/tex/context/base/font-gds.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['font-gds'] = { -- depends on ctx local type, next = type, next -local gmatch, format, lower = string.gmatch, string.format, string.lower +local gmatch, format, lower, find, splitup = string.gmatch, string.format, string.lower, string.find, string.splitup local texsp = tex.sp local fonts, nodes, attributes, node = fonts, nodes, attributes, node @@ -251,17 +251,42 @@ local function setcolorscheme(tfmdata,scheme) local g = goodies[i] what = (g.colorschemes and g.colorschemes[scheme]) or what end - if what then + if type(what) == "table" then -- this is font bound but we can share them if needed -- just as we could hash the conversions (per font) - local hash, reverse = tfmdata.resources.unicodes, { } + local hash = tfmdata.resources.unicodes + local reverse = { } + local characters = tfmdata.characters for i=1,#what do local w = what[i] for j=1,#w do local name = w[j] - local unicode = hash[name] - if unicode then - reverse[unicode] = i + if name == "*" then + -- inefficient but only used for tracing anyway + for _, unicode in next, hash do + reverse[unicode] = i + end + elseif type(name) == "number" then + reverse[name] = i + elseif find(name,":") then + local start, stop = splitup(name,":") + start = tonumber(start) + stop = tonumber(stop) + if start and stop then + -- limited usage: we only deal with non reassigned + -- maybe some day I'll also support the ones with a + -- tounicode in this range + for unicode=start,stop do + if characters[unicode] then + reverse[unicode] = i + end + end + end + else + local unicode = hash[name] + if unicode then + reverse[unicode] = i + end end end end |