summaryrefslogtreecommitdiff
path: root/src/fontloader/runtime/fontloader-fontloader.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2015-03-18 08:08:59 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2015-03-18 08:08:59 +0100
commitc4c4901173b0f4284534db1b6a3cfe865b05e15c (patch)
treef27d1546977bae78b33180192cc80eecc568bf4c /src/fontloader/runtime/fontloader-fontloader.lua
parentb966e35c9df3cca2a25baaf68574d0b8d94eef39 (diff)
parentf5dd1ec3517cda47e5a48221d4ff5cfced12ea06 (diff)
downloadluaotfload-c4c4901173b0f4284534db1b6a3cfe865b05e15c.tar.gz
Merge pull request #266 from phi-gamma/master
fontloader fallback
Diffstat (limited to 'src/fontloader/runtime/fontloader-fontloader.lua')
-rw-r--r--src/fontloader/runtime/fontloader-fontloader.lua526
1 files changed, 280 insertions, 246 deletions
diff --git a/src/fontloader/runtime/fontloader-fontloader.lua b/src/fontloader/runtime/fontloader-fontloader.lua
index 96a7dd3..b662152 100644
--- a/src/fontloader/runtime/fontloader-fontloader.lua
+++ b/src/fontloader/runtime/fontloader-fontloader.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/21/14 22:25:48
+-- merge date : 03/10/15 12:09:17
do -- begin closure to overcome local limits and interference
@@ -85,6 +85,13 @@ end
if lua then
lua.mask=load([[τεχ = 1]]) and "utf" or "ascii"
end
+local flush=io.flush
+if flush then
+ local execute=os.execute if execute then function os.execute(...) flush() return execute(...) end end
+ local exec=os.exec if exec then function os.exec (...) flush() return exec (...) end end
+ local spawn=os.spawn if spawn then function os.spawn (...) flush() return spawn (...) end end
+ local popen=io.popen if popen then function io.popen (...) flush() return popen (...) end end
+end
end -- closure
@@ -964,8 +971,9 @@ function table.keys(t)
end
end
local function compare(a,b)
- local ta,tb=type(a),type(b)
- if ta==tb then
+ local ta=type(a)
+ local tb=type(b)
+ if ta==tb and ta=="number" then
return a<b
else
return tostring(a)<tostring(b)
@@ -1288,7 +1296,7 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
end
- if root and next(root) then
+ if root and next(root)~=nil then
local first,last=nil,0
if compact then
last=#root
@@ -1321,7 +1329,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s %q,",depth,v))
end
elseif tv=="table" then
- if not next(v) then
+ if next(v)==nil then
handle(format("%s {},",depth))
elseif inline then
local st=simple_table(v)
@@ -1405,7 +1413,7 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
elseif tv=="table" then
- if not next(v) then
+ if next(v)==nil then
if tk=="number" then
if hexify then
handle(format("%s [0x%X]={},",depth,k))
@@ -1547,7 +1555,7 @@ local function serialize(_handle,root,name,specification)
local dummy=root._w_h_a_t_e_v_e_r_
root._w_h_a_t_e_v_e_r_=nil
end
- if next(root) then
+ if next(root)~=nil then
do_serialize(root,name,"",0)
end
end
@@ -1682,7 +1690,7 @@ local function sparse(old,nest,keeptables)
if not (v=="" or v==false) then
if nest and type(v)=="table" then
v=sparse(v,nest)
- if keeptables or next(v) then
+ if keeptables or next(v)~=nil then
new[k]=v
end
else
@@ -1799,10 +1807,10 @@ function table.sub(t,i,j)
return { unpack(t,i,j) }
end
function table.is_empty(t)
- return not t or not next(t)
+ return not t or next(t)==nil
end
function table.has_one_entry(t)
- return t and not next(t,next(t))
+ return t and next(t,next(t))==nil
end
function table.loweredkeys(t)
local l={}
@@ -1871,7 +1879,7 @@ function table.filtered(t,pattern,sort,cmp)
else
local n=next(t)
local function iterator()
- while n do
+ while n~=nil do
local k=n
n=next(t,k)
if find(k,pattern) then
@@ -2195,8 +2203,6 @@ function io.readstring(f,n,m)
local str=gsub(f:read(n),"\000","")
return str
end
-if not io.i_limiter then function io.i_limiter() end end
-if not io.o_limiter then function io.o_limiter() end end
end -- closure
@@ -2214,41 +2220,28 @@ local file=file
if not lfs then
lfs=optionalrequire("lfs")
end
-if not lfs then
- lfs={
- getcurrentdir=function()
- return "."
- end,
- attributes=function()
- return nil
- end,
- isfile=function(name)
- local f=io.open(name,'rb')
- if f then
- f:close()
- return true
- end
- end,
- isdir=function(name)
- print("you need to load lfs")
- return false
- end
- }
-elseif not lfs.isfile then
- local attributes=lfs.attributes
- function lfs.isdir(name)
- return attributes(name,"mode")=="directory"
- end
- function lfs.isfile(name)
- return attributes(name,"mode")=="file"
- end
-end
local insert,concat=table.insert,table.concat
local match,find,gmatch=string.match,string.find,string.gmatch
local lpegmatch=lpeg.match
local getcurrentdir,attributes=lfs.currentdir,lfs.attributes
local checkedsplit=string.checkedsplit
local P,R,S,C,Cs,Cp,Cc,Ct=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cp,lpeg.Cc,lpeg.Ct
+local tricky=S("/\\")*P(-1)
+local attributes=lfs.attributes
+if sandbox then
+ sandbox.redefine(lfs.isfile,"lfs.isfile")
+ sandbox.redefine(lfs.isdir,"lfs.isdir")
+end
+function lfs.isdir(name)
+ if lpegmatch(tricky,name) then
+ return attributes(name,"mode")=="directory"
+ else
+ return attributes(name.."/.","mode")=="directory"
+ end
+end
+function lfs.isfile(name)
+ return attributes(name,"mode")=="file"
+end
local colon=P(":")
local period=P(".")
local periods=P("..")
@@ -2535,18 +2528,6 @@ function file.collapsepath(str,anchor)
end
end
end
-local tricky=S("/\\")*P(-1)
-local attributes=lfs.attributes
-function lfs.isdir(name)
- if lpegmatch(tricky,name) then
- return attributes(name,"mode")=="directory"
- else
- return attributes(name.."/.","mode")=="directory"
- end
-end
-function lfs.isfile(name)
- return attributes(name,"mode")=="file"
-end
local validchars=R("az","09","AZ","--","..")
local pattern_a=lpeg.replacer(1-validchars)
local pattern_a=Cs((validchars+P(1)/"-")^1)
@@ -2874,10 +2855,10 @@ string.tracedchars=tracedchars
strings.tracers=tracedchars
function string.tracedchar(b)
if type(b)=="number" then
- return tracedchars[b] or (utfchar(b).." (U+"..format('%05X',b)..")")
+ return tracedchars[b] or (utfchar(b).." (U+"..format("%05X",b)..")")
else
local c=utfbyte(b)
- return tracedchars[c] or (b.." (U+"..format('%05X',c)..")")
+ return tracedchars[c] or (b.." (U+"..(c and format("%05X",c) or "?????")..")")
end
end
function number.signed(i)
@@ -3393,8 +3374,13 @@ end
local dummyfunction=function()
end
local dummyreporter=function(c)
- return function(...)
- (texio.reporter or texio.write_nl)(c.." : "..string.formatters(...))
+ return function(f,...)
+ local r=texio.reporter or texio.write_nl
+ if f then
+ r(c.." : "..string.formatters(f,...))
+ else
+ r("")
+ end
end
end
statistics={
@@ -3981,7 +3967,7 @@ fonts.analyzers={}
fonts.readers={}
fonts.definers={ methods={} }
fonts.loggers={ register=function() end }
-fontloader.totable=fontloader.to_table
+fontloader.totable=fontloader.to_table
end -- closure
@@ -5813,13 +5799,13 @@ local function read_from_tfm(specification)
properties.filename=specification.filename
properties.format=fonts.formats.tfm
parameters.size=size
- shared.rawdata={}
- shared.features=features
- shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil
tfmdata.properties=properties
tfmdata.resources=resources
tfmdata.parameters=parameters
tfmdata.shared=shared
+ shared.rawdata={}
+ shared.features=features
+ shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil
parameters.slant=parameters.slant or parameters[1] or 0
parameters.space=parameters.space or parameters[2] or 0
parameters.space_stretch=parameters.space_stretch or parameters[3] or 0
@@ -5915,6 +5901,10 @@ local findbinfile=resolvers.findbinfile
local definers=fonts.definers
local readers=fonts.readers
local constructors=fonts.constructors
+local fontloader=fontloader
+local font_to_table=fontloader.to_table
+local open_font=fontloader.open
+local close_font=fontloader.close
local afm=constructors.newhandler("afm")
local pfb=constructors.newhandler("pfb")
local afmfeatures=constructors.newfeatures("afm")
@@ -6030,10 +6020,10 @@ local function get_variables(data,fontmetrics)
end
local function get_indexes(data,pfbname)
data.resources.filename=resolvers.unresolve(pfbname)
- local pfbblob=fontloader.open(pfbname)
+ local pfbblob=open_font(pfbname)
if pfbblob then
local characters=data.characters
- local pfbdata=fontloader.to_table(pfbblob)
+ local pfbdata=font_to_table(pfbblob)
if pfbdata then
local glyphs=pfbdata.glyphs
if glyphs then
@@ -6058,7 +6048,7 @@ local function get_indexes(data,pfbname)
elseif trace_loading then
report_afm("no data in pfb file %a",pfbname)
end
- fontloader.close(pfbblob)
+ close_font(pfbblob)
elseif trace_loading then
report_afm("invalid pfb file %a",pfbname)
end
@@ -7072,13 +7062,14 @@ local report_otf=logs.reporter("fonts","otf loading")
local fonts=fonts
local otf=fonts.handlers.otf
otf.glists={ "gsub","gpos" }
-otf.version=2.802
+otf.version=2.803
otf.cache=containers.define("fonts","otf",otf.version,true)
-local fontdata=fonts.hashes.identifiers
-local chardata=characters and characters.data
+local hashes=fonts.hashes
local definers=fonts.definers
local readers=fonts.readers
local constructors=fonts.constructors
+local fontdata=hashes and hashes.identifiers
+local chardata=characters and characters.data
local otffeatures=constructors.newfeatures("otf")
local registerotffeature=otffeatures.register
local enhancers=allocate()
@@ -7095,7 +7086,11 @@ local overloadkerns=false
local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes
local wildcard="*"
local default="dflt"
-local fontloaderfields=fontloader.fields
+local fontloader=fontloader
+local open_font=fontloader.open
+local close_font=fontloader.close
+local font_fields=fontloader.fields
+local apply_featurefile=fontloader.apply_featurefile
local mainfields=nil
local glyphfields=nil
local formats=fonts.formats
@@ -7136,7 +7131,7 @@ local function load_featurefile(raw,featurefile)
if trace_loading then
report_otf("using featurefile %a",featurefile)
end
- fontloader.apply_featurefile(raw,featurefile)
+ apply_featurefile(raw,featurefile)
end
end
local function showfeatureorder(rawdata,filename)
@@ -7387,12 +7382,12 @@ function otf.load(filename,sub,featurefile)
report_otf("loading %a, hash %a",filename,hash)
local fontdata,messages
if sub then
- fontdata,messages=fontloader.open(filename,sub)
+ fontdata,messages=open_font(filename,sub)
else
- fontdata,messages=fontloader.open(filename)
+ fontdata,messages=open_font(filename)
end
if fontdata then
- mainfields=mainfields or (fontloaderfields and fontloaderfields(fontdata))
+ mainfields=mainfields or (font_fields and font_fields(fontdata))
end
if trace_loading and messages and #messages>0 then
if type(messages)=="string" then
@@ -7466,7 +7461,7 @@ function otf.load(filename,sub,featurefile)
report_otf("preprocessing and caching time %s, packtime %s",
elapsedtime(data),packdata and elapsedtime(packtime) or 0)
end
- fontloader.close(fontdata)
+ close_font(fontdata)
if cleanup>3 then
collectgarbage("collect")
end
@@ -9850,9 +9845,9 @@ if not modules then modules={} end modules ['font-inj']={
if not nodes.properties then return end
local next,rawget=next,rawget
local utfchar=utf.char
+local fastcopy=table.fastcopy
local trace_injections=false trackers.register("fonts.injections",function(v) trace_injections=v end)
local report_injections=logs.reporter("fonts","injections")
-report_injections("using experimental injector")
local attributes,nodes,node=attributes,nodes,node
fonts=fonts
local fontdata=fonts.hashes.identifiers
@@ -9899,15 +9894,36 @@ function injections.resetcounts()
keepregisteredcounts=false
end
function injections.reset(n)
- local p=rawget(properties,start)
- if p and p.injections then
- p.injections=nil
+ local p=rawget(properties,n)
+ if p and rawget(p,"injections") then
+ p.injections=nil
+ end
+end
+function injections.copy(target,source)
+ local sp=rawget(properties,source)
+ if sp then
+ local tp=rawget(properties,target)
+ local si=rawget(sp,"injections")
+ if si then
+ si=fastcopy(si)
+ if tp then
+ tp.injections=si
+ else
+ propertydata[target]={
+ injections=si,
+ }
+ end
+ else
+ if tp then
+ tp.injections=nil
+ end
+ end
end
end
function injections.setligaindex(n,index)
local p=rawget(properties,n)
if p then
- local i=p.injections
+ local i=rawget(p,"injections")
if i then
i.ligaindex=index
else
@@ -9926,9 +9942,9 @@ end
function injections.getligaindex(n,default)
local p=rawget(properties,n)
if p then
- p=p.injections
- if p then
- return p.ligaindex or default
+ local i=rawget(p,"injections")
+ if i then
+ return i.ligaindex or default
end
end
return default
@@ -9945,7 +9961,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne
end
local p=rawget(properties,start)
if p then
- local i=p.injections
+ local i=rawget(p,"injections")
if i then
i.cursiveanchor=true
else
@@ -9962,7 +9978,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne
end
local p=rawget(properties,nxt)
if p then
- local i=p.injections
+ local i=rawget(p,"injections")
if i then
i.cursivex=dx
i.cursivey=dy
@@ -9995,14 +10011,16 @@ function injections.setpair(current,factor,rlmode,r2lflag,spec,injection)
end
local p=rawget(properties,current)
if p then
- local i=p.injections
+ local i=rawget(p,"injections")
if i then
- if leftkern~=0 or rightkern~=0 then
- i.leftkern=i.leftkern or 0+leftkern
- i.rightkern=i.rightkern or 0+rightkern
+ if leftkern~=0 then
+ i.leftkern=(i.leftkern or 0)+leftkern
+ end
+ if rightkern~=0 then
+ i.rightkern=(i.rightkern or 0)+rightkern
end
if yoffset~=0 then
- i.yoffset=i.yoffset or 0+yoffset
+ i.yoffset=(i.yoffset or 0)+yoffset
end
elseif leftkern~=0 or rightkern~=0 then
p.injections={
@@ -10044,9 +10062,9 @@ function injections.setkern(current,factor,rlmode,x,injection)
injection="injections"
end
if p then
- local i=p[injection]
+ local i=rawget(p,injection)
if i then
- i.leftkern=dx+i.leftkern or 0
+ i.leftkern=dx+(i.leftkern or 0)
else
p[injection]={
leftkern=dx,
@@ -10072,7 +10090,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase)
end
local p=rawget(properties,start)
if p then
- local i=p.injections
+ local i=rawget(p,"injections")
if i then
i.markx=dx
i.marky=dy
@@ -10112,18 +10130,18 @@ local function show(n,what,nested,symbol)
if n then
local p=rawget(properties,n)
if p then
- local p=p[what]
- if p then
- local leftkern=p.leftkern or 0
- local rightkern=p.rightkern or 0
- local yoffset=p.yoffset or 0
- local markx=p.markx or 0
- local marky=p.marky or 0
- local markdir=p.markdir or 0
- local markbase=p.markbase or 0
- local cursivex=p.cursivex or 0
- local cursivey=p.cursivey or 0
- local ligaindex=p.ligaindex or 0
+ local i=rawget(p,what)
+ if i then
+ local leftkern=i.leftkern or 0
+ local rightkern=i.rightkern or 0
+ local yoffset=i.yoffset or 0
+ local markx=i.markx or 0
+ local marky=i.marky or 0
+ local markdir=i.markdir or 0
+ local markbase=i.markbase or 0
+ local cursivex=i.cursivex or 0
+ local cursivey=i.cursivey or 0
+ local ligaindex=i.ligaindex or 0
local margin=nested and 4 or 2
if rightkern~=0 or yoffset~=0 then
report_injections("%w%s pair: lx %p, rx %p, dy %p",margin,symbol,leftkern,rightkern,yoffset)
@@ -10151,9 +10169,9 @@ local function showsub(n,what,where)
end
report_injections("end subrun")
end
-local function trace(head)
- report_injections("begin run: %s kerns, %s pairs, %s marks and %s cursives registered",
- nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives)
+local function trace(head,where)
+ report_injections("begin run %s: %s kerns, %s pairs, %s marks and %s cursives registered",
+ where or "",nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives)
local n=head
while n do
local id=getid(n)
@@ -10206,10 +10224,6 @@ local function collect_glyphs_1(head)
local nf,tm=nil,nil
for n in traverse_id(glyph_code,head) do
if getsubtype(n)<256 then
- local pn=rawget(properties,n)
- if pn then
- pn=pn.injections
- end
local f=getfont(n)
if f~=nf then
nf=f
@@ -10222,10 +10236,14 @@ local function collect_glyphs_1(head)
nofglyphs=nofglyphs+1
glyphs[nofglyphs]=n
end
- if pn then
- local yoffset=pn.yoffset
- if yoffset and yoffset~=0 then
- setfield(n,"yoffset",yoffset)
+ local p=rawget(properties,n)
+ if p then
+ local i=rawget(p,"injections")
+ if i then
+ local yoffset=i.yoffset
+ if yoffset and yoffset~=0 then
+ setfield(n,"yoffset",yoffset)
+ end
end
end
end
@@ -10259,20 +10277,30 @@ local function inject_marks(marks,nofmarks)
local n=marks[i]
local pn=rawget(properties,n)
if pn then
- pn=pn.injections
- end
- if pn then
+ pn=rawget(pn,"injections")
+ if pn then
local p=pn.markbasenode
if p then
local px=getfield(p,"xoffset")
local ox=0
+ local rightkern=nil
local pp=rawget(properties,p)
- local rightkern=pp and pp.rightkern
+ if pp then
+ pp=rawget(pp,"injections")
+ if pp then
+ rightkern=pp.rightkern
+ end
+ end
if rightkern then
if pn.markdir<0 then
ox=px-pn.markx-rightkern
else
- ox=px-pn.markx-pp.leftkern
+ local leftkern=pp.leftkern
+ if leftkern then
+ ox=px-pn.markx
+ else
+ ox=px-pn.markx-leftkern
+ end
end
else
ox=px-pn.markx
@@ -10293,6 +10321,7 @@ local function inject_marks(marks,nofmarks)
setfield(n,"yoffset",oy)
else
end
+ end
end
end
end
@@ -10303,14 +10332,14 @@ local function inject_cursives(glyphs,nofglyphs)
local n=glyphs[i]
local pn=rawget(properties,n)
if pn then
- pn=pn.injections
+ pn=rawget(pn,"injections")
end
if pn then
local cursivex=pn.cursivex
if cursivex then
if cursiveanchor then
if cursivex~=0 then
- pn.leftkern=pn.leftkern or 0+cursivex
+ pn.leftkern=(pn.leftkern or 0)+cursivex
end
if lastanchor then
if maxc==0 then
@@ -10374,16 +10403,16 @@ local function inject_kerns(head,glyphs,nofglyphs)
local n=glyphs[i]
local pn=rawget(properties,n)
if pn then
- pn=pn.injections
- end
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
- insert_node_before(head,n,newkern(leftkern))
- end
- local rightkern=pn.rightkern
- if rightkern and rightkern~=0 then
- insert_node_after(head,n,newkern(rightkern))
+ local i=rawget(pn,"injections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ insert_node_before(head,n,newkern(leftkern))
+ end
+ local rightkern=i.rightkern
+ if rightkern and rightkern~=0 then
+ insert_node_after(head,n,newkern(rightkern))
+ end
end
end
end
@@ -10391,7 +10420,7 @@ end
local function inject_everything(head,where)
head=tonut(head)
if trace_injections then
- trace(head)
+ trace(head,"everything")
end
local glyphs,nofglyphs,marks,nofmarks
if nofregisteredpairs>0 then
@@ -10403,7 +10432,7 @@ local function inject_everything(head,where)
if nofregisteredcursives>0 then
inject_cursives(glyphs,nofglyphs)
end
- if nofregisteredmarks>0 then
+ if nofregisteredmarks>0 then
inject_marks(marks,nofmarks)
end
inject_kerns(head,glyphs,nofglyphs)
@@ -10421,7 +10450,7 @@ end
local function inject_kerns_only(head,where)
head=tonut(head)
if trace_injections then
- trace(head)
+ trace(head,"kerns")
end
local n=head
local p=nil
@@ -10434,10 +10463,10 @@ local function inject_kerns_only(head,where)
if p then
local d=getfield(p,"post")
if d then
- local pn=pn.postinjections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"postinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
local t=find_tail(d)
insert_node_after(d,t,newkern(leftkern))
end
@@ -10445,28 +10474,28 @@ local function inject_kerns_only(head,where)
end
local d=getfield(p,"replace")
if d then
- local pn=pn.replaceinjections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"replaceinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
local t=find_tail(d)
insert_node_after(d,t,newkern(leftkern))
end
end
else
- local pn=pn.injections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"injections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
setfield(p,"replace",newkern(leftkern))
end
end
end
else
- local pn=pn.injections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"injections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
head=insert_node_before(head,n,newkern(leftkern))
end
end
@@ -10484,12 +10513,12 @@ local function inject_kerns_only(head,where)
if getsubtype(n)<256 then
local pn=rawget(properties,n)
if pn then
- pn=pn.preinjections
- end
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
+ local i=rawget(pn,"preinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
end
end
else
@@ -10507,12 +10536,12 @@ local function inject_kerns_only(head,where)
if getsubtype(n)<256 then
local pn=rawget(properties,n)
if pn then
- pn=pn.postinjections
- end
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
+ local i=rawget(pn,"postinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
end
end
else
@@ -10530,12 +10559,12 @@ local function inject_kerns_only(head,where)
if getsubtype(n)<256 then
local pn=rawget(properties,n)
if pn then
- pn=pn.replaceinjections
- end
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
+ local i=rawget(pn,"replaceinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
end
end
else
@@ -10562,7 +10591,7 @@ end
local function inject_pairs_only(head,where)
head=tonut(head)
if trace_injections then
- trace(head)
+ trace(head,"pairs")
end
local n=head
local p=nil
@@ -10575,10 +10604,10 @@ local function inject_pairs_only(head,where)
if p then
local d=getfield(p,"post")
if d then
- local pn=pn.postinjections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"postinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
local t=find_tail(d)
insert_node_after(d,t,newkern(leftkern))
end
@@ -10586,35 +10615,35 @@ local function inject_pairs_only(head,where)
end
local d=getfield(p,"replace")
if d then
- local pn=pn.replaceinjections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"replaceinjections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
local t=find_tail(d)
insert_node_after(d,t,newkern(leftkern))
end
end
else
- local pn=pn.injections
- if pn then
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local i=rawget(pn,"injections")
+ if i then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
setfield(p,"replace",newkern(leftkern))
end
end
end
else
- local pn=pn.injections
- if pn then
- local yoffset=pn.yoffset
+ local i=rawget(pn,"injections")
+ if i then
+ local yoffset=i.yoffset
if yoffset and yoffset~=0 then
setfield(n,"yoffset",yoffset)
end
- local leftkern=pn.leftkern
- if leftkern~=0 then
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
insert_node_before(head,n,newkern(leftkern))
end
- local rightkern=pn.rightkern
+ local rightkern=i.rightkern
if rightkern and rightkern~=0 then
insert_node_after(head,n,newkern(rightkern))
n=getnext(n)
@@ -10632,23 +10661,23 @@ local function inject_pairs_only(head,where)
local h=d
for n in traverse_id(glyph_code,d) do
if getsubtype(n)<256 then
- local pn=rawget(properties,n)
- if pn then
- pn=pn.preinjections
- end
- if pn then
- local yoffset=pn.yoffset
- if yoffset and yoffset~=0 then
- setfield(n,"yoffset",yoffset)
- end
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
- end
- local rightkern=pn.rightkern
- if rightkern and rightkern~=0 then
- insert_node_after(head,n,newkern(rightkern))
- n=getnext(n)
+ local p=rawget(properties,n)
+ if p then
+ local i=rawget(p,"preinjections")
+ if i then
+ local yoffset=i.yoffset
+ if yoffset and yoffset~=0 then
+ setfield(n,"yoffset",yoffset)
+ end
+ local leftkern=i.leftkern
+ if leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
+ local rightkern=i.rightkern
+ if rightkern and rightkern~=0 then
+ insert_node_after(head,n,newkern(rightkern))
+ n=getnext(n)
+ end
end
end
else
@@ -10664,23 +10693,23 @@ local function inject_pairs_only(head,where)
local h=d
for n in traverse_id(glyph_code,d) do
if getsubtype(n)<256 then
- local pn=rawget(properties,n)
- if pn then
- pn=pn.postinjections
- end
- if pn then
- local yoffset=pn.yoffset
- if yoffset and yoffset~=0 then
- setfield(n,"yoffset",yoffset)
- end
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
- end
- local rightkern=pn.rightkern
- if rightkern and rightkern~=0 then
- insert_node_after(head,n,newkern(rightkern))
- n=getnext(n)
+ local p=rawget(properties,n)
+ if p then
+ local i=rawget(p,"postinjections")
+ if i then
+ local yoffset=i.yoffset
+ if yoffset and yoffset~=0 then
+ setfield(n,"yoffset",yoffset)
+ end
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
+ local rightkern=i.rightkern
+ if rightkern and rightkern~=0 then
+ insert_node_after(head,n,newkern(rightkern))
+ n=getnext(n)
+ end
end
end
else
@@ -10696,23 +10725,23 @@ local function inject_pairs_only(head,where)
local h=d
for n in traverse_id(glyph_code,d) do
if getsubtype(n)<256 then
- local pn=rawget(properties,n)
- if pn then
- pn=pn.replaceinjections
- end
- if pn then
- local yoffset=pn.yoffset
- if yoffset and yoffset~=0 then
- setfield(n,"yoffset",yoffset)
- end
- local leftkern=pn.leftkern
- if leftkern~=0 then
- h=insert_node_before(h,n,newkern(leftkern))
- end
- local rightkern=pn.rightkern
- if rightkern and rightkern~=0 then
- insert_node_after(head,n,newkern(rightkern))
- n=getnext(n)
+ local p=rawget(properties,n)
+ if p then
+ local i=rawget(pn,"replaceinjections")
+ if i then
+ local yoffset=i.yoffset
+ if yoffset and yoffset~=0 then
+ setfield(n,"yoffset",yoffset)
+ end
+ local leftkern=i.leftkern
+ if leftkern and leftkern~=0 then
+ h=insert_node_before(h,n,newkern(leftkern))
+ end
+ local rightkern=i.rightkern
+ if rightkern and rightkern~=0 then
+ insert_node_after(head,n,newkern(rightkern))
+ n=getnext(n)
+ end
end
end
else
@@ -11224,6 +11253,7 @@ local setcursive=injections.setcursive
local setkern=injections.setkern
local setpair=injections.setpair
local resetinjection=injections.reset
+local copyinjection=injections.copy
local setligaindex=injections.setligaindex
local getligaindex=injections.getligaindex
local cursonce=true
@@ -11306,10 +11336,13 @@ local function copy_glyph(g)
if components then
setfield(g,"components",nil)
local n=copy_node(g)
+ copyinjection(n,g)
setfield(g,"components",components)
return n
else
- return copy_node(g)
+ local n=copy_node(g)
+ copyinjection(n,g)
+ return n
end
end
local function markstoligature(kind,lookupname,head,start,stop,char)
@@ -15094,13 +15127,14 @@ function nodes.handlers.nodepass(head)
if basepass and #basefonts>0 then
for i=1,#basefonts do
local range=basefonts[i]
- local start,stop=range[1],range[2]
+ local start=range[1]
+ local stop=range[2]
if stop then
- ligaturing(start,stop)
- kerning(start,stop)
- else
- ligaturing(start)
- kerning(start)
+ start,stop=ligaturing(start,stop)
+ start,stop=kerning(start,stop)
+ elseif start then
+ start=ligaturing(start)
+ start=kerning(start)
end
end
end