diff options
Diffstat (limited to 'tex/context/base/mkiv/font-syn.lua')
-rw-r--r-- | tex/context/base/mkiv/font-syn.lua | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/tex/context/base/mkiv/font-syn.lua b/tex/context/base/mkiv/font-syn.lua index c4dcf0bcd..52ddf621f 100644 --- a/tex/context/base/mkiv/font-syn.lua +++ b/tex/context/base/mkiv/font-syn.lua @@ -423,8 +423,9 @@ filters.list = { -- to be considered: loop over paths per list entry (so first all otf ttf etc) -names.fontconfigfile = "fonts.conf" -- a bit weird format, bonus feature -names.osfontdirvariable = "OSFONTDIR" -- the official way, in minimals etc +names.fontconfigfile = "fonts.conf" -- a bit weird format, bonus feature +names.osfontdirvariable = "OSFONTDIR" -- the official way, in minimals etc +names.extrafontsvariable = "EXTRAFONTS" -- the official way, in minimals etc filters.paths = { } filters.names = { } @@ -436,7 +437,7 @@ function names.getpaths(trace) local v = cleanpath(t[i]) v = gsub(v,"/+$","") -- not needed any more local key = lower(v) - report_names("%a specifies path %a",where,v) + report_names("variable %a specifies path %a",where,v) if not hash[key] then r = r + 1 result[r] = v @@ -448,6 +449,10 @@ function names.getpaths(trace) if path ~= "" then collect(resolvers.expandedpathlist(path),path) end + local path = names.extrafontsvariable or "" + if path ~= "" then + collect(resolvers.expandedpathlist(path),path) + end if xml then local confname = resolvers.expansion("FONTCONFIG_FILE") or "" if confname == "" then @@ -539,23 +544,6 @@ names.cleanfilename = cleanfilename -- return result -- end -local function walk_tree(pathlist,suffix,identify) - if pathlist then - for i=1,#pathlist do - local path = pathlist[i] - path = cleanpath(path .. "/") - path = gsub(path,"/+","/") - local pattern = path .. "**." .. suffix -- ** forces recurse - report_names("globbing path %a",pattern) - local t = dir.glob(pattern) - sort(t,sorter) - for j=1,#t do - local completename = t[j] - identify(completename,basename(completename),suffix,completename) - end - end - end -end local function check_name(data,result,filename,modification,suffix,subfont) -- shortcuts @@ -1002,9 +990,11 @@ local function unpackreferences() end local function analyzefiles(olddata) + if not trace_warnings then report_names("warnings are disabled (tracker 'fonts.warnings')") end + local data = names.data local done = { } local totalnofread = 0 @@ -1020,6 +1010,26 @@ local function analyzefiles(olddata) local oldspecifications = olddata and olddata.specifications or { } local oldrejected = olddata and olddata.rejected or { } local treatmentdata = treatments.data or { } -- when used outside context + ----- walked = setmetatableindex("number") + + local function walk_tree(pathlist,suffix,identify) + if pathlist then + for i=1,#pathlist do + local path = pathlist[i] + path = cleanpath(path .. "/") + path = gsub(path,"/+","/") + local pattern = path .. "**." .. suffix -- ** forces recurse + report_names("globbing path %a",pattern) + local t = dir.glob(pattern) + sort(t,sorter) + for j=1,#t do + local completename = t[j] + identify(completename,basename(completename),suffix,completename) + end + -- walked[path] = walked[path] + #t + end + end + end local function identify(completename,name,suffix,storedname) local pathpart, basepart = splitbase(completename) @@ -1123,6 +1133,7 @@ local function analyzefiles(olddata) end logs.flush() -- a bit overkill for each font, maybe not needed here end + local function traverse(what, method) local list = filters.list for n=1,#list do @@ -1141,7 +1152,9 @@ local function analyzefiles(olddata) end logs.flush() end + -- problem .. this will not take care of duplicates + local function withtree(suffix) resolvers.dowithfilesintree(".*%." .. suffix .. "$", function(method,root,path,name) if method == "file" or method == "tree" then @@ -1158,16 +1171,20 @@ local function analyzefiles(olddata) report_names("%s entries found, %s %s files checked, %s okay",total,checked,suffix,done) end) end + local function withlsr(suffix) -- all trees -- we do this only for a stupid names run, not used for context itself, -- using the vars is too clumsy so we just stick to a full scan instead local pathlist = resolvers.splitpath(resolvers.showpath("ls-R") or "") walk_tree(pathlist,suffix,identify) end + local function withsystem(suffix) -- OSFONTDIR cum suis walk_tree(names.getpaths(trace),suffix,identify) end + traverse("tree",withtree) -- TEXTREE only + if not usesystemfonts then report_names("ignoring system fonts") elseif texconfig.kpse_init then @@ -1175,9 +1192,15 @@ local function analyzefiles(olddata) else traverse("system", withsystem) end + data.statistics.readfiles = totalnofread data.statistics.skippedfiles = totalnofskipped data.statistics.duplicatefiles = totalnofduplicates + + -- for k, v in sortedhash(walked) do + -- report_names("%s : %i",k,v) + -- end + end local function addfilenames() |