From 03e78f8f86fa8286c8bee314a26c454d79a871f4 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 18 Jun 2010 17:40:29 +0300 Subject: Sync with ConTeXt beta (beta 2010.06.18) --- otfl-font-ota.lua | 1 + otfl-font-otb.lua | 2 +- otfl-font-otd.lua | 2 +- otfl-font-otf.lua | 8 +++++--- otfl-font-otn.lua | 22 ++++++++++---------- otfl-font-ott.lua | 1 - otfl-node-inj.lua | 61 +++++++++++++++++++++++++++++++------------------------ 7 files changed, 53 insertions(+), 44 deletions(-) diff --git a/otfl-font-ota.lua b/otfl-font-ota.lua index 0b61e17..0e5b555 100644 --- a/otfl-font-ota.lua +++ b/otfl-font-ota.lua @@ -51,6 +51,7 @@ local a_to_language = otf.a_to_language -- somewhat slower; and .. we need a chain of them function fonts.initializers.node.otf.analyze(tfmdata,value,attr) + local script, language if attr and attr > 0 then script, language = a_to_script[attr], a_to_language[attr] else diff --git a/otfl-font-otb.lua b/otfl-font-otb.lua index a3d3477..e0528a4 100644 --- a/otfl-font-otb.lua +++ b/otfl-font-otb.lua @@ -136,7 +136,7 @@ end local splitter = lpeg.splitat(" ") -function prepare_base_substitutions(tfmdata,kind,value) -- we can share some code with the node features +local function prepare_base_substitutions(tfmdata,kind,value) -- we can share some code with the node features if value then local otfdata = tfmdata.shared.otfdata local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language) diff --git a/otfl-font-otd.lua b/otfl-font-otd.lua index 14a9727..46899fd 100644 --- a/otfl-font-otd.lua +++ b/otfl-font-otd.lua @@ -24,7 +24,7 @@ local a_to_script = { } otf.a_to_script = a_to_script local a_to_language = { } otf.a_to_language = a_to_language function otf.set_dynamics(font,dynamics,attribute) - features = context_setups[context_numbers[attribute]] -- can be moved to caller + local features = context_setups[context_numbers[attribute]] -- can be moved to caller if features then local script = features.script or 'dflt' local language = features.language or 'dflt' diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua index b113cf6..d1ad3d0 100644 --- a/otfl-font-otf.lua +++ b/otfl-font-otf.lua @@ -222,7 +222,8 @@ local enhancers = { function otf.load(filename,format,sub,featurefile) local name = file.basename(file.removesuffix(filename)) - local size = lfs.attributes(filename,"size") or 0 + local attr = lfs.attributes(filename) + local size, time = attr.size or 0, attr.modification or 0 if featurefile then name = name .. "@" .. file.removesuffix(file.basename(featurefile)) end @@ -233,7 +234,7 @@ function otf.load(filename,format,sub,featurefile) end hash = containers.cleanname(hash) local data = containers.read(otf.cache,hash) - if not data or data.verbose ~= fonts.verbose or data.size ~= size then + if not data or data.verbose ~= fonts.verbose or data.size ~= size or data.time ~= time then logs.report("load otf","loading: %s (hash: %s)",filename,hash) local ff, messages if sub then @@ -267,6 +268,7 @@ function otf.load(filename,format,sub,featurefile) otf.enhance("pack",data,filename) end data.size = size + data.time = time data.verbose = fonts.verbose logs.report("load otf","saving in cache: %s",filename) data = containers.write(otf.cache, hash, data) @@ -1537,7 +1539,7 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th if designsize == 0 then designsize = 100 end - local spaceunits = 500 + local spaceunits, spacer = 500, "space" -- indices maps from unicodes to indices for u, i in next, indices do characters[u] = { } -- we need this because for instance we add protruding info and loop over characters diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua index 4402dd6..6a6a046 100644 --- a/otfl-font-otn.lua +++ b/otfl-font-otn.lua @@ -1058,7 +1058,7 @@ end

Here we replace start by new glyph. First we delete the rest of the match.

--ldx]]-- -function chainprocs.gsub_alternate(start,stop,kind,lookupname,currentcontext,cache,currentlookup) +function chainprocs.gsub_alternate(start,stop,kind,chainname,currentcontext,cache,currentlookup,chainlookupname) -- todo: marks ? delete_till_stop(start,stop) local current = start @@ -1155,7 +1155,7 @@ function chainprocs.gsub_ligature(start,stop,kind,chainname,currentcontext,cache logprocess("%s: replacing character %s upto %s by ligature %s",cref(kind,chainname,chainlookupname,lookupname,chainindex),gref(startchar),gref(stop.char),gref(l2)) end end - start = toligature(kind,lookup,start,stop,l2,currentlookup.flags[1],discfound) + start = toligature(kind,lookupname,start,stop,l2,currentlookup.flags[1],discfound) return start, true, nofreplacements elseif trace_bugs then if start == stop then @@ -2308,7 +2308,7 @@ local function prepare_lookups(tfmdata) -- as well (no big deal) -- local action = { - substitution = function(p,lookup,k,glyph,unicode) + substitution = function(p,lookup,glyph,unicode) local old, new = unicode, unicodes[p[2]] if type(new) == "table" then new = new[1] @@ -2320,7 +2320,7 @@ local function prepare_lookups(tfmdata) --~ logs.report("define otf","lookup %s: substitution %s => %s",lookup,old,new) --~ end end, - multiple = function (p,lookup,k,glyph,unicode) + multiple = function (p,lookup,glyph,unicode) local old, new = unicode, { } local m = multiple[lookup] if not m then m = { } multiple[lookup] = m end @@ -2337,7 +2337,7 @@ local function prepare_lookups(tfmdata) --~ logs.report("define otf","lookup %s: multiple %s => %s",lookup,old,concat(new," ")) --~ end end, - alternate = function(p,lookup,k,glyph,unicode) + alternate = function(p,lookup,glyph,unicode) local old, new = unicode, { } local a = alternate[lookup] if not a then a = { } alternate[lookup] = a end @@ -2354,7 +2354,7 @@ local function prepare_lookups(tfmdata) --~ logs.report("define otf","lookup %s: alternate %s => %s",lookup,old,concat(new,"|")) --~ end end, - ligature = function (p,lookup,k,glyph,unicode) + ligature = function (p,lookup,glyph,unicode) --~ if trace_lookups then --~ logs.report("define otf","lookup %s: ligature %s => %s",lookup,p[2],glyph.name) --~ end @@ -2402,13 +2402,13 @@ local function prepare_lookups(tfmdata) end t[2] = unicode end, - position = function(p,lookup,k,glyph,unicode) + position = function(p,lookup,glyph,unicode) -- not used local s = position[lookup] if not s then s = { } position[lookup] = s end s[unicode] = p[2] -- direct pointer to kern spec end, - pair = function(p,lookup,k,glyph,unicode) + pair = function(p,lookup,glyph,unicode) local s = pair[lookup] if not s then s = { } pair[lookup] = s end local others = s[unicode] @@ -2444,7 +2444,7 @@ local function prepare_lookups(tfmdata) local lookups = glyph.slookups if lookups then for lookup, p in next, lookups do - action[p[1]](p,lookup,k,glyph,unicode) + action[p[1]](p,lookup,glyph,unicode) end end local lookups = glyph.mlookups @@ -2452,7 +2452,7 @@ local function prepare_lookups(tfmdata) for lookup, whatever in next, lookups do for i=1,#whatever do -- normaly one local p = whatever[i] - action[p[1]](p,lookup,k,glyph,unicode) + action[p[1]](p,lookup,glyph,unicode) end end end @@ -2507,7 +2507,7 @@ end -- local cache = { } luatex = luatex or {} -- this has to change ... we need a better one -function prepare_contextchains(tfmdata) +local function prepare_contextchains(tfmdata) local otfdata = tfmdata.shared.otfdata local lookups = otfdata.lookups if lookups then diff --git a/otfl-font-ott.lua b/otfl-font-ott.lua index 2be1bf0..c56e984 100644 --- a/otfl-font-ott.lua +++ b/otfl-font-ott.lua @@ -696,7 +696,6 @@ function otf.meanings.normalize(features) k = lower(k) if k == "language" or k == "lang" then v = gsub(lower(v),"[^a-z0-9%-]","") - k = language if not languages[v] then h.language = to_languages[v] or "dflt" else diff --git a/otfl-node-inj.lua b/otfl-node-inj.lua index 579a266..5b55c8c 100644 --- a/otfl-node-inj.lua +++ b/otfl-node-inj.lua @@ -27,6 +27,7 @@ local glyph = node.id('glyph') local kern = node.id('kern') local traverse_id = node.traverse_id +local unset_attribute = node.unset_attribute local has_attribute = node.has_attribute local set_attribute = node.set_attribute local insert_node_before = node.insert_before @@ -88,8 +89,10 @@ function nodes.set_kern(current,factor,rlmode,x,tfmchr) local bound = #kerns + 1 set_attribute(current,kernpair,bound) kerns[bound] = { rlmode, dx } + return dx, bound + else + return 0, 0 end - return dx, bound end function nodes.set_mark(start,base,factor,rlmode,ba,ma,index) --ba=baseanchor, ma=markanchor @@ -171,6 +174,7 @@ function nodes.trace_injection(head) end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway +-- todo: check for attribute function nodes.inject_kerns(head,where,keep) local has_marks, has_cursives, has_kerns = next(marks), next(cursives), next(kerns) @@ -193,6 +197,7 @@ function nodes.inject_kerns(head,where,keep) mk[n] = tm[n.char] local k = has_attribute(n,kernpair) if k then +--~ unset_attribute(k,kernpair) local kk = kerns[k] if kk then local x, y, w, h = kk[2] or 0, kk[3] or 0, kk[4] or 0, kk[5] or 0 @@ -383,37 +388,39 @@ function nodes.inject_kerns(head,where,keep) nodes.trace_injection(head) end for n in traverse_id(glyph,head) do - local k = has_attribute(n,kernpair) - if k then - local kk = kerns[k] - if kk then - local rl, x, y, w = kk[1], kk[2] or 0, kk[3], kk[4] - if y and y ~= 0 then - n.yoffset = y -- todo: h ? - end - if w then - -- copied from above - local r2l = kk[6] - local wx = w - x - if r2l then - if wx ~= 0 then - insert_node_before(head,n,newkern(wx)) - end - if x ~= 0 then - insert_node_after (head,n,newkern(x)) + if n.subtype < 256 then + local k = has_attribute(n,kernpair) + if k then + local kk = kerns[k] + if kk then + local rl, x, y, w = kk[1], kk[2] or 0, kk[3], kk[4] + if y and y ~= 0 then + n.yoffset = y -- todo: h ? + end + if w then + -- copied from above + local r2l = kk[6] + local wx = w - x + if r2l then + if wx ~= 0 then + insert_node_before(head,n,newkern(wx)) + end + if x ~= 0 then + insert_node_after (head,n,newkern(x)) + end + else + if x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end end else + -- simple (e.g. kernclass kerns) if x ~= 0 then insert_node_before(head,n,newkern(x)) end - if wx ~= 0 then - insert_node_after(head,n,newkern(wx)) - end - end - else - -- simple (e.g. kernclass kerns) - if x ~= 0 then - insert_node_before(head,n,newkern(x)) end end end -- cgit v1.2.3