diff options
| author | Hans Hagen <pragma@wxs.nl> | 2026-11-22 22:35:18 +0000 |
|---|---|---|
| committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2026-11-22 22:35:18 +0000 |
| commit | e5337a5d9bf6eb951599ed4f3b86a41514236704 (patch) | |
| tree | ae0cbdfd99014fa35eccd08dd700a2953d5c37e6 /tex/generic | |
| parent | 8d460b764f99b306461189a66cb22bbb319db454 (diff) | |
Diffstat (limited to 'tex/generic')
| -rw-r--r-- | tex/generic/context/luatex/luatex-basics-gen.lua | 8 | ||||
| -rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 238 |
2 files changed, 134 insertions, 112 deletions
diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua index cbb9fb010..b879fbb6a 100644 --- a/tex/generic/context/luatex/luatex-basics-gen.lua +++ b/tex/generic/context/luatex/luatex-basics-gen.lua @@ -236,7 +236,7 @@ do logs.report("system","creating cache path '%s'",cachepath) end end - if file.is_writable(cachepath) then + if dir.iswritable(cachepath) then writable = file.join(cachepath,"luatex-cache") lfs.mkdir(writable) writable = file.join(writable,caches.namespace) @@ -246,13 +246,13 @@ do end for i=1,#cachepaths do - if file.is_readable(cachepaths[i]) then + if dir.isreadable(cachepaths[i]) then readables[#readables+1] = file.join(cachepaths[i],"luatex-cache",caches.namespace) end end if not writable then - logs.report("system","no writeable cache path, quiting") + logs.report("system","no writable cache path, quiting") os.exit() elseif #readables == 0 then logs.report("system","no readable cache path, quiting") @@ -290,7 +290,7 @@ end function caches.is_writable(path,name) local fullname = makefullname(path,name) - return fullname and file.is_writable(fullname) + return fullname and file.canbewritten(fullname) end function caches.loaddata(readables,name,writable) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7a2aeec2f..3520ae8d7 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.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 : 2026-09-21 20:00 +-- merge date : 2026-10-31 00:48 do -- begin closure to overcome local limits and interference @@ -137,7 +137,6 @@ if not modules then modules={} end modules ['l-lpeg']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -lpeg=require("lpeg") local lpeg=lpeg if not lpeg.print then function lpeg.print(...) print(lpeg.pcode(...)) end end local type,next,tostring=type,next,tostring @@ -923,7 +922,8 @@ if not modules then modules={} end modules ['l-functions']={ license="see context related readme files" } functions=functions or {} -function functions.dummy() end +function functions.dummy () end +function functions.identity(s) return s end end -- closure @@ -937,7 +937,7 @@ if not modules then modules={} end modules ['l-string']={ license="see context related readme files" } local string=string -local sub,gmatch,format,char,byte,rep,lower,find=string.sub,string.gmatch,string.format,string.char,string.byte,string.rep,string.lower,string.find +local sub,gsub,gmatch,format,char,byte,rep,lower,find=string.sub,string.gsub,string.gmatch,string.format,string.char,string.byte,string.rep,string.lower,string.find local lpegmatch,patterns=lpeg.match,lpeg.patterns local P,S,C,Ct,Cc,Cs=lpeg.P,lpeg.S,lpeg.C,lpeg.Ct,lpeg.Cc,lpeg.Cs do @@ -1034,17 +1034,18 @@ function string.valid(str,default) return (type(str)=="string" and str~="" and str) or default or nil end string.itself=function(s) return s end -local pattern_c=Ct(C(1)^0) -local pattern_b=Ct((C(1)/byte)^0) -function string.totable(str,bytes) - return lpegmatch(bytes and pattern_b or pattern_c,str) -end -local replacer=lpeg.replacer("@","%%") function string.tformat(fmt,...) - return format(lpegmatch(replacer,fmt),...) + return format((gsub(fmt,"@","%%")),...) end string.quote=string.quoted string.unquote=string.unquoted +if not string.totable then + local pattern_c=Ct(C(1)^0) + local pattern_b=Ct((C(1)/byte)^0) + function string.totable(str,bytes) + return lpegmatch(bytes and pattern_b or pattern_c,str) + end +end if not string.bytetable then local limit=5000 function string.bytetable(str) @@ -2446,7 +2447,7 @@ function io.ask(question,default,options) if default then write(format(" [%s]",default)) end - write(format(" ")) + write(" ") flush() local answer=read() answer=gsub(answer,"^%s*(.*)%s*$","%1") @@ -2709,48 +2710,44 @@ local reslasher=lpeg.replacer(P("\\"),"/") function file.reslash(str) return str and lpegmatch(reslasher,str) end -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 +function file.iswritable(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 - 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 + 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 + return false end -file.isreadable=file.is_readable -file.iswritable=file.is_writable +local readable=P("r")*Cc(true) +function file.isreadable(name) + if name then + local a=attributes(name) + return a and lpegmatch(readable,a.permissions) or false + else + return false + end +end +file.canbewritten=file.iswritable +file.is_readable=file.isreadable +file.is_writable=file.iswritable function file.size(name) if name then local a=attributes(name) @@ -2896,11 +2893,13 @@ end function file.is_rootbased_path(filename) return filename and lpegmatch(rootbased,filename)~=nil end -function lfs.mkdirs(path) - local full="" - for sub in gmatch(path,"(/*[^\\/]+)") do - full=full..sub - lfs.mkdir(full) +if not lfs.mkdirs then + function lfs.mkdirs(path) + local full="" + for sub in gmatch(path,"(/*[^\\/]+)") do + full=full..sub + lfs.mkdir(full) + end end end function file.withinbase(path) @@ -3102,39 +3101,6 @@ if not math.ult then return floor(m)<floor(n) end end -if setinspector and vector then - local inspect=inspect - local isvector=vector.isvector - local totable=vector.totable - setinspector("vector",function(v) - if isvector(v) then - inspect(totable(v)) - return true - end - end) - local mesh=vector.mesh - if mesh then - local ismesh=mesh.ismesh - local totable=mesh.totable - setinspector("mesh",function(v) - if ismesh(v) then - inspect(totable(v)) - return true - end - end) - end - local points=vector.points - if points then - local ispoints=points.ispoints - local totable=points.totable - setinspector("points",function(v) - if ispoints(v) then - inspect(totable(v)) - return true - end - end) - end -end end -- closure @@ -3150,7 +3116,7 @@ if not modules then modules={} end modules ['util-str']={ utilities=utilities or {} utilities.strings=utilities.strings or {} local strings=utilities.strings -local format,gsub,rep,sub,find,char,byte=string.format,string.gsub,string.rep,string.sub,string.find,string.char,string.byte +local format,gsub,match,rep,sub,find,char,byte=string.format,string.gsub,string.match,string.rep,string.sub,string.find,string.char,string.byte local load,dump=load,string.dump local tonumber,type,tostring,next,setmetatable,rawset=tonumber,type,tostring,next,setmetatable,rawset local unpack,concat=table.unpack,table.concat @@ -3602,6 +3568,10 @@ local environment={ stripzeros=patterns.stripzeros, escapedquotes=string.escapedquotes, FORMAT=string.f6, + FD=string.fd, + FD3=string.fd3, + FD6=string.fd6, + FD9=string.fd9, nspaces=hashes.spaces, X00=hashes.X00, X02=false, @@ -3876,7 +3846,30 @@ 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 if environment.FORMAT then +local format_N +if environment.FD then + format_N=function(f) + n=n+1 + if not f or f=="" then + return format("FD(a%s,9)",n) + end + if type(f)=="string" then + f=tonumber(match(f,"[^%d]*([%d+])f?")) + end + if type(f)=="number" then + if f==3 then + return format("FD3(a%s)",n) + elseif f==6 then + return format("FD6(a%s)",n) + elseif f==9 then + return format("FD9(a%s)",n) + elseif f>=1 and f<=20 then + return format("FD(a%s,%i)",n,f//1) + end + end + return format("FD(a%s)",n) + end +elseif environment.FORMAT then format_N=function(f) n=n+1 if not f or f=="" then @@ -4212,6 +4205,27 @@ if CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 then return (gsub(s,".",t)) end end +if characters and characters.lower then + string.tolower=characters.lower + string.toupper=characters.upper +else + local ulower + local uupper + local function check() + if not characters then + dofile(resolvers.findfile("char-def.lua")) + dofile(resolvers.findfile("char-utf.lua")) + end + ulower=characters.lower + uupper=characters.upper + string.tolower=ulower + string.toupper=uupper + end + ulower=function(str) check() return ulower(str) end + uupper=function(str) check() return uupper(str) end + function string.tolower(str) return ulower(str) end + function string.toupper(str) return uupper(str) end +end end -- closure @@ -4760,7 +4774,7 @@ do logs.report("system","creating cache path '%s'",cachepath) end end - if file.is_writable(cachepath) then + if dir.iswritable(cachepath) then writable=file.join(cachepath,"luatex-cache") lfs.mkdir(writable) writable=file.join(writable,caches.namespace) @@ -4769,12 +4783,12 @@ do end end for i=1,#cachepaths do - if file.is_readable(cachepaths[i]) then + if dir.isreadable(cachepaths[i]) then readables[#readables+1]=file.join(cachepaths[i],"luatex-cache",caches.namespace) end end if not writable then - logs.report("system","no writeable cache path, quiting") + logs.report("system","no writable cache path, quiting") os.exit() elseif #readables==0 then logs.report("system","no readable cache path, quiting") @@ -4807,7 +4821,7 @@ local function makefullname(path,name) end function caches.is_writable(path,name) local fullname=makefullname(path,name) - return fullname and file.is_writable(fullname) + return fullname and file.canbewritten(fullname) end function caches.loaddata(readables,name,writable) for i=1,#readables do @@ -11848,8 +11862,8 @@ function readers.name(f,fontdata,specification) for i=1,#namelist do local name=namelist[i] local nametag=name.name - local index=name.index - if not done[nametag or i] then + local index=name.index or i + if not done[nametag or index] then local encoding=name.encoding local language=name.language if (not e or encoding==e) and (not l or language==l) then @@ -11864,7 +11878,7 @@ function readers.name(f,fontdata,specification) } end extras[index]=content - done[nametag or i]=true + done[nametag or index]=true end end end @@ -12889,6 +12903,12 @@ local function readtable(tag,f,fontdata,specification,...) reader(f,fontdata,specification,...) end end +local toclean=string.toclean +if not toclean then + toclean=function(str) + return lower(gsub(str,"[^a-zA-Z0-9]","")) + end +end local function readdata(f,offset,specification) local fontdata,tables=loadtables(f,specification,offset) if specification.glyphs then @@ -12898,11 +12918,11 @@ local function readdata(f,offset,specification) readtable("name",f,fontdata,specification) local askedname=specification.askedname if askedname then - local fullname=getname(fontdata,"fullname") or "" - local cleanname=gsub(askedname,"[^a-zA-Z0-9]","") - local foundname=gsub(fullname,"[^a-zA-Z0-9]","") - if lower(cleanname)~=lower(foundname) then - return + local fullname=getname(fontdata,"fullname") + if fullname then + if toclean(askedname)~=toclean(fullname) then + return + end end end readtable("stat",f,fontdata,specification) @@ -13126,11 +13146,12 @@ local function loadfont(specification,n,instance) return result end end -function readers.loadshapes(filename,n,instance,streams) +function readers.loadshapes(filename,n,instance,streams,keephints) local fontdata=loadfont { filename=filename, shapes=true, streams=streams, + keephints=keephints, variable=true, subfont=n, instance=instance, @@ -13160,6 +13181,7 @@ function readers.loadshapes(filename,n,instance,streams) maximumprofile=fontdata.maximumprofile, names=fontdata.names, postscript=fontdata.postscript, + hinttables=fontdata.hinttables, } or { filename=filename, format="unknown", @@ -21603,7 +21625,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.154 +otf.version=3.158 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) @@ -35921,8 +35943,8 @@ local function enhance_add_extra_kerns(rawdata) if kerns then local extrakerns for complex,simple in next,what do - complex=unicodes[complex] - simple=unicodes[simple] + local complex=unicodes[complex] + local simple=unicodes[simple] if complex and simple then local ks=kerns[simple] if ks and not kerns[complex] then @@ -35944,8 +35966,8 @@ local function enhance_add_extra_kerns(rawdata) local function do_it_copy(what) if what then for complex,simple in next,what do - complex=unicodes[complex] - simple=unicodes[simple] + local complex=unicodes[complex] + local simple=unicodes[simple] if complex and simple then local complexdescription=descriptions[complex] if complexdescription then |
