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.lua1002
1 files changed, 542 insertions, 460 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-reference.lua
index d470094fcf1..8a940cc22ba 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 : 02/14/19 16:57:24
+-- merge date : 05/18/19 10:42:24
do -- begin closure to overcome local limits and interference
@@ -119,8 +119,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
end -- closure
@@ -1045,7 +1044,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1055,7 +1054,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1068,7 +1068,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -1099,27 +1100,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
for key in next,tab do
s=s+1
srt[s]=key
- if category==3 then
- elseif category==1 then
- if type(key)~="string" then
- category=3
- end
- elseif category==2 then
- if type(key)~="number" then
- category=3
- end
- else
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -1136,7 +1140,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -1153,7 +1158,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -1170,7 +1176,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -1246,7 +1253,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -1275,7 +1284,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -1307,7 +1317,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -1354,7 +1366,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -1455,7 +1468,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -1714,7 +1728,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -1728,13 +1743,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -1836,8 +1853,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -1937,7 +1958,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2050,7 +2072,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -2652,40 +2676,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -3045,7 +3074,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -3384,8 +3412,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -3472,7 +3500,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -3828,9 +3856,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -3862,6 +3890,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- closure
@@ -4074,6 +4123,32 @@ if bit32 then
local b=char(n%256)
f:write(b,a)
end
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
else
local floor=math.floor
function files.writecardinal2(f,n)
@@ -4082,16 +4157,32 @@ else
local b=char(n%256)
f:write(b,a)
end
-end
-function files.writecardinal4(f,n)
- local a=char(n%256)
- n=rshift(n,8)
- local b=char(n%256)
- n=rshift(n,8)
- local c=char(n%256)
- n=rshift(n,8)
- local d=char(n%256)
- f:write(d,c,b,a)
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
end
function files.writestring(f,s)
f:write(char(byte(s,1,#s)))
@@ -4104,10 +4195,18 @@ if fio and fio.readcardinal1 then
files.readcardinal2=fio.readcardinal2
files.readcardinal3=fio.readcardinal3
files.readcardinal4=fio.readcardinal4
+ files.readcardinal1le=fio.readcardinal1le or files.readcardinal1le
+ files.readcardinal2le=fio.readcardinal2le or files.readcardinal2le
+ files.readcardinal3le=fio.readcardinal3le or files.readcardinal3le
+ files.readcardinal4le=fio.readcardinal4le or files.readcardinal4le
files.readinteger1=fio.readinteger1
files.readinteger2=fio.readinteger2
files.readinteger3=fio.readinteger3
files.readinteger4=fio.readinteger4
+ files.readinteger1le=fio.readinteger1le or files.readinteger1le
+ files.readinteger2le=fio.readinteger2le or files.readinteger2le
+ files.readinteger3le=fio.readinteger3le or files.readinteger3le
+ files.readinteger4le=fio.readinteger4le or files.readinteger4le
files.readfixed2=fio.readfixed2
files.readfixed4=fio.readfixed4
files.read2dot14=fio.read2dot14
@@ -4128,6 +4227,24 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.writecardinal1 then
+ files.writecardinal1=fio.writecardinal1
+ files.writecardinal2=fio.writecardinal2
+ files.writecardinal3=fio.writecardinal3
+ files.writecardinal4=fio.writecardinal4
+ files.writecardinal1le=fio.writecardinal1le
+ files.writecardinal2le=fio.writecardinal2le
+ files.writecardinal3le=fio.writecardinal3le
+ files.writecardinal4le=fio.writecardinal4le
+ files.writeinteger1=fio.writeinteger1 or fio.writecardinal1
+ files.writeinteger2=fio.writeinteger2 or fio.writecardinal2
+ files.writeinteger3=fio.writeinteger3 or fio.writecardinal3
+ files.writeinteger4=fio.writeinteger4 or fio.writecardinal4
+ files.writeinteger1le=files.writeinteger1le or fio.writecardinal1le
+ files.writeinteger2le=files.writeinteger2le or fio.writecardinal2le
+ files.writeinteger3le=files.writeinteger3le or fio.writecardinal3le
+ files.writeinteger4le=files.writeinteger4le or fio.writecardinal4le
+end
if fio and fio.readcardinaltable then
files.readcardinaltable=fio.readcardinaltable
files.readintegertable=fio.readintegertable
@@ -4712,67 +4829,8 @@ end
nodes.nodecodes=nodecodes
nodes.glyphcodes=glyphcodes
nodes.disccodes=disccodes
-local flush_node=node.flush_node
-local remove_node=node.remove
-local traverse_id=node.traverse_id
nodes.handlers.protectglyphs=node.protect_glyphs
-nodes.handlers.unprotectglyphs=node.unprotect_glyphs
-function nodes.remove(head,current,free_too)
- local t=current
- head,current=remove_node(head,current)
- if t then
- if free_too then
- flush_node(t)
- t=nil
- else
- t.next,t.prev=nil,nil
- end
- end
- return head,current,t
-end
-function nodes.delete(head,current)
- return nodes.remove(head,current,true)
-end
-local getfield=node.getfield
-local setfield=node.setfield
-nodes.getfield=getfield
-nodes.setfield=setfield
-nodes.getattr=getfield
-nodes.setattr=setfield
-nodes.tostring=node.tostring or tostring
-nodes.copy=node.copy
-nodes.copy_node=node.copy
-nodes.copy_list=node.copy_list
-nodes.delete=node.delete
-nodes.dimensions=node.dimensions
-nodes.end_of_math=node.end_of_math
-nodes.flush_list=node.flush_list
-nodes.flush_node=node.flush_node
-nodes.flush=node.flush_node
-nodes.free=node.free
-nodes.insert_after=node.insert_after
-nodes.insert_before=node.insert_before
-nodes.hpack=node.hpack
-nodes.new=node.new
-nodes.tail=node.tail
-nodes.traverse=node.traverse
-nodes.traverse_id=node.traverse_id
-nodes.slide=node.slide
-nodes.vpack=node.vpack
-nodes.first_glyph=node.first_glyph
-nodes.has_glyph=node.has_glyph or node.first_glyph
-nodes.current_attr=node.current_attr
-nodes.has_field=node.has_field
-nodes.last_node=node.last_node
-nodes.usedlist=node.usedlist
-nodes.protrusion_skippable=node.protrusion_skippable
-nodes.write=node.write
-nodes.has_attribute=node.has_attribute
-nodes.set_attribute=node.set_attribute
-nodes.unset_attribute=node.unset_attribute
-nodes.protect_glyphs=node.protect_glyphs
-nodes.unprotect_glyphs=node.unprotect_glyphs
-nodes.mlist_to_hlist=node.mlist_to_hlist
+nodes.handlers.unprotectglyphs=node.unprotect_glyphs
local direct=node.direct
local nuts={}
nodes.nuts=nuts
@@ -4802,7 +4860,6 @@ nuts.setattr=direct.setfield
nuts.setboth=direct.setboth
nuts.setchar=direct.setchar
nuts.setcomponents=direct.setcomponents
-nuts.setdir=direct.setdir
nuts.setdirection=direct.setdirection
nuts.setdisc=direct.setdisc
nuts.setfield=setfield
@@ -4815,8 +4872,8 @@ nuts.setprev=direct.setprev
nuts.setsplit=direct.setsplit
nuts.setsubtype=direct.setsubtype
nuts.setwidth=direct.setwidth
-nuts.is_char=direct.is_char
-nuts.is_glyph=direct.is_glyph
+nuts.getglyphdata=nuts.getattr
+nuts.setglyphdata=nuts.setattr
nuts.ischar=direct.is_char
nuts.isglyph=direct.is_glyph
nuts.copy=direct.copy
@@ -4840,20 +4897,6 @@ nuts.traverse=direct.traverse
nuts.traverse_char=direct.traverse_char
nuts.traverse_glyph=direct.traverse_glyph
nuts.traverse_id=direct.traverse_id
-if not nuts.getdirection then
- local getdir=direct.getdir
- function nuts.getdirection(n)
- local d=getdir(n)
- if d=="TLT" then return 0
- elseif d=="TRT" then return 1
- elseif d=="+TLT" then return 0,false
- elseif d=="+TRT" then return 1,false
- elseif d=="-TLT" then return 0,true
- elseif d=="-TRT" then return 1,true
- else return 0
- end
- end
-end
local propertydata=direct.get_properties_table()
nodes.properties={ data=propertydata }
if direct.set_properties_mode then
@@ -8637,7 +8680,6 @@ function constructors.scale(tfmdata,specification)
local hasitalics=properties.hasitalics
local autoitalicamount=properties.autoitalicamount
local stackmath=not properties.nostackmath
- local nonames=properties.noglyphnames
local haskerns=properties.haskerns or properties.mode=="base"
local hasligatures=properties.hasligatures or properties.mode=="base"
local realdimensions=properties.realdimensions
@@ -8744,6 +8786,7 @@ function constructors.scale(tfmdata,specification)
local width=description.width
local height=description.height
local depth=description.depth
+ local isunicode=description.unicode
if realdimensions then
if not height or height==0 then
local bb=description.boundingbox
@@ -8768,16 +8811,16 @@ function constructors.scale(tfmdata,specification)
if height then height=vdelta*height else height=scaledheight end
if depth and depth~=0 then
depth=delta*depth
- if nonames then
+ if isunicode then
chr={
index=index,
height=height,
depth=depth,
width=width,
+ unicode=isunicode,
}
else
chr={
- name=description.name,
index=index,
height=height,
depth=depth,
@@ -8785,33 +8828,23 @@ function constructors.scale(tfmdata,specification)
}
end
else
- if nonames then
+ if isunicode then
chr={
index=index,
height=height,
width=width,
+ unicode=isunicode,
}
else
chr={
- name=description.name,
index=index,
height=height,
width=width,
}
end
end
- local isunicode=description.unicode
if addtounicode then
- if isunicode then
- chr.unicode=isunicode
- chr.tounicode=tounicode(isunicode)
- else
- chr.tounicode=unknowncode
- end
- else
- if isunicode then
- chr.unicode=isunicode
- end
+ chr.tounicode=isunicode and tounicode(isunicode) or unknowncode
end
if hasquality then
local ve=character.expansion_factor
@@ -8881,7 +8914,10 @@ function constructors.scale(tfmdata,specification)
if stackmath then
local mk=character.mathkerns
if mk then
- local tr,tl,br,bl=mk.topright,mk.topleft,mk.bottomright,mk.bottomleft
+ local tr=mk.topright
+ local tl=mk.topleft
+ local br=mk.bottomright
+ local bl=mk.bottomleft
chr.mathkern={
top_right=tr and mathkerns(tr,vdelta) or nil,
top_left=tl and mathkerns(tl,vdelta) or nil,
@@ -9062,11 +9098,11 @@ function constructors.finalize(tfmdata)
if not properties.virtualized then
properties.virtualized=tfmdata.type=="virtual"
end
- properties.fontname=tfmdata.fontname
- properties.filename=tfmdata.filename
- properties.fullname=tfmdata.fullname
- properties.name=tfmdata.name
- properties.psname=tfmdata.psname
+ properties.fontname=properties.fontname or tfmdata.fontname
+ properties.filename=properties.filename or tfmdata.filename
+ properties.fullname=properties.fullname or tfmdata.fullname
+ properties.name=properties.name or tfmdata.name
+ properties.psname=properties.psname or tfmdata.psname
properties.encodingbytes=tfmdata.encodingbytes or 1
properties.embedding=tfmdata.embedding or "subset"
properties.tounicode=tfmdata.tounicode or 1
@@ -9167,7 +9203,9 @@ hashmethods.normal=function(list)
end
end
function constructors.hashinstance(specification,force)
- local hash,size,fallbacks=specification.hash,specification.size,specification.fallbacks
+ local hash=specification.hash
+ local size=specification.size
+ local fallbacks=specification.fallbacks
if force or not hash then
hash=constructors.hashfeatures(specification)
specification.hash=hash
@@ -9534,7 +9572,8 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
end
end
function constructors.collectprocessors(what,tfmdata,features,trace,report)
- local processes,nofprocesses={},0
+ local processes={}
+ local nofprocesses=0
if features and next(features) then
local properties=tfmdata.properties
local whathandler=handlers[what]
@@ -10071,7 +10110,8 @@ function mappings.addtounicode(data,filename,checklookups,forceligatures)
glyph.unicode=unicode
end
else
- local t,n={},0
+ local t={}
+ local n=0
for l=1,nsplit do
local base=split[l]
local u=unicodes[base] or unicodevector[base] or contextvector[name]
@@ -10410,7 +10450,6 @@ local P,R,S,C,Cs,Cc,Ct,Carg,Cmt=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg
local lpegmatch=lpeg.match
local rshift=bit32.rshift
local setmetatableindex=table.setmetatableindex
-local formatters=string.formatters
local sortedkeys=table.sortedkeys
local sortedhash=table.sortedhash
local stripstring=string.nospaces
@@ -14945,7 +14984,8 @@ end
end
end
local function setbias(globals,locals)
- local g,l=#globals,#locals
+ local g=#globals
+ local l=#locals
return
((g<1240 and 107) or (g<33900 and 1131) or 32768)+1,
((l<1240 and 107) or (l<33900 and 1131) or 32768)+1
@@ -15351,8 +15391,8 @@ function readers.cff(f,fontdata,specification)
if private then
local data=private.data
if type(data)=="table" then
- cffinfo.defaultwidth=data.defaultwidth or cffinfo.defaultwidth
- cffinfo.nominalwidth=data.nominalwidth or cffinfo.nominalwidth
+ cffinfo.defaultwidth=data.defaultwidthx or cffinfo.defaultwidth
+ cffinfo.nominalwidth=data.nominalwidthx or cffinfo.nominalwidth
cffinfo.bluevalues=data.bluevalues
cffinfo.otherblues=data.otherblues
cffinfo.familyblues=data.familyblues
@@ -15681,7 +15721,8 @@ local function contours2outlines_normal(glyphs,shapes)
local nofsegments=0
glyph.segments=segments
if nofcontours>0 then
- local px,py=0,0
+ local px=0
+ local py=0
local first=1
for i=1,nofcontours do
local last=contours[i]
@@ -15708,15 +15749,20 @@ local function contours2outlines_normal(glyphs,shapes)
end
control_pt=first_pt
end
- local x,y=first_pt[1],first_pt[2]
+ local x=first_pt[1]
+ local y=first_pt[2]
if not done then
- xmin,ymin,xmax,ymax=x,y,x,y
+ xmin=x
+ ymin=y
+ xmax=x
+ ymax=y
done=true
end
nofsegments=nofsegments+1
segments[nofsegments]={ x,y,"m" }
if not quadratic then
- px,py=x,y
+ px=x
+ py=y
end
local previous_pt=first_pt
for i=first,last do
@@ -15735,8 +15781,10 @@ local function contours2outlines_normal(glyphs,shapes)
control_pt=current_pt
end
elseif current_on then
- local x1,y1=control_pt[1],control_pt[2]
- local x2,y2=current_pt[1],current_pt[2]
+ local x1=control_pt[1]
+ local y1=control_pt[2]
+ local x2=current_pt[1]
+ local y2=current_pt[2]
nofsegments=nofsegments+1
if quadratic then
segments[nofsegments]={ x1,y1,x2,y2,"q" }
@@ -15746,8 +15794,10 @@ local function contours2outlines_normal(glyphs,shapes)
end
control_pt=false
else
- local x2,y2=(previous_pt[1]+current_pt[1])/2,(previous_pt[2]+current_pt[2])/2
- local x1,y1=control_pt[1],control_pt[2]
+ local x2=(previous_pt[1]+current_pt[1])/2
+ local y2=(previous_pt[2]+current_pt[2])/2
+ local x1=control_pt[1]
+ local y1=control_pt[2]
nofsegments=nofsegments+1
if quadratic then
segments[nofsegments]={ x1,y1,x2,y2,"q" }
@@ -15762,14 +15812,17 @@ local function contours2outlines_normal(glyphs,shapes)
if first_pt==last_pt then
else
nofsegments=nofsegments+1
- local x2,y2=first_pt[1],first_pt[2]
+ local x2=first_pt[1]
+ local y2=first_pt[2]
if not control_pt then
segments[nofsegments]={ x2,y2,"l" }
elseif quadratic then
- local x1,y1=control_pt[1],control_pt[2]
+ local x1=control_pt[1]
+ local y1=control_pt[2]
segments[nofsegments]={ x1,y1,x2,y2,"q" }
else
- local x1,y1=control_pt[1],control_pt[2]
+ local x1=control_pt[1]
+ local y1=control_pt[2]
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2)
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" }
end
@@ -15828,7 +15881,8 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
end
control_pt=first_pt
end
- local x,y=first_pt[1],first_pt[2]
+ local x=first_pt[1]
+ local y=first_pt[2]
if not done then
xmin,ymin,xmax,ymax=x,y,x,y
done=true
@@ -15841,7 +15895,8 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
segments[nofsegments]={ x,y,"m" }
end
if not quadratic then
- px,py=x,y
+ px=x
+ py=y
end
local previous_pt=first_pt
for i=first,last do
@@ -15850,7 +15905,8 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
local previous_on=previous_pt[3]
if previous_on then
if current_on then
- local x,y=current_pt[1],current_pt[2]
+ local x=current_pt[1]
+ local y=current_pt[2]
if x<xmin then xmin=x elseif x>xmax then xmax=x end
if y<ymin then ymin=y elseif y>ymax then ymax=y end
if keepcurve then
@@ -15858,14 +15914,17 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
segments[nofsegments]={ x,y,"l" }
end
if not quadratic then
- px,py=x,y
+ px=x
+ py=y
end
else
control_pt=current_pt
end
elseif current_on then
- local x1,y1=control_pt[1],control_pt[2]
- local x2,y2=current_pt[1],current_pt[2]
+ local x1=control_pt[1]
+ local y1=control_pt[2]
+ local x2=current_pt[1]
+ local y2=current_pt[2]
if quadratic then
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end
@@ -15888,8 +15947,10 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
end
control_pt=false
else
- local x2,y2=(previous_pt[1]+current_pt[1])/2,(previous_pt[2]+current_pt[2])/2
- local x1,y1=control_pt[1],control_pt[2]
+ local x2=(previous_pt[1]+current_pt[1])/2
+ local y2=(previous_pt[2]+current_pt[2])/2
+ local x1=control_pt[1]
+ local y1=control_pt[2]
if quadratic then
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end
@@ -15921,8 +15982,10 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
segments[nofsegments]={ first_pt[1],first_pt[2],"l" }
end
else
- local x1,y1=control_pt[1],control_pt[2]
- local x2,y2=first_pt[1],first_pt[2]
+ local x1=control_pt[1]
+ local y1=control_pt[2]
+ local x2=first_pt[1]
+ local y2=first_pt[2]
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end
if quadratic then
@@ -17818,6 +17881,7 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
local sets=readarray(f)
sets=readpairsets(f,tableoffset,sets,format1,format2,mainoffset,getdelta)
coverage=readcoverage(f,tableoffset+coverage)
+ local shared={}
for index,newindex in next,coverage do
local set=sets[newindex+1]
local hash={}
@@ -17825,18 +17889,24 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
local value=set[i]
if value then
local other=value[1]
- local first=value[2]
- local second=value[3]
- if first or second then
- hash[other]={ first,second or nil }
- else
- hash[other]=nil
+ local share=shared[value]
+ if share==nil then
+ local first=value[2]
+ local second=value[3]
+ if first or second then
+ share={ first,second or nil }
+ else
+ share=false
+ end
+ shared[value]=share
end
+ hash[other]=share or nil
end
end
coverage[index]=hash
end
return {
+ shared=shared and true or nil,
format="pair",
coverage=coverage,
}
@@ -17853,6 +17923,7 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
classdef1=readclassdef(f,tableoffset+classdef1,coverage)
classdef2=readclassdef(f,tableoffset+classdef2,nofglyphs)
local usedcoverage={}
+ local shared={}
for g1,c1 in next,classdef1 do
if coverage[g1] then
local l1=classlist[c1]
@@ -17864,8 +17935,17 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
local first=offsets[1]
local second=offsets[2]
if first or second then
- hash[paired]={ first,second or nil }
- else
+ local s1=shared[first]
+ if s1==nil then
+ s1={}
+ shared[first]=s1
+ end
+ local s2=s1[second]
+ if s2==nil then
+ s2={ first,second or nil }
+ s1[second]=s2
+ end
+ hash[paired]=s2
end
end
end
@@ -17874,6 +17954,7 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
end
end
return {
+ shared=shared and true or nil,
format="pair",
coverage=usedcoverage,
}
@@ -19587,12 +19668,13 @@ function readers.avar(f,fontdata,specification)
local lastfrom=false
local lastto=false
for i=1,nofvalues do
- local f,t=read2dot14(f),read2dot14(f)
- if lastfrom and f<=lastfrom then
- elseif lastto and t>=lastto then
+ local from=read2dot14(f)
+ local to=read2dot14(f)
+ if lastfrom and from<=lastfrom then
+ elseif lastto and to>=lastto then
else
- values[#values+1]={ f,t }
- lastfrom,lastto=f,t
+ values[#values+1]={ from,to }
+ lastfrom,lastto=from,to
end
end
nofvalues=#values
@@ -21074,7 +21156,9 @@ function readers.pack(data)
end
return false
elseif nt>=threshold then
- local one,two,rest=0,0,0
+ local one=0
+ local two=0
+ local rest=0
if pass==1 then
for k,v in next,c do
if v==1 then
@@ -21162,16 +21246,30 @@ function readers.pack(data)
if kind=="gpos_pair" then
local c=step.coverage
if c then
- if step.format=="pair" then
+ if step.format~="pair" then
+ for g1,d1 in next,c do
+ c[g1]=pack_normal(d1)
+ end
+ elseif step.shared then
+ local shared={}
for g1,d1 in next,c do
for g2,d2 in next,d1 do
- local f=d2[1] if f and f~=true then d2[1]=pack_indexed(f) end
- local s=d2[2] if s and s~=true then d2[2]=pack_indexed(s) end
+ if not shared[d2] then
+ local f=d2[1] if f and f~=true then d2[1]=pack_indexed(f) end
+ local s=d2[2] if s and s~=true then d2[2]=pack_indexed(s) end
+ shared[d2]=true
+ end
end
end
+ if pass==2 then
+ step.shared=nil
+ end
else
for g1,d1 in next,c do
- c[g1]=pack_normal(d1)
+ for g2,d2 in next,d1 do
+ local f=d2[1] if f and f~=true then d2[1]=pack_indexed(f) end
+ local s=d2[2] if s and s~=true then d2[2]=pack_indexed(s) end
+ end
end
end
end
@@ -22457,7 +22555,7 @@ 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.107
+otf.version=3.108
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)
@@ -22822,7 +22920,6 @@ local function copytotfm(data,cache_id)
properties.space=spacer
properties.encodingbytes=2
properties.format=data.format or formats.otf
- properties.noglyphnames=true
properties.filename=filename
properties.fontname=fontname
properties.fullname=fullname
@@ -23176,7 +23273,9 @@ local function gref(descriptions,n)
return f_unicode(n)
end
elseif n then
- local num,nam,j={},{},0
+ local num={}
+ local nam={}
+ local j=0
for i=1,#n do
local ni=n[i]
if tonumber(ni) then
@@ -23381,12 +23480,15 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis
local done=trace_baseinit and trace_ligatures and {}
for i=1,nofligatures do
local ligature=ligatures[i]
- local unicode,tree=ligature[1],ligature[2]
+ local unicode=ligature[1]
+ local tree=ligature[2]
make_1(present,tree,"ctx_"..unicode)
end
for i=1,nofligatures do
local ligature=ligatures[i]
- local unicode,tree,lookupname=ligature[1],ligature[2],ligature[3]
+ local unicode=ligature[1]
+ local tree=ligature[2]
+ local lookupname=ligature[3]
make_2(present,tfmdata,characters,tree,"ctx_"..unicode,unicode,unicode,done,sequence)
end
end
@@ -23639,7 +23741,7 @@ local getboth=nuts.getboth
local getdisc=nuts.getdisc
local setdisc=nuts.setdisc
local setoffsets=nuts.setoffsets
-local ischar=nuts.is_char
+local ischar=nuts.ischar
local getkern=nuts.getkern
local setkern=nuts.setkern
local setlink=nuts.setlink
@@ -23952,7 +24054,8 @@ function injections.setmove(current,factor,rlmode,x,injection)
end
end
function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase,mkmk,checkmark)
- local dx,dy=factor*(ba[1]-ma[1]),factor*(ba[2]-ma[2])
+ local dx=factor*(ba[1]-ma[1])
+ local dy=factor*(ba[2]-ma[2])
nofregisteredmarks=nofregisteredmarks+1
if rlmode>=0 then
dx=tfmbase.width-dx
@@ -25069,7 +25172,7 @@ local getprop=nuts.getprop
local setprop=nuts.setprop
local getsubtype=nuts.getsubtype
local getchar=nuts.getchar
-local ischar=nuts.is_char
+local ischar=nuts.ischar
local end_of_math=nuts.end_of_math
local nodecodes=nodes.nodecodes
local disc_code=nodecodes.disc
@@ -25278,9 +25381,9 @@ if not classifiers then
characters.classifiers=classifiers
end
function methods.arab(head,font,attr)
- local first,last=nil,nil
- local c_first,c_last=nil,nil
- local current,done=head,false
+ local first,last,c_first,c_last
+ local current=head
+ local done=false
current=tonut(current)
while current do
local char,id=ischar(current,font)
@@ -25486,8 +25589,6 @@ local setprev=nuts.setprev
local getboth=nuts.getboth
local setboth=nuts.setboth
local getid=nuts.getid
-local getattr=nuts.getattr
-local setattr=nuts.setattr
local getprop=nuts.getprop
local setprop=nuts.setprop
local getsubtype=nuts.getsubtype
@@ -25500,7 +25601,9 @@ local setlink=nuts.setlink
local getcomponents=nuts.getcomponents
local setcomponents=nuts.setcomponents
local getwidth=nuts.getwidth
-local ischar=nuts.is_char
+local getattr=nuts.getattr
+local getglyphdata=nuts.getglyphdata
+local ischar=nuts.ischar
local isglyph=nuts.isglyph
local usesfont=nuts.uses_font
local insert_node_after=nuts.insert_after
@@ -26021,8 +26124,8 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
local prev=getprev(start)
if stop then
setnext(stop)
- local tail=getprev(stop)
local copy=copy_node_list(start)
+ local tail=stop
local liat=find_node_tail(copy)
if pre then
setlink(liat,pre)
@@ -26113,7 +26216,8 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,st
end
local format=step.format
if format=="pair" then
- local a,b=krn[1],krn[2]
+ local a=krn[1]
+ local b=krn[2]
if a==true then
elseif a then
local x,y,w,h=setposition(1,start,factor,rlmode,a,injection)
@@ -26631,7 +26735,8 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm
end
local format=currentlookup.format
if format=="pair" then
- local a,b=krn[1],krn[2]
+ local a=krn[1]
+ local b=krn[2]
if a==true then
elseif a then
local x,y,w,h=setposition(1,start,factor,rlmode,a,"injections")
@@ -28101,7 +28206,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm
if char then
local a
if attr then
- a=getattr(start,0)
+ a=getglyphdata(start)
end
if not a or (a==attr) then
local lookupmatch=lookupcache[char]
@@ -28135,7 +28240,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
if char then
local a
if attr then
- a=getattr(start,0)
+ a=getglyphdata(start)
end
local startnext=getnext(start)
if not a or (a==attr) then
@@ -28210,7 +28315,7 @@ end
local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
local a
if attr then
- a=getattr(sub,0)
+ a=getglyphdata(sub)
end
if not a or (a==attr) then
for n in nextnode,sub do
@@ -28244,7 +28349,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm
if char then
local a
if attr then
- a=getattr(start,0)
+ a=getglyphdata(start)
end
if not a or (a==attr) then
for i=1,nofsteps do
@@ -28285,7 +28390,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
if char then
local a
if attr then
- a=getattr(start,0)
+ a=getglyphdata(start)
end
local startnext=getnext(start)
if not a or (a==attr) then
@@ -28363,7 +28468,7 @@ end
local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
local a
if attr then
- a=getattr(sub,0)
+ a=getglyphdata(sub)
end
if not a or (a==attr) then
for n in nextnode,sub do
@@ -28514,7 +28619,7 @@ do
if m then
local a
if attr then
- a=getattr(start,0)
+ a=getglyphdata(start)
end
if not a or (a==attr) then
for i=m[1],m[2] do
@@ -28558,7 +28663,7 @@ do
if lookupmatch then
local a
if attr then
- if getattr(start,0)==attr and (not attribute or getprop(start,a_state)==attribute) then
+ if getglyphdata(start)==attr and (not attribute or getprop(start,a_state)==attribute) then
a=true
end
elseif not attribute or getprop(start,a_state)==attribute then
@@ -28614,7 +28719,7 @@ do
if m then
local a
if attr then
- if getattr(start,0)==attr and (not attribute or getprop(start,a_state)==attribute) then
+ if getglyphdata(start)==attr and (not attribute or getprop(start,a_state)==attribute) then
a=true
end
elseif not attribute or getprop(start,a_state)==attribute then
@@ -29065,7 +29170,7 @@ local setprev=nuts.setprev
local setchar=nuts.setchar
local getprop=nuts.getprop
local setprop=nuts.setprop
-local ischar=nuts.is_char
+local ischar=nuts.ischar
local insert_node_after=nuts.insert_after
local copy_node=nuts.copy
local remove_node=nuts.remove
@@ -30034,7 +30139,7 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start)
end
function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement)
local stop=getnext(start)
- local font=getfont(start)
+ local font=getfont(start)
local last=start
while stop do
local char=ischar(stop,font)
@@ -31668,7 +31773,8 @@ local function addfeature(data,feature,specifications)
if not nocheck and not description then
skip=skip+1
elseif type(replacement)=="table" then
- local r,n={},0
+ local r={}
+ local n=0
for i=1,#replacement do
local u=tounicode(replacement[i])
if nocheck or descriptions[u] then
@@ -32601,13 +32707,15 @@ function afm.load(filename)
local name=file.removesuffix(file.basename(filename))
local data=containers.read(afm.cache,name)
local attr=lfs.attributes(filename)
- local size,time=attr and attr.size or 0,attr and attr.modification or 0
+ local size=attr and attr.size or 0
+ local time=attr and attr.modification or 0
local pfbfile=file.replacesuffix(name,"pfb")
local pfbname=resolvers.findfile(pfbfile,"pfb") or ""
if pfbname=="" then
pfbname=resolvers.findfile(file.basename(pfbfile),"pfb") or ""
end
- local pfbsize,pfbtime=0,0
+ local pfbsize=0
+ local pfbtime=0
if pfbname~="" then
local attr=lfs.attributes(pfbname)
pfbsize=attr.size or 0
@@ -32816,7 +32924,8 @@ local addthem=function(rawdata,ligatures)
local one=descriptions[unicodes[ligname]]
if one then
for _,pair in next,ligdata do
- local two,three=unicodes[pair[1]],unicodes[pair[2]]
+ local two=unicodes[pair[1]]
+ local three=unicodes[pair[2]]
if two and three then
local ol=one.ligatures
if ol then
@@ -32916,7 +33025,8 @@ local function adddimensions(data)
for unicode,description in next,data.descriptions do
local bb=description.boundingbox
if bb then
- local ht,dp=bb[4],-bb[2]
+ local ht=bb[4]
+ local dp=-bb[2]
if ht==0 or ht<0 then
else
description.height=ht
@@ -32945,8 +33055,9 @@ local function copytotfm(data)
local filename=constructors.checkedfilename(resources)
local fontname=metadata.fontname or metadata.fullname
local fullname=metadata.fullname or metadata.fontname
- local endash=0x0020
+ local endash=0x2013
local emdash=0x2014
+ local space=0x0020
local spacer="space"
local spaceunits=500
local monospaced=metadata.monospaced
@@ -32957,26 +33068,32 @@ local function copytotfm(data)
parameters.italicangle=italicangle
parameters.charwidth=charwidth
parameters.charxheight=charxheight
+ local d_endash=descriptions[endash]
+ local d_emdash=descriptions[emdash]
+ local d_space=descriptions[space]
+ if not d_space or d_space==0 then
+ d_space=d_endash
+ end
+ if d_space then
+ spaceunits,spacer=d_space.width or 0,"space"
+ end
if properties.monospaced then
- if descriptions[endash] then
- spaceunits,spacer=descriptions[endash].width,"space"
- end
- if not spaceunits and descriptions[emdash] then
- spaceunits,spacer=descriptions[emdash].width,"emdash"
- end
- if not spaceunits and charwidth then
- spaceunits,spacer=charwidth,"charwidth"
+ if spaceunits==0 and d_emdash then
+ spaceunits,spacer=d_emdash.width or 0,"emdash"
end
else
- if descriptions[endash] then
- spaceunits,spacer=descriptions[endash].width,"space"
- end
- if not spaceunits and charwidth then
- spaceunits,spacer=charwidth,"charwidth"
+ if spaceunits==0 and d_endash then
+ spaceunits,spacer=d_emdash.width or 0,"endash"
end
end
- spaceunits=tonumber(spaceunits)
- if spaceunits<200 then
+ if spaceunits==0 and charwidth then
+ spaceunits,spacer=charwidth or 0,"charwidth"
+ end
+ if spaceunits==0 then
+ spaceunits=tonumber(spaceunits) or 500
+ end
+ if spaceunits==0 then
+ spaceunits=500
end
parameters.slant=0
parameters.space=spaceunits
@@ -33182,7 +33299,7 @@ local function check_afm(specification,fullname)
if foundname=="" then
foundname=fonts.names.getfilename(fullname,"afm") or ""
end
- if foundname=="" and afm.autoprefixed then
+ if fullname and foundname=="" and afm.autoprefixed then
local encoding,shortname=match(fullname,"^(.-)%-(.*)$")
if encoding and shortname and fonts.encodings.known[encoding] then
shortname=findbinfile(shortname,'afm') or ""
@@ -33424,7 +33541,7 @@ end -- closure
do -- begin closure to overcome local limits and interference
-if not modules then modules={} end modules ['font-tfm']={
+if not modules then modules={} end modules ['luatex-fonts-tfm']={
version=1.001,
comment="companion to font-ini.mkiv",
author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -33460,7 +33577,7 @@ local registertfmenhancer=tfmenhancers.register
local charcommand=helpers.commands.char
constructors.resolvevirtualtoo=false
fonts.formats.tfm="type1"
-fonts.formats.ofm="type1"
+fonts.formats.ofm="type1"
function tfm.setfeatures(tfmdata,features)
local okay=constructors.initializefeatures("tfm",tfmdata,features,trace_features,report_tfm)
if okay then
@@ -33469,191 +33586,156 @@ function tfm.setfeatures(tfmdata,features)
return {}
end
end
-local depth={}
-local read_from_tfm,check_tfm do
- local tfmreaders=context and tfm.readers
- local loadtfmvf=tfmreaders and tfmreaders.loadtfmvf
- local loadtfm=font.read_tfm
- local loadvf=font.read_vf
- directives.register("fonts.tfm.builtin",function(v)
- loadtfmvf=tfmreaders and tfmreaders.loadtfmvf
- if v and loadtfm then
- loadtfmvf=false
- end
- end)
- read_from_tfm=function(specification)
- local filename=specification.filename
- local size=specification.size
- depth[filename]=(depth[filename] or 0)+1
- if trace_defining then
- report_defining("loading tfm file %a at size %s",filename,size)
- end
- local tfmdata
- if loadtfmvf then
- tfmdata=loadtfmvf(filename,size)
- else
- tfmdata=loadtfm(filename,size)
+local depth={}
+local loadtfm=font.read_tfm
+local loadvf=font.read_vf
+local function read_from_tfm(specification)
+ local filename=specification.filename
+ local size=specification.size
+ depth[filename]=(depth[filename] or 0)+1
+ if trace_defining then
+ report_defining("loading tfm file %a at size %s",filename,size)
+ end
+ local tfmdata=loadtfm(filename,size)
+ if tfmdata then
+ local features=specification.features and specification.features.normal or {}
+ local features=constructors.checkedfeatures("tfm",features)
+ specification.features.normal=features
+ local newtfmdata=(depth[filename]==1) and tfm.reencode(tfmdata,specification)
+ if newtfmdata then
+ tfmdata=newtfmdata
end
- if tfmdata then
- local features=specification.features and specification.features.normal or {}
- local features=constructors.checkedfeatures("tfm",features)
- specification.features.normal=features
- local newtfmdata=(depth[filename]==1) and tfm.reencode(tfmdata,specification)
- if newtfmdata then
- tfmdata=newtfmdata
- end
- local resources=tfmdata.resources or {}
- local properties=tfmdata.properties or {}
- local parameters=tfmdata.parameters or {}
- local shared=tfmdata.shared or {}
- shared.features=features
- shared.resources=resources
- properties.name=tfmdata.name
- properties.fontname=tfmdata.fontname
- properties.psname=tfmdata.psname
- properties.fullname=tfmdata.fullname
- properties.filename=specification.filename
- properties.format=tfmdata.format or fonts.formats.tfm
- properties.usedbitmap=tfmdata.usedbitmap
- tfmdata.properties=properties
- tfmdata.resources=resources
- tfmdata.parameters=parameters
- tfmdata.shared=shared
- shared.rawdata={ resources=resources }
- shared.features=features
- if newtfmdata then
- if not resources.marks then
- resources.marks={}
- end
- if not resources.sequences then
- resources.sequences={}
- end
- if not resources.features then
- resources.features={
- gsub={},
- gpos={},
- }
- end
- if not tfmdata.changed then
- tfmdata.changed={}
- end
- if not tfmdata.descriptions then
- tfmdata.descriptions=tfmdata.characters
- end
- otf.readers.addunicodetable(tfmdata)
- tfmenhancers.apply(tfmdata,filename)
- constructors.applymanipulators("tfm",tfmdata,features,trace_features,report_tfm)
- otf.readers.unifymissing(tfmdata)
- fonts.mappings.addtounicode(tfmdata,filename)
- tfmdata.tounicode=1
- local tounicode=fonts.mappings.tounicode
- for unicode,v in next,tfmdata.characters do
- local u=v.unicode
- if u then
- v.tounicode=tounicode(u)
- end
- end
- if tfmdata.usedbitmap then
- tfm.addtounicode(tfmdata)
- end
- end
- shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil
- if size<0 then
- size=idiv(65536*-size,100)
- end
- parameters.factor=1
- parameters.units=1000
- parameters.size=size
- 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
- parameters.space_shrink=parameters.space_shrink or parameters[4] or 0
- parameters.x_height=parameters.x_height or parameters[5] or 0
- parameters.quad=parameters.quad or parameters[6] or 0
- parameters.extra_space=parameters.extra_space or parameters[7] or 0
- constructors.enhanceparameters(parameters)
- properties.private=properties.private or tfmdata.private or privateoffset
- if newtfmdata then
- elseif loadtfmvf then
- local fonts=tfmdata.fonts
- if fonts then
- for i=1,#fonts do
- local font=fonts[i]
- local id=font.id
- if not id then
- local name=font.name
- local size=font.size
- if name and size then
- local data,id=constructors.readanddefine(name,size)
- if id then
- font.id=id
- font.name=nil
- font.size=nil
- end
- end
- end
- end
- end
- elseif constructors.resolvevirtualtoo then
- fonts.loggers.register(tfmdata,file.suffix(filename),specification)
- local vfname=findbinfile(specification.name,'ovf')
- if vfname and vfname~="" then
- local vfdata=loadvf(vfname,size)
- if vfdata then
- local chars=tfmdata.characters
- for k,v in next,vfdata.characters do
- chars[k].commands=v.commands
- end
- properties.virtualized=true
- tfmdata.fonts=vfdata.fonts
- tfmdata.type="virtual"
- local fontlist=vfdata.fonts
- local name=file.nameonly(filename)
- for i=1,#fontlist do
- local n=fontlist[i].name
- local s=fontlist[i].size
- local d=depth[filename]
- s=constructors.scaled(s,vfdata.designsize)
- if d>tfm.maxnestingdepth then
- report_defining("too deeply nested virtual font %a with size %a, max nesting depth %s",n,s,tfm.maxnestingdepth)
- fontlist[i]={ id=0 }
- elseif (d>1) and (s>tfm.maxnestingsize) then
- report_defining("virtual font %a exceeds size %s",n,s)
- fontlist[i]={ id=0 }
- else
- local t,id=constructors.readanddefine(n,s)
- fontlist[i]={ id=id }
- end
+ local resources=tfmdata.resources or {}
+ local properties=tfmdata.properties or {}
+ local parameters=tfmdata.parameters or {}
+ local shared=tfmdata.shared or {}
+ shared.features=features
+ shared.resources=resources
+ properties.name=tfmdata.name
+ properties.fontname=tfmdata.fontname
+ properties.psname=tfmdata.psname
+ properties.fullname=tfmdata.fullname
+ properties.filename=specification.filename
+ properties.format=tfmdata.format or fonts.formats.tfm
+ properties.usedbitmap=tfmdata.usedbitmap
+ tfmdata.properties=properties
+ tfmdata.resources=resources
+ tfmdata.parameters=parameters
+ tfmdata.shared=shared
+ shared.rawdata={ resources=resources }
+ shared.features=features
+ if newtfmdata then
+ if not resources.marks then
+ resources.marks={}
+ end
+ if not resources.sequences then
+ resources.sequences={}
+ end
+ if not resources.features then
+ resources.features={
+ gsub={},
+ gpos={},
+ }
+ end
+ if not tfmdata.changed then
+ tfmdata.changed={}
+ end
+ if not tfmdata.descriptions then
+ tfmdata.descriptions=tfmdata.characters
+ end
+ otf.readers.addunicodetable(tfmdata)
+ tfmenhancers.apply(tfmdata,filename)
+ constructors.applymanipulators("tfm",tfmdata,features,trace_features,report_tfm)
+ otf.readers.unifymissing(tfmdata)
+ fonts.mappings.addtounicode(tfmdata,filename)
+ tfmdata.tounicode=1
+ local tounicode=fonts.mappings.tounicode
+ for unicode,v in next,tfmdata.characters do
+ local u=v.unicode
+ if u then
+ v.tounicode=tounicode(u)
+ end
+ end
+ if tfmdata.usedbitmap then
+ tfm.addtounicode(tfmdata)
+ end
+ end
+ shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil
+ if size<0 then
+ size=idiv(65536*-size,100)
+ end
+ parameters.factor=1
+ parameters.units=1000
+ parameters.size=size
+ 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
+ parameters.space_shrink=parameters.space_shrink or parameters[4] or 0
+ parameters.x_height=parameters.x_height or parameters[5] or 0
+ parameters.quad=parameters.quad or parameters[6] or 0
+ parameters.extra_space=parameters.extra_space or parameters[7] or 0
+ constructors.enhanceparameters(parameters)
+ properties.private=properties.private or tfmdata.private or privateoffset
+ if newtfmdata then
+ elseif constructors.resolvevirtualtoo then
+ fonts.loggers.register(tfmdata,file.suffix(filename),specification)
+ local vfname=findbinfile(specification.name,'ovf')
+ if vfname and vfname~="" then
+ local vfdata=loadvf(vfname,size)
+ if vfdata then
+ local chars=tfmdata.characters
+ for k,v in next,vfdata.characters do
+ chars[k].commands=v.commands
+ end
+ properties.virtualized=true
+ tfmdata.fonts=vfdata.fonts
+ tfmdata.type="virtual"
+ local fontlist=vfdata.fonts
+ local name=file.nameonly(filename)
+ for i=1,#fontlist do
+ local n=fontlist[i].name
+ local s=fontlist[i].size
+ local d=depth[filename]
+ s=constructors.scaled(s,vfdata.designsize)
+ if d>tfm.maxnestingdepth then
+ report_defining("too deeply nested virtual font %a with size %a, max nesting depth %s",n,s,tfm.maxnestingdepth)
+ fontlist[i]={ id=0 }
+ elseif (d>1) and (s>tfm.maxnestingsize) then
+ report_defining("virtual font %a exceeds size %s",n,s)
+ fontlist[i]={ id=0 }
+ else
+ local t,id=constructors.readanddefine(n,s)
+ fontlist[i]={ id=id }
end
end
end
end
- properties.haskerns=true
- properties.hasligatures=true
- properties.hasitalics=true
- resources.unicodes={}
- resources.lookuptags={}
- depth[filename]=depth[filename]-1
- return tfmdata
- else
- depth[filename]=depth[filename]-1
end
+ properties.haskerns=true
+ properties.hasligatures=true
+ properties.hasitalics=true
+ resources.unicodes={}
+ resources.lookuptags={}
+ depth[filename]=depth[filename]-1
+ return tfmdata
+ else
+ depth[filename]=depth[filename]-1
end
- check_tfm=function(specification,fullname)
- local foundname=findbinfile(fullname,'tfm') or ""
- if foundname=="" then
- foundname=findbinfile(fullname,'ofm') or ""
- end
- if foundname=="" then
- foundname=fonts.names.getfilename(fullname,"tfm") or ""
- end
- if foundname~="" then
- specification.filename=foundname
- specification.format="ofm"
- return read_from_tfm(specification)
- elseif trace_defining then
- report_defining("loading tfm with name %a fails",specification.name)
- end
+end
+local function check_tfm(specification,fullname)
+ local foundname=findbinfile(fullname,'tfm') or ""
+ if foundname=="" then
+ foundname=findbinfile(fullname,'ofm') or ""
+ end
+ if foundname=="" then
+ foundname=fonts.names.getfilename(fullname,"tfm") or ""
+ end
+ if foundname~="" then
+ specification.filename=foundname
+ specification.format="ofm"
+ return read_from_tfm(specification)
+ elseif trace_defining then
+ report_defining("loading tfm with name %a fails",specification.name)
end
end
readers.check_tfm=check_tfm