summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-21 06:46:45 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-21 07:07:28 +0300
commit3cbef76101d9aaef3b2c355c58675bf9f386d949 (patch)
treee11465e3a2ae642973a74ec1a5202d5cf815b176
parent7714c6972814b0ff3175479b09d0139dd67c6ab0 (diff)
downloadluaotfload-3cbef76101d9aaef3b2c355c58675bf9f386d949.tar.gz
Sync with ConTeXt beta (beta 2010.05.20)
-rw-r--r--otfl-data-con.lua2
-rw-r--r--otfl-font-def.lua6
-rw-r--r--otfl-font-dum.lua25
-rw-r--r--otfl-font-map.lua4
-rw-r--r--otfl-font-otc.lua29
-rw-r--r--otfl-font-otf.lua16
-rw-r--r--otfl-font-otn.lua49
-rw-r--r--otfl-font-ott.lua4
-rw-r--r--otfl-font-tfm.lua27
-rw-r--r--otfl-node-res.lua2
10 files changed, 112 insertions, 52 deletions
diff --git a/otfl-data-con.lua b/otfl-data-con.lua
index f06dba5..fabe0ba 100644
--- a/otfl-data-con.lua
+++ b/otfl-data-con.lua
@@ -74,7 +74,7 @@ end
function containers.is_valid(container, name)
if name and name ~= "" then
local storage = container.storage[name]
- return storage and not table.is_empty(storage) and storage.cache_version == container.version
+ return storage and storage.cache_version == container.version
else
return false
end
diff --git a/otfl-font-def.lua b/otfl-font-def.lua
index f64bae5..0add703 100644
--- a/otfl-font-def.lua
+++ b/otfl-font-def.lua
@@ -501,14 +501,14 @@ a helper function.</p>
function define.check(features,defaults) -- nb adapts features !
local done = false
- if table.is_empty(features) then
- features, done = table.fastcopy(defaults), true
- else
+ if features and next(features) then
for k,v in next, defaults do
if features[k] == nil then
features[k], done = v, true
end
end
+ else
+ features, done = table.fastcopy(defaults), true
end
return features, done -- done signals a change
end
diff --git a/otfl-font-dum.lua b/otfl-font-dum.lua
index 5224ae1..2de1ae1 100644
--- a/otfl-font-dum.lua
+++ b/otfl-font-dum.lua
@@ -55,11 +55,14 @@ fonts.names.old_to_new = { }
local data, loaded = nil, false
+local fileformats = { "lua", "tex", "other text files" }
+
function fonts.names.resolve(name,sub)
if not loaded then
local basename = fonts.names.basename
if basename and basename ~= "" then
- for _, format in ipairs { "lua", "tex", "other text files" } do
+ for i=1,#fileformats do
+ local format = fileformats[i]
local foundname = resolvers.find_file(basename,format) or ""
if foundname ~= "" then
data = dofile(foundname)
@@ -356,3 +359,23 @@ fonts.otf.meanings.normalize = fonts.otf.meanings.normalize or function(t)
t.rand = "random"
end
end
+
+-- bonus
+
+function fonts.otf.name_to_slot(name)
+ local tfmdata = fonts.ids[font.current()]
+ if tfmdata and tfmdata.shared then
+ local otfdata = tfmdata.shared.otfdata
+ local unicode = otfdata.luatex.unicodes[name]
+ return unicode and (type(unicode) == "number" and unicode or unicode[1])
+ end
+end
+
+function fonts.otf.char(n)
+ if type(n) == "string" then
+ n = fonts.otf.name_to_slot(n)
+ end
+ if type(n) == "number" then
+ tex.sprint("\\char" .. n)
+ end
+end
diff --git a/otfl-font-map.lua b/otfl-font-map.lua
index 208ad50..2995087 100644
--- a/otfl-font-map.lua
+++ b/otfl-font-map.lua
@@ -252,7 +252,7 @@ fonts.map.add_to_unicode = function(data,filename)
end
end
if trace_unimapping then
- for index, glyph in table.sortedpairs(data.glyphs) do
+ for index, glyph in table.sortedhash(data.glyphs) do
local toun, name, unic = tounicode[index], glyph.name, glyph.unicode or -1 -- play safe
if toun then
logs.report("load otf","internal: 0x%05X, name: %s, unicode: 0x%05X, tounicode: %s",index,name,unic,toun)
@@ -302,7 +302,7 @@ end
--
-- function fonts.map.flush(backend) -- will also erase the accumulated data
-- local flushline = fonts.map.line[backend or "pdftex"] or fonts.map.line.pdftex
--- for _, e in pairs(fonts.map.data) do
+-- for _, e in next, fonts.map.data do
-- flushline(e)
-- end
-- fonts.map.data = { }
diff --git a/otfl-font-otc.lua b/otfl-font-otc.lua
index 64e09f8..551696f 100644
--- a/otfl-font-otc.lua
+++ b/otfl-font-otc.lua
@@ -9,8 +9,6 @@ if not modules then modules = { } end modules ['font-otc'] = {
local format, insert = string.format, table.insert
local type, next = type, next
-local ctxcatcodes = tex.ctxcatcodes
-
-- we assume that the other otf stuff is loaded already
local trace_loading = false trackers.register("otf.loading", function(v) trace_loading = v end)
@@ -217,30 +215,3 @@ fonts.initializers.node.otf.lineheight = fonts.initializers.common.lineheight
fonts.initializers.base.otf.compose = fonts.initializers.common.compose
fonts.initializers.node.otf.compose = fonts.initializers.common.compose
-
--- bonus function
-
-function otf.name_to_slot(name) -- todo: afm en tfm
- local tfmdata = fonts.ids[font.current()]
- if tfmdata and tfmdata.shared then
- local otfdata = tfmdata.shared.otfdata
- local unicode = otfdata.luatex.unicodes[name]
- if not unicode then
- return string.byte("?") -- nil
- elseif type(unicode) == "number" then
- return unicode
- else
- return unicode[1]
- end
- end
- return nil
-end
-
-function otf.char(n) -- todo: afm en tfm
- if type(n) == "string" then
- n = otf.name_to_slot(n)
- end
- if n then
- tex.sprint(ctxcatcodes,format("\\char%s ",n))
- end
-end
diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua
index 29c56cd..bad09cb 100644
--- a/otfl-font-otf.lua
+++ b/otfl-font-otf.lua
@@ -80,7 +80,7 @@ otf.features.default = otf.features.default or { }
otf.enhancers = otf.enhancers or { }
otf.glists = { "gsub", "gpos" }
-otf.version = 2.645 -- beware: also sync font-mis.lua
+otf.version = 2.650 -- beware: also sync font-mis.lua
otf.pack = true -- beware: also sync font-mis.lua
otf.syncspace = true
otf.notdef = false
@@ -576,7 +576,7 @@ end
otf.enhancers["merge cid fonts"] = function(data,filename)
-- we can also move the names to data.luatex.names which might
-- save us some more memory (at the cost of harder tracing)
- if data.subfonts and table.is_empty(data.glyphs) then
+ if data.subfonts and data.glyphs and next(data.glyphs) then
local cidinfo = data.cidinfo
local verbose = fonts.verbose
if cidinfo.registry then
@@ -1355,7 +1355,7 @@ end
function otf.set_features(tfmdata,features)
local processes = { }
- if not table.is_empty(features) then
+ if features and next(features) then
local lists = {
fonts.triggers,
fonts.processors,
@@ -1430,14 +1430,14 @@ function otf.otf_to_tfm(specification)
--~ print(cache_id)
if not tfmdata then
local otfdata = otf.load(filename,format,sub,features and features.featurefile)
- if not table.is_empty(otfdata) then
+ if otfdata and next(otfdata) then
otfdata.shared = otfdata.shared or {
featuredata = { },
anchorhash = { },
initialized = false,
}
tfmdata = otf.copy_to_tfm(otfdata,cache_id)
- if not table.is_empty(tfmdata) then
+ if tfmdata and next(tfmdata) then
tfmdata.unique = tfmdata.unique or { }
tfmdata.shared = tfmdata.shared or { } -- combine
local shared = tfmdata.shared
@@ -1562,12 +1562,12 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th
designsize = 100
end
local spaceunits = 500
- tfm.units = metadata.units_per_em or 1000
- -- we need a runtime lookup because of running from cdrom or zip, brrr
- tfm.filename = resolvers.findbinfile(luatex.filename,"") or luatex.filename
+ -- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't we use the basename then?)
+ tfm.filename = fonts.tfm.checked_filename(luatex)
tfm.fullname = metadata.fullname
tfm.fontname = metadata.fontname
tfm.psname = tfm.fontname or tfm.fullname
+ tfm.units = metadata.units_per_em or 1000
tfm.encodingbytes = 2
tfm.cidinfo = data.cidinfo
tfm.cidinfo.registry = tfm.cidinfo.registry or ""
diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua
index 3aa1927..d4f89ad 100644
--- a/otfl-font-otn.lua
+++ b/otfl-font-otn.lua
@@ -123,6 +123,7 @@ results in different tables.</p>
local concat, insert, remove = table.concat, table.insert, table.remove
local format, gmatch, gsub, find, match, lower, strip = string.format, string.gmatch, string.gsub, string.find, string.match, string.lower, string.strip
local type, next, tonumber, tostring = type, next, tonumber, tostring
+local lpegmatch = lpeg.match
local otf = fonts.otf
local tfm = fonts.tfm
@@ -166,7 +167,7 @@ local zwj = 0x200D
local wildcard = "*"
local default = "dflt"
-local split_at_space = lpeg.Ct(lpeg.splitat(" ")) -- no trailing or multiple spaces anyway
+local split_at_space = lpeg.splitters[" "] or lpeg.Ct(lpeg.splitat(" ")) -- no trailing or multiple spaces anyway
local glyph = node.id('glyph')
local glue = node.id('glue')
@@ -2208,11 +2209,11 @@ otf.features.prepare = { }
-- document)
local function split(replacement,original,cache,unicodes)
- -- we can cache this too, but not the same
+ -- we can cache this too, but not the same (although unicode is a unique enough hash)
local o, t, n = { }, { }, 0
for s in gmatch(original,"[^ ]+") do
local us = unicodes[s]
- if type(us) == "number" then
+ if type(us) == "number" then -- tonumber(us)
o[#o+1] = us
else
o[#o+1] = us[1]
@@ -2221,7 +2222,7 @@ local function split(replacement,original,cache,unicodes)
for s in gmatch(replacement,"[^ ]+") do
n = n + 1
local us = unicodes[s]
- if type(us) == "number" then
+ if type(us) == "number" then -- tonumber(us)
t[o[n]] = us
else
t[o[n]] = us[1]
@@ -2579,6 +2580,46 @@ function prepare_contextchains(tfmdata)
end
end
end
+ elseif fmt == "glyphs" then
+ if lookuptype ~= "chainsub" and lookuptype ~= "chainpos" then
+ logs.report("otf process","unsupported coverage %s for %s",lookuptype,lookupname)
+ else
+ local contexts = contextchain[lookupname]
+ if not contexts then
+ contexts = { }
+ contextchain[lookupname] = contexts
+ end
+ local t = { }
+ for nofrules=1,#rules do
+ -- nearly the same as coverage so we could as well rename it
+ local rule = rules[nofrules]
+ local glyphs = rule.glyphs
+ if glyphs and glyphs.names then
+ local fore, back, names, sequence = glyphs.fore, glyphs.back, glyphs.names, { }
+ if fore and fore ~= "" then
+ fore = lpegmatch(split_at_space,fore)
+ uncover(fore,sequence,cache,unicodes)
+ end
+ local start = #sequence + 1
+ names = lpegmatch(split_at_space,names)
+ uncover(names,sequence,cache,unicodes)
+ local stop = #sequence
+ if back and back ~= "" then
+ back = lpegmatch(split_at_space,back)
+ uncover(back,sequence,cache,unicodes)
+ end
+ if sequence[1] then
+ t[#t+1] = { nofrules, lookuptype, sequence, start, stop, rule.lookups }
+ for unic, _ in next, sequence[start] do
+ local cu = contexts[unic]
+ if not cu then
+ contexts[unic] = t
+ end
+ end
+ end
+ end
+ end
+ end
end
end
end
diff --git a/otfl-font-ott.lua b/otfl-font-ott.lua
index d26c55f..2be1bf0 100644
--- a/otfl-font-ott.lua
+++ b/otfl-font-ott.lua
@@ -672,13 +672,13 @@ local to_scripts = otf.tables.to_scripts
local to_languages = otf.tables.to_languages
local to_features = otf.tables.to_features
-for k, v in pairs(to_features) do
+for k, v in next, to_features do
local stripped = gsub(k,"%-"," ")
to_features[stripped] = v
local stripped = gsub(k,"[^a-zA-Z0-9]","")
to_features[stripped] = v
end
-for k, v in pairs(to_features) do
+for k, v in next, to_features do
to_features[lower(k)] = v
end
diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua
index 4b217a3..31ae2ca 100644
--- a/otfl-font-tfm.lua
+++ b/otfl-font-tfm.lua
@@ -279,7 +279,7 @@ t.colorscheme = tfmtable.colorscheme
local characters = tfmtable.characters
local nameneeded = not tfmtable.shared.otfdata --hack
local changed = tfmtable.changed or { } -- for base mode
- local ischanged = not table.is_empty(changed)
+ local ischanged = changed and next(changed)
local indices = tfmtable.indices
local luatex = tfmtable.luatex
local tounicode = luatex and luatex.tounicode
@@ -704,6 +704,31 @@ function tfm.replacements(tfm,value)
-- tfm.characters[0x0060] = tfm.characters[0x2018]
end
+-- checking
+
+function tfm.checked_filename(metadata,whatever)
+ local foundfilename = metadata.foundfilename
+ if not foundfilename then
+ local askedfilename = metadata.filename or ""
+ if askedfilename ~= "" then
+ foundfilename = resolvers.findbinfile(askedfilename,"") or ""
+ if foundfilename == "" then
+ logs.report("fonts","source file '%s' is not found",askedfilename)
+ foundfilename = resolvers.findbinfile(file.basename(askedfilename),"") or ""
+ if foundfilename ~= "" then
+ logs.report("fonts","using source file '%s' (cache mismatch)",foundfilename)
+ end
+ end
+ elseif whatever then
+ logs.report("fonts","no source file for '%s'",whatever)
+ foundfilename = ""
+ end
+ metadata.foundfilename = foundfilename
+ -- logs.report("fonts","using source file '%s'",foundfilename)
+ end
+ return foundfilename
+end
+
-- status info
statistics.register("fonts load time", function()
diff --git a/otfl-node-res.lua b/otfl-node-res.lua
index 2657dfa..a8ea874 100644
--- a/otfl-node-res.lua
+++ b/otfl-node-res.lua
@@ -24,7 +24,7 @@ nodes.whatsits = { } -- table.swapped(node.whatsits())
local reserved = { }
local whatsits = nodes.whatsits
-for k, v in pairs(node.whatsits()) do
+for k, v in next, node.whatsits() do
whatsits[k], whatsits[v] = v, k -- two way
end