summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua227
1 files changed, 155 insertions, 72 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua
index 3120f45135b..b8a21fc937b 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/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 : 08/11/19 20:03:46
+-- merge date : 10/29/19 15:00:00
do -- begin closure to overcome local limits and interference
@@ -20,6 +20,9 @@ if LUAVERSION<5.2 and jit then
MINORVERSION=2
LUAVERSION=5.2
end
+if lua and lua.openfile then
+ io.open=lua.openfile
+end
if not lpeg then
lpeg=require("lpeg")
end
@@ -296,7 +299,7 @@ patterns.propername=(uppercase+lowercase+underscore)*(uppercase+lowercase+unders
patterns.somecontent=(anything-newline-space)^1
patterns.beginline=#(1-newline)
patterns.longtostring=Cs(whitespace^0/""*((patterns.quoted+nonwhitespace^1+whitespace^1/""*(endofstring+Cc(" ")))^0))
-function anywhere(pattern)
+local function anywhere(pattern)
return (1-P(pattern))^0*P(pattern)
end
lpeg.anywhere=anywhere
@@ -3433,7 +3436,7 @@ local environment={
stripzero=patterns.stripzero,
stripzeros=patterns.stripzeros,
escapedquotes=string.escapedquotes,
- FORMAT=string.f9,
+ FORMAT=string.f6,
}
local arguments={ "a1" }
setmetatable(arguments,{ __index=function(t,k)
@@ -3641,12 +3644,25 @@ local format_n=function()
n=n+1
return format("((a%s %% 1 == 0) and format('%%i',a%s) or tostring(a%s))",n,n,n)
end
-local format_N=function(f)
- n=n+1
- if not f or f=="" then
- f=".9"
- end
- return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n)
+local format_N if environment.FORMAT then
+ format_N=function(f)
+ n=n+1
+ if not f or f=="" then
+ return format("FORMAT(a%s,'%%.9f')",n)
+ elseif f==".6" then
+ return format("FORMAT(a%s)",n)
+ else
+ return format("FORMAT(a%s,'%%%sf')",n,f)
+ end
+ end
+else
+ format_N=function(f)
+ n=n+1
+ if not f or f=="" then
+ f=".9"
+ end
+ return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n)
+ end
end
local format_a=function(f)
n=n+1
@@ -4865,6 +4881,7 @@ nuts.getchar=direct.getchar
nuts.getcomponents=direct.getcomponents
nuts.getdirection=direct.getdirection
nuts.getdisc=direct.getdisc
+nuts.getreplace=direct.getreplace
nuts.getfield=direct.getfield
nuts.getfont=direct.getfont
nuts.getid=direct.getid
@@ -4881,6 +4898,7 @@ nuts.setchar=direct.setchar
nuts.setcomponents=direct.setcomponents
nuts.setdirection=direct.setdirection
nuts.setdisc=direct.setdisc
+nuts.setreplace=direct.setreplace
nuts.setfield=setfield
nuts.setkern=direct.setkern
nuts.setlink=direct.setlink
@@ -4998,6 +5016,17 @@ do
node=nuts.traverse(dummy),
}
end
+if not nuts.setreplace then
+ local getdisc=nuts.getdisc
+ local setfield=nuts.setfield
+ function nuts.getreplace(n)
+ local _,_,h,_,_,t=getdisc(n,true)
+ return h,t
+ end
+ function nuts.setreplace(n,h)
+ setfield(n,"replace",h)
+ end
+end
end -- closure
@@ -8989,7 +9018,8 @@ function constructors.scale(tfmdata,specification)
local units=parameters.units or 1000
targetproperties.language=properties.language or "dflt"
targetproperties.script=properties.script or "dflt"
- targetproperties.mode=properties.mode or "base"
+ targetproperties.mode=properties.mode or "base"
+ targetproperties.method=properties.method
local askedscaledpoints=scaledpoints
local scaledpoints,delta=constructors.calculatescale(tfmdata,scaledpoints,nil,specification)
local hdelta=delta
@@ -19773,6 +19803,8 @@ function readers.cpal(f,fontdata,specification)
fontdata.colorpalettes=palettes
end
end
+local compress=gzip and gzip.compress
+local compressed=compress and gzip.compressed
function readers.svg(f,fontdata,specification)
local tableoffset=gotodatatable(f,fontdata,"svg",specification.glyphs)
if tableoffset then
@@ -19794,10 +19826,14 @@ function readers.svg(f,fontdata,specification)
for i=1,nofentries do
local entry=entries[i]
setposition(f,entry.offset)
+ local data=readstring(f,entry.length)
+ if compressed and not compressed(data) then
+ data=compress(data)
+ end
entries[i]={
first=entry.first,
last=entry.last,
- data=readstring(f,entry.length)
+ data=data
}
end
fontdata.svgshapes=entries
@@ -21059,6 +21095,9 @@ local function checklookups(fontdata,missing,nofmissing)
end
end
end
+local firstprivate=fonts.privateoffsets and fonts.privateoffsets.textbase or 0xF0000
+local puafirst=0xE000
+local pualast=0xF8FF
local function unifymissing(fontdata)
if not fonts.mappings then
require("font-map")
@@ -21069,18 +21108,19 @@ local function unifymissing(fontdata)
resources.unicodes=unicodes
for unicode,d in next,fontdata.descriptions do
if unicode<privateoffset then
- local name=d.name
- if name then
- unicodes[name]=unicode
+ if unicode>=puafirst and unicode<=pualast then
+ else
+ local name=d.name
+ if name then
+ unicodes[name]=unicode
+ end
end
+ else
end
end
fonts.mappings.addtounicode(fontdata,fontdata.filename,checklookups)
resources.unicodes=nil
end
-local firstprivate=fonts.privateoffsets and fonts.privateoffsets.textbase or 0xF0000
-local puafirst=0xE000
-local pualast=0xF8FF
local function unifyglyphs(fontdata,usenames)
local private=fontdata.private or privateoffset
local glyphs=fontdata.glyphs
@@ -23049,11 +23089,12 @@ local trace_defining=false registertracker("fonts.defining",function(v) trace_d
local report_otf=logs.reporter("fonts","otf loading")
local fonts=fonts
local otf=fonts.handlers.otf
-otf.version=3.109
+otf.version=3.110
otf.cache=containers.define("fonts","otl",otf.version,true)
otf.svgcache=containers.define("fonts","svg",otf.version,true)
otf.pngcache=containers.define("fonts","png",otf.version,true)
otf.pdfcache=containers.define("fonts","pdf",otf.version,true)
+otf.mpscache=containers.define("fonts","mps",otf.version,true)
otf.svgenabled=false
otf.pngenabled=false
local otfreaders=otf.readers
@@ -26076,7 +26117,6 @@ registertracker("otf.actions","otf.substitutions","otf.positions")
registertracker("otf.sample","otf.steps","otf.substitutions","otf.positions","otf.analyzing")
registertracker("otf.sample.silent","otf.steps=silent","otf.substitutions","otf.positions","otf.analyzing")
local nuts=nodes.nuts
-local getfield=nuts.getfield
local getnext=nuts.getnext
local setnext=nuts.setnext
local getprev=nuts.getprev
@@ -26092,6 +26132,7 @@ local getchar=nuts.getchar
local setchar=nuts.setchar
local getdisc=nuts.getdisc
local setdisc=nuts.setdisc
+local getreplace=nuts.getreplace
local setlink=nuts.setlink
local getcomponents=nuts.getcomponents
local setcomponents=nuts.setcomponents
@@ -27670,7 +27711,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
if keepdisc then
keepdisc=false
lookaheaddisc=current
- local replace=getfield(current,"replace")
+ local replace=getreplace(current)
if not replace then
sweepoverflow=true
sweepnode=current
@@ -27742,7 +27783,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
if notmatchpre[current]~=notmatchreplace[current] then
lookaheaddisc=current
end
- local replace=getfield(current,"replace")
+ local replace=getreplace(current)
while replace and i<s do
if getid(replace)==glyph_code then
i=i+1
@@ -27786,7 +27827,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
if notmatchpost[current]~=notmatchreplace[current] then
backtrackdisc=current
end
- local replace=getfield(current,"replace")
+ local replace=getreplace(current)
while replace and i>1 do
if getid(replace)==glyph_code then
i=i-1
@@ -28750,7 +28791,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
end
while getid(s)==disc_code do
ss=getnext(s)
- s=getfield(s,"replace")
+ s=getreplace(s)
if not s then
s=ss
ss=nil
@@ -28777,7 +28818,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
end
while getid(s)==disc_code do
ss=getnext(s)
- s=getfield(s,"replace")
+ s=getreplace(s)
if not s then
s=ss
ss=nil
@@ -28904,7 +28945,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
end
while getid(s)==disc_code do
ss=getnext(s)
- s=getfield(s,"replace")
+ s=getreplace(s)
if not s then
s=ss
ss=nil
@@ -28931,7 +28972,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
end
while getid(s)==disc_code do
ss=getnext(s)
- s=getfield(s,"replace")
+ s=getreplace(s)
if not s then
s=ss
ss=nil
@@ -30708,7 +30749,7 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
local cp=getprev(current)
local cnsn=getnext(cns)
setlink(cp,n)
- setlink(cns,current)
+ setlink(cns,current)
setlink(c,cnsn)
if c==stop then
stop=cp
@@ -32071,9 +32112,13 @@ if not modules then modules={} end modules ['font-ocl']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
+if CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 then
+ return
+end
local tostring,tonumber,next=tostring,tonumber,next
local round,max=math.round,math.round
-local sortedkeys,sortedhash=table.sortedkeys,table.sortedhash
+local gsub,find=string.gsub,string.find
+local sortedkeys,sortedhash,concat=table.sortedkeys,table.sortedhash,table.concat
local setmetatableindex=table.setmetatableindex
local formatters=string.formatters
local tounicode=fonts.mappings.tounicode
@@ -32083,6 +32128,7 @@ local rightcommand=helpers.commands.right
local leftcommand=helpers.commands.left
local downcommand=helpers.commands.down
local otf=fonts.handlers.otf
+local otfregister=otf.features.register
local f_color=formatters["%.3f %.3f %.3f rg"]
local f_gray=formatters["%.3f g"]
if context then
@@ -32139,7 +32185,7 @@ end
local start={ "pdf","mode","font" }
local push={ "pdf","page","q" }
local pop={ "pdf","page","Q" }
-local function initialize(tfmdata,kind,value)
+local function initializeoverlay(tfmdata,kind,value)
if value then
local resources=tfmdata.resources
local palettes=resources.colorpalettes
@@ -32181,52 +32227,39 @@ local function initialize(tfmdata,kind,value)
local s=#colorlist
local goback=w~=0 and leftcommand[w] or nil
local t={
- start,
- not u and actualb or { "pdf","page",(getactualtext(tounicode(u))) }
+ not u and actualb or { "pdf","page",(getactualtext(tounicode(u))) },
+ push,
}
local n=2
local l=nil
- local f=false
for i=1,s do
local entry=colorlist[i]
local v=colorvalues[entry.class] or default
if v and l~=v then
- if f then
- n=n+1 t[n]=pop
- end
- n=n+1 t[n]=push
- f=true
n=n+1 t[n]=v
l=v
- else
- if f then
- n=n+1 t[n]=pop
- end
- f=false
- l=nil
end
n=n+1 t[n]=charcommand[entry.slot]
if s>1 and i<s and goback then
n=n+1 t[n]=goback
end
end
- if f then
- n=n+1 t[n]=pop
- end
+ n=n+1 t[n]=pop
n=n+1 t[n]=actuale
character.commands=t
end
end
end
+ return true
end
end
end
-fonts.handlers.otf.features.register {
+otfregister {
name="colr",
description="color glyphs",
manipulators={
- base=initialize,
- node=initialize,
+ base=initializeoverlay,
+ node=initializeoverlay,
}
}
do
@@ -32277,14 +32310,20 @@ local function pdftovirtual(tfmdata,pdfshapes,kind)
local data=nil
local dx=nil
local dy=nil
+ local scale=1
if typ=="table" then
data=pdf.data
- dx=pdf.dx or 0
- dy=pdf.dy or 0
+ dx=pdf.x or pdf.dx or 0
+ dy=pdf.y or pdf.dy or 0
+ scale=pdf.scale or 1
elseif typ=="string" then
data=pdf
dx=0
dy=0
+ elseif typ=="number" then
+ data=pdf
+ dx=0
+ dy=0
end
if data then
local bt=unicode and getactualtext(unicode)
@@ -32293,9 +32332,9 @@ local function pdftovirtual(tfmdata,pdfshapes,kind)
local dp=character.depth or 0
character.commands={
not unicode and actualb or { "pdf","page",(getactualtext(unicode)) },
- downcommand[dp+dy*hfactor],
- rightcommand[dx*hfactor],
- vfimage(wd,ht,dp,data,name),
+ downcommand [dp+dy*hfactor],
+ rightcommand[ dx*hfactor],
+ vfimage(scale*wd,ht,dp,data,pdfshapes.filename or ""),
actuale,
}
character[kind]=true
@@ -32329,24 +32368,27 @@ do
name="otfsvg",
program="inkscape",
method="pipeto",
- template="--shell > temp-otf-svg-shape.log",
+ template="--export-area-drawing --shell > temp-otf-svg-shape.log",
reporter=report_svg,
}
if not runner then
runner=function()
- return io.open("inkscape --shell > temp-otf-svg-shape.log","w")
+ return io.popen("inkscape --export-area-drawing --shell > temp-otf-svg-shape.log","w")
end
end
- function otfsvg.topdf(svgshapes)
+ function otfsvg.topdf(svgshapes,tfmdata)
local pdfshapes={}
local inkscape=runner()
if inkscape then
+ local indices=fonts.getindices(tfmdata)
+ local descriptions=tfmdata.descriptions
local nofshapes=#svgshapes
local f_svgfile=formatters["temp-otf-svg-shape-%i.svg"]
local f_pdffile=formatters["temp-otf-svg-shape-%i.pdf"]
local f_convert=formatters["%s --export-pdf=%s\n"]
local filterglyph=otfsvg.filterglyph
local nofdone=0
+ local processed={}
report_svg("processing %i svg containers",nofshapes)
statistics.starttiming()
for i=1,nofshapes do
@@ -32358,24 +32400,51 @@ do
local pdffile=f_pdffile(index)
savedata(svgfile,data)
inkscape:write(f_convert(svgfile,pdffile))
- pdfshapes[index]=true
+ processed[index]=true
nofdone=nofdone+1
- if nofdone%100==0 then
- report_svg("%i shapes processed",nofdone)
+ if nofdone%25==0 then
+ report_svg("%i shapes submitted",nofdone)
end
end
end
end
+ if nofdone%25~=0 then
+ report_svg("%i shapes submitted",nofdone)
+ end
+ report_svg("processing can be going on for a while")
inkscape:write("quit\n")
inkscape:close()
report_svg("processing %i pdf results",nofshapes)
- for index in next,pdfshapes do
+ for index in next,processed do
local svgfile=f_svgfile(index)
local pdffile=f_pdffile(index)
- pdfshapes[index]=loaddata(pdffile)
+ local pdfdata=loaddata(pdffile)
+ if pdfdata and pdfdata~="" then
+ pdfshapes[index]={
+ data=pdfdata,
+ }
+ end
remove(svgfile)
remove(pdffile)
end
+ local characters=tfmdata.characters
+ for k,v in next,characters do
+ local d=descriptions[k]
+ local i=d.index
+ if i then
+ local p=pdfshapes[i]
+ if p then
+ local w=d.width
+ local l=d.boundingbox[1]
+ local r=d.boundingbox[3]
+ p.scale=(r-l)/w
+ p.x=l
+ end
+ end
+ end
+ if not next(pdfshapes) then
+ report_svg("there are no converted shapes, fix your setup")
+ end
statistics.stoptiming()
if statistics.elapsedseconds then
report_svg("svg conversion time %s",statistics.elapsedseconds() or "-")
@@ -32394,19 +32463,20 @@ local function initializesvg(tfmdata,kind,value)
end
local pdffile=containers.read(otf.pdfcache,hash)
local pdfshapes=pdffile and pdffile.pdfshapes
- if not pdfshapes or pdffile.timestamp~=timestamp then
+ if not pdfshapes or pdffile.timestamp~=timestamp or not next(pdfshapes) then
local svgfile=containers.read(otf.svgcache,hash)
local svgshapes=svgfile and svgfile.svgshapes
- pdfshapes=svgshapes and otfsvg.topdf(svgshapes) or {}
+ pdfshapes=svgshapes and otfsvg.topdf(svgshapes,tfmdata,otf.pdfcache.writable,hash) or {}
containers.write(otf.pdfcache,hash,{
pdfshapes=pdfshapes,
timestamp=timestamp,
})
end
pdftovirtual(tfmdata,pdfshapes,"svg")
+ return true
end
end
-fonts.handlers.otf.features.register {
+otfregister {
name="svg",
description="svg glyphs",
manipulators={
@@ -32489,9 +32559,10 @@ local function initializepng(tfmdata,kind,value)
})
end
pdftovirtual(tfmdata,pdfshapes,"png")
+ return true
end
end
-fonts.handlers.otf.features.register {
+otfregister {
name="sbix",
description="sbix glyphs",
manipulators={
@@ -32499,7 +32570,7 @@ fonts.handlers.otf.features.register {
node=initializepng,
}
}
-fonts.handlers.otf.features.register {
+otfregister {
name="cblc",
description="cblc glyphs",
manipulators={
@@ -32507,6 +32578,11 @@ fonts.handlers.otf.features.register {
node=initializepng,
}
}
+if context then
+
+--removed
+
+end
end -- closure
@@ -32530,9 +32606,10 @@ local fonts=fonts
local otf=fonts.handlers.otf
local registerotffeature=otf.features.register
local setmetatableindex=table.setmetatableindex
-local checkmerge=fonts.helpers.checkmerge
-local checkflags=fonts.helpers.checkflags
-local checksteps=fonts.helpers.checksteps
+local fonthelpers=fonts.helpers
+local checkmerge=fonthelpers.checkmerge
+local checkflags=fonthelpers.checkflags
+local checksteps=fonthelpers.checksteps
local normalized={
substitution="substitution",
single="substitution",
@@ -32654,6 +32731,7 @@ local function addfeature(data,feature,specifications)
local done=0
local skip=0
local aglunicodes=false
+ local privateslot=fonthelpers.privateslot
local specifications=validspecification(specifications,feature)
if not specifications then
return
@@ -32676,6 +32754,12 @@ local function addfeature(data,feature,specifications)
return u
end
end
+ if privateslot then
+ u=privateslot(code)
+ if u then
+ return u
+ end
+ end
local u=lpegmatch(p,code)
if u then
return u
@@ -32705,7 +32789,7 @@ local function addfeature(data,feature,specifications)
replacement=replacement[1]
end
replacement=tounicode(replacement)
- if replacement and descriptions[replacement] then
+ if replacement and (nocheck or descriptions[replacement]) then
cover(coverage,unicode,replacement)
done=done+1
else
@@ -33075,7 +33159,6 @@ local function addfeature(data,feature,specifications)
local featuretype=normalized[specification.type or "substitution"] or "substitution"
local featureflags=specification.flags or noflags
local nocheck=specification.nocheck
- local futuresteps=specification.futuresteps
local featureorder=specification.order or { feature }
local featurechain=(featuretype=="chainsubstitution" or featuretype=="chainposition") and 1 or 0
local nofsteps=0