diff options
Diffstat (limited to 'src/fontloader/runtime')
-rw-r--r-- | src/fontloader/runtime/fontloader-reference.lua | 180 |
1 files changed, 101 insertions, 79 deletions
diff --git a/src/fontloader/runtime/fontloader-reference.lua b/src/fontloader/runtime/fontloader-reference.lua index 2472903..0d22a73 100644 --- a/src/fontloader/runtime/fontloader-reference.lua +++ b/src/fontloader/runtime/fontloader-reference.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 04/16/16 15:27:56 +-- merge date : 04/17/16 11:56:26 do -- begin closure to overcome local limits and interference @@ -6673,92 +6673,39 @@ function mappings.addtounicode(data,filename,checklookups) if type(checklookups)=="function" then checklookups(data,missing,nofmissing) end - local unset={} - for unic,glyph in next,descriptions do + local collected=false + local unicoded=0 + for unicode,glyph in next,descriptions do if not glyph.unicode and glyph.class=="ligature" then - unset[unic]=glyph - end - end - if next(unset) then - local sequences=resources.sequences - local collected={} - for i=1,#sequences do - local sequence=sequences[i] - if sequence.type=="gsub_ligature" then - local steps=sequence.steps - if steps then - local l={} - local function traverse(p,k,v) - if k=="ligature" then - collected[v]={ unpack(l) } - else - table.insert(l,k) - for k,vv in next,v do - traverse(p,k,vv) - end - table.remove(l) - end - end - for i=1,#steps do - local coverage=steps[i].coverage - if coverage then - for k,v in next,coverage do - traverse(k,k,v) - end - end - end + if not collected then + collected=fonts.handlers.otf.readers.getcomponents(data) + if not collected then + break end end - end - if next(collected) then - while true do - local done=false - for k,v in next,collected do - for i=1,#v do - local vi=v[i] - if vi==k then - collected[k]=nil - unset[k]=nil - else - local c=collected[vi] - if c then - done=true - local t={} - local n=i-1 - for j=1,n do - t[j]=t[j] - end - for j=1,#c do - n=n+1 - t[n]=c[j] - end - for j=i+1,#v do - n=n+1 - t[n]=t[j] - end - collected[k]=t - break - end - end + local u=collected[unicode] + if u then + local n=#u + for i=1,n do + if u[i]>private then + n=0 + break end end - if not done then - break - end - end - local n=0 - for k,v in next,unset do - u=collected[k] - if u then - v.unicode=u - n=n+1 + if n>0 then + if n>1 then + glyph.unicode=u + else + glyph.unicode=u[1] + end + unicoded=unicoded+1 end end - if trace_mapping and n>0 then - report_fonts("%n ligature tounicode mappings deduced from gsub ligature feaures",n) - end end end + if trace_mapping and unicoded>0 then + report_fonts("%n ligature tounicode mappings deduced from gsub ligature features",unicoded) + end if trace_mapping then for unic,glyph in table.sortedhash(descriptions) do local name=glyph.name @@ -9696,7 +9643,7 @@ function readers.loadfont(filename,n) end function readers.getinfo(filename,specification) local subfont=nil - local platformname=false + local platformnames=false local rawfamilynames=false if type(specification)=="table" then subfont=tonumber(specification.subfont) @@ -14220,6 +14167,81 @@ local function stripredundant(fontdata) end end end +function readers.getcomponents(fontdata) + local resources=fontdata.resources + local descriptions=fontdata.descriptions + if resources then + local sequences=resources.sequences + if sequences then + local collected={} + for i=1,#sequences do + local sequence=sequences[i] + if sequence.type=="gsub_ligature" then + local steps=sequence.steps + if steps then + local l={} + local function traverse(p,k,v) + if k=="ligature" then + collected[v]={ unpack(l) } + else + insert(l,k) + for k,vv in next,v do + traverse(p,k,vv) + end + remove(l) + end + end + for i=1,#steps do + local coverage=steps[i].coverage + if coverage then + for k,v in next,coverage do + traverse(k,k,v) + end + end + end + end + end + end + if next(collected) then + while true do + local done=false + for k,v in next,collected do + for i=1,#v do + local vi=v[i] + if vi==k then + collected[k]=nil + else + local c=collected[vi] + if c then + done=true + local t={} + local n=i-1 + for j=1,n do + t[j]=t[j] + end + for j=1,#c do + n=n+1 + t[n]=c[j] + end + for j=i+1,#v do + n=n+1 + t[n]=t[j] + end + collected[k]=t + break + end + end + end + end + if not done then + break + end + end + return collected + end + end + end +end function readers.rehash(fontdata,hashmethod) if not (fontdata and fontdata.glyphs) then return |