From 551c89289d267c2d8901f3375e57ed1fe2508de5 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 2 Oct 2018 23:41:59 +0200 Subject: 2018-10-02 23:25:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-ro.mkii | 1 + tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/font-con.lua | 3 +- tex/context/base/mkiv/font-ctx.lua | 12 +- tex/context/base/mkiv/font-dsp.lua | 9 +- tex/context/base/mkiv/font-ini.lua | 12 + tex/context/base/mkiv/font-mis.lua | 2 +- tex/context/base/mkiv/font-otl.lua | 5 +- tex/context/base/mkiv/font-oup.lua | 500 ++++++++++++++------- tex/context/base/mkiv/font-prv.lua | 4 +- tex/context/base/mkiv/good-ctx.lua | 6 +- tex/context/base/mkiv/grph-inc.lua | 2 +- tex/context/base/mkiv/java-imp-fld.mkiv | 20 +- tex/context/base/mkiv/java-ini.lua | 5 +- tex/context/base/mkiv/java-ini.mkiv | 6 + tex/context/base/mkiv/lpdf-fld.lua | 120 ++--- tex/context/base/mkiv/math-ext.lua | 2 +- tex/context/base/mkiv/math-ini.lua | 11 +- tex/context/base/mkiv/mtx-context-xml.tex | 5 + tex/context/base/mkiv/scrn-fld.mkvi | 13 +- tex/context/base/mkiv/status-files.pdf | Bin 26173 -> 26120 bytes tex/context/base/mkiv/status-lua.pdf | Bin 269261 -> 268553 bytes tex/context/base/mkiv/strc-def.mkiv | 11 + tex/context/base/mkiv/strc-doc.lua | 6 +- tex/context/base/mkiv/tabl-xtb.mkvi | 10 +- tex/context/base/mkiv/trac-inf.lua | 6 +- tex/context/interface/mkii/keys-ro.xml | 1 + tex/context/interface/mkiv/context-en.xml | 7 + tex/context/interface/mkiv/i-common-value.xml | 1 + tex/context/interface/mkiv/i-context.pdf | Bin 857242 -> 857249 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 60771 -> 60771 bytes tex/context/modules/mkiv/s-fonts-system.lua | 39 +- tex/context/modules/mkiv/s-fonts-system.mkiv | 6 +- tex/context/modules/mkiv/s-xml-analyzers.lua | 6 + tex/generic/context/luatex/luatex-fonts-merged.lua | 467 +++++++++++++------ 38 files changed, 883 insertions(+), 423 deletions(-) (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e9ee9f19d..e309eca7b 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.09.30 19:32} +\newcontextversion{2018.10.02 23:17} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index f297b9b39..76f4f8d69 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2018.09.30 19:32} +\edef\contextversion{2018.10.02 23:17} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index f360848e9..447600484 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -1241,6 +1241,7 @@ \setinterfaceconstant{textstyle}{stiltext} \setinterfaceconstant{textwidth}{latimetext} \setinterfaceconstant{threshold}{threshold} +\setinterfaceconstant{time}{time} \setinterfaceconstant{title}{titlu} \setinterfaceconstant{titlecolor}{culoaretitlu} \setinterfaceconstant{titlecommand}{titlecommand} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 01f33231d..733561e8c 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.09.30 19:32} +\newcontextversion{2018.10.02 23:17} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index d50c05923..23a0825ce 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.09.30 19:32} +\edef\contextversion{2018.10.02 23:17} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index e8bcd56a2..54cf2c199 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -46,8 +46,7 @@ constructors.namemode = "fullpath" -- will be a function constructors.version = 1.01 constructors.cache = containers.define("fonts", "constructors", constructors.version, false) -constructors.privateoffset = 0xF0000 -- 0x10FFFF | context also uses privates: 0xE000-0xEFFF - +constructors.privateoffset = fonts.privateoffsets.textbase or 0xF0000 constructors.cacheintex = true -- so we see the original table in fonts.font -- This might become an interface: diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua index 37ce96ee8..73d39d036 100644 --- a/tex/context/base/mkiv/font-ctx.lua +++ b/tex/context/base/mkiv/font-ctx.lua @@ -1903,7 +1903,11 @@ implement { -- => commands -local function nametoslot(name) +local pattern = P("P") + * (lpeg.patterns.hexdigit^4 / function(s) return tonumber(s,16) end) + * P(-1) + +local function nametoslot(name) -- also supports PXXXXX (4+ positions) local t = type(name) if t == "string" then local unic = unicodes[true] @@ -1924,7 +1928,11 @@ local function nametoslot(name) end local char = characters[true] local slot = aglunicodes[name] - if char[slot] then + if slot and char[slot] then + return slot + end + local slot = lpegmatch(pattern,name) + if slot and char[slot] then return slot end -- not in font diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index ba92c62be..127afd9cb 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -54,7 +54,7 @@ if not modules then modules = { } end modules ['font-dsp'] = { -- Although we use a few table readers there i sno real gain in there (apart from having -- less code. After all there are often not that many demanding features. -local next, type = next, type +local next, type, tonumber = next, type, tonumber local band = bit32.band local extract = bit32.extract local bor = bit32.bor @@ -1007,8 +1007,9 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n rules = rules, } elseif subtype == 3 then - local current = readarray(f) + local nofglyphs = readushort(f) local noflookups = readushort(f) + local current = readcardinaltable(f,nofglyphs,ushort) local lookups = readlookuparray(f,noflookups,#current) current = readcoveragearray(f,tableoffset,current,true) return { @@ -2213,7 +2214,7 @@ do report_issue(i,what,sequence,"no") elseif not next(rlookups) then -- can be ok as it aborts a chain sequence - report_issue(i,what,sequence,"empty") + -- report_issue(i,what,sequence,"empty") rule.lookups = nil else -- we can have holes in rlookups flagged false and we can have multiple lookups @@ -2421,7 +2422,7 @@ do elseif specification.globalkerns then name = "globalkern" else - report("ignoring global kern table using gpos kern feature") + report("ignoring global kern table, using gpos kern feature") return end setposition(f,datatable.offset) diff --git a/tex/context/base/mkiv/font-ini.lua b/tex/context/base/mkiv/font-ini.lua index d42652e0e..462e30bf9 100644 --- a/tex/context/base/mkiv/font-ini.lua +++ b/tex/context/base/mkiv/font-ini.lua @@ -40,3 +40,15 @@ if context then fontloader = nil end + +-- Outside context one can bump textbase to some higher value but only the +-- textbase given here is officially supported (read: bug testing etc will +-- use the values below). + +fonts.privateoffsets = { + textbase = 0xF0000, -- used for hidden (opentype features) + textextrabase = 0xFD000, -- used for visible by name + mathextrabase = 0xFE000, -- used for visible by code + mathbase = 0xFF000, -- used for hidden (virtual math) + keepnames = false, -- when set to true names are always kept (not for context) +} diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index 62353f3c6..66fb19afe 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -21,7 +21,7 @@ local readers = otf.readers if readers then - otf.version = otf.version or 3.105 + otf.version = otf.version or 3.106 otf.cache = otf.cache or containers.define("fonts", "otl", otf.version, true) function fonts.helpers.getfeatures(name,save) diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index e2013720b..7a8e9b02e 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -52,7 +52,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.105 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.106 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) otf.svgcache = containers.define("fonts", "svg", otf.version, true) otf.sbixcache = containers.define("fonts", "sbix", otf.version, true) @@ -155,7 +155,7 @@ function otf.load(filename,sub,instance) if reload then report_otf("loading %a, hash %a",filename,hash) -- - starttiming(otfreaders) + starttiming(otfreaders,true) data = otfreaders.loadfont(filename,sub or 1,instance) -- we can pass the number instead (if it comes from a name search) if data then -- todo: make this a plugin @@ -242,6 +242,7 @@ function otf.load(filename,sub,instance) checkmemory(used,threshold,tracememory) end else + stoptiming(otfreaders) data = nil report_otf("loading failed due to read error") end diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index 70d1ef4ab..012b007d5 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -11,27 +11,34 @@ local P, R, S = lpeg.P, lpeg.R, lpeg.S local lpegmatch = lpeg.match local insert, remove, copy, unpack = table.insert, table.remove, table.copy, table.unpack -local formatters = string.formatters -local sortedkeys = table.sortedkeys -local sortedhash = table.sortedhash -local tohash = table.tohash -local setmetatableindex = table.setmetatableindex - -local report = logs.reporter("otf reader") - -local trace_markwidth = false trackers.register("otf.markwidth",function(v) trace_markwidth = v end) - -local readers = fonts.handlers.otf.readers -local privateoffset = fonts.constructors and fonts.constructors.privateoffset or 0xF0000 -- 0x10FFFF - -local f_private = formatters["P%05X"] -local f_unicode = formatters["U%05X"] -local f_index = formatters["I%05X"] -local f_character_y = formatters["%C"] -local f_character_n = formatters["[ %C ]"] - -local check_duplicates = true -- can become an option (pseudo feature) / aways needed anyway -local check_soft_hyphen = true -- can become an option (pseudo feature) / needed for tagging +local formatters = string.formatters +local sortedkeys = table.sortedkeys +local sortedhash = table.sortedhash +local tohash = table.tohash +local setmetatableindex = table.setmetatableindex + +local report_error = logs.reporter("otf reader","error") +local report_markwidth = logs.reporter("otf reader","markwidth") +local report_cleanup = logs.reporter("otf reader","cleanup") +local report_optimizations = logs.reporter("otf reader","merges") +local report_unicodes = logs.reporter("otf reader","unicodes") + +local trace_markwidth = false trackers.register("otf.markwidth", function(v) trace_markwidth = v end) +local trace_cleanup = false trackers.register("otf.cleanups", function(v) trace_cleanups = v end) +local trace_optimizations = false trackers.register("otf.optimizations", function(v) trace_optimizations = v end) +local trace_unicodes = false trackers.register("otf.unicodes", function(v) trace_unicodes = v end) + +local readers = fonts.handlers.otf.readers +local privateoffset = fonts.constructors and fonts.constructors.privateoffset or 0xF0000 -- 0x10FFFF + +local f_private = formatters["P%05X"] +local f_unicode = formatters["U%05X"] +local f_index = formatters["I%05X"] +local f_character_y = formatters["%C"] +local f_character_n = formatters["[ %C ]"] + +local check_duplicates = true -- can become an option (pseudo feature) / aways needed anyway +local check_soft_hyphen = true -- can become an option (pseudo feature) / needed for tagging directives.register("otf.checksofthyphen",function(v) check_soft_hyphen = v @@ -67,6 +74,8 @@ local function unifyresources(fontdata,indices) return end -- + local nofindices = #indices + -- local variants = fontdata.resources.variants if variants then for selector, unicodes in next, variants do @@ -83,8 +92,8 @@ local function unifyresources(fontdata,indices) local u = indices[k] if u then newmarks[u] = v - else - report("discarding mark %i",k) + elseif trace_optimizations then + report_optimizations("discarding mark %i",k) end end return newmarks @@ -123,7 +132,12 @@ local function unifyresources(fontdata,indices) if not done[c] then local t = { } for k, v in next, c do - t[indices[k]] = v + local ug = indices[k] + if ug then + t[ug] = v + else + report_error("case %i, bad index in unifying %s: %s of %s",1,"coverage",k,nofindices) + end end cover[i] = t done[c] = d @@ -131,11 +145,16 @@ local function unifyresources(fontdata,indices) end end -- - local function recursed(c) -- ligs are not packed + local function recursed(c,kind) -- ligs are not packed local t = { } for g, d in next, c do if type(d) == "table" then - t[indices[g]] = recursed(d) + local ug = indices[g] + if ug then + t[ug] = recursed(d,kind) + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g,nofindices) + end else t[g] = indices[d] -- ligature end @@ -167,19 +186,31 @@ local function unifyresources(fontdata,indices) if duplicates then for g1, d1 in next, c do local ug1 = indices[g1] - local ud1 = indices[d1] - t1[ug1] = ud1 - -- - local dg1 = duplicates[ug1] - if dg1 then - for u in next, dg1 do - t1[u] = ud1 + if ug1 then + local ud1 = indices[d1] + if ud1 then + t1[ug1] = ud1 + local dg1 = duplicates[ug1] + if dg1 then + for u in next, dg1 do + t1[u] = ud1 + end + end + else + report_error("case %i, bad index in unifying %s: %s of %s",3,kind,d1,nofindices) end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) end end else for g1, d1 in next, c do - t1[indices[g1]] = indices[d1] + local ug1 = indices[g1] + if ug1 then + t1[ug1] = indices[d1] + else + report_error("fuzzy case %i in unifying %s: %i",2,kind,g1) + end end end done[c] = t1 @@ -193,15 +224,25 @@ local function unifyresources(fontdata,indices) if not t1 then t1 = { } for g1, d1 in next, c do - local t2 = done[d1] - if not t2 then - t2 = { } - for g2, d2 in next, d1 do - t2[indices[g2]] = d2 + local ug1 = indices[g1] + if ug1 then + local t2 = done[d1] + if not t2 then + t2 = { } + for g2, d2 in next, d1 do + local ug2 = indices[g2] + if ug2 then + t2[ug2] = d2 + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g2,nofindices,nofindices) + end + end + done[d1] = t2 end - done[d1] = t2 + t1[ug1] = t2 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end - t1[indices[g1]] = t2 end done[c] = t1 end @@ -210,7 +251,7 @@ local function unifyresources(fontdata,indices) elseif kind == "gsub_ligature" then local c = step.coverage if c then - step.coverage = recursed(c) + step.coverage = recursed(c,kind) end elseif kind == "gsub_alternate" or kind == "gsub_multiple" then local c = step.coverage @@ -221,22 +262,37 @@ local function unifyresources(fontdata,indices) if duplicates then for g1, d1 in next, c do for i=1,#d1 do - d1[i] = indices[d1[i]] + local d1i = d1[i] + local d1u = indices[d1i] + if d1u then + d1[i] = d1u + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,i,d1i,nofindices) + end end local ug1 = indices[g1] - t1[ug1] = d1 - -- - local dg1 = duplicates[ug1] - if dg1 then - for u in next, dg1 do - t1[u] = copy(d1) + if ug1 then + t1[ug1] = d1 + local dg1 = duplicates[ug1] + if dg1 then + for u in next, dg1 do + t1[u] = copy(d1) + end end + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end end else for g1, d1 in next, c do for i=1,#d1 do - d1[i] = indices[d1[i]] + local d1i = d1[i] + local d1u = indices[d1i] + if d1u then + d1[i] = d1u + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,d1i,nofindices) + end end t1[indices[g1]] = d1 end @@ -245,6 +301,41 @@ local function unifyresources(fontdata,indices) end step.coverage = t1 end + elseif kind == "gpos_single" then + local c = step.coverage + if c then + local t1 = done[c] + if not t1 then + t1 = { } + if duplicates then + for g1, d1 in next, c do + local ug1 = indices[g1] + if ug1 then + t1[ug1] = d1 + local dg1 = duplicates[ug1] + if dg1 then + for u in next, dg1 do + t1[u] = d1 + end + end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) + end + end + else + for g1, d1 in next, c do + local ug1 = indices[g1] + if ug1 then + t1[ug1] = d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) + end + end + end + done[c] = t1 + end + step.coverage = t1 + end elseif kind == "gpos_mark2base" or kind == "gpos_mark2mark" or kind == "gpos_mark2ligature" then local c = step.coverage if c then @@ -252,7 +343,12 @@ local function unifyresources(fontdata,indices) if not t1 then t1 = { } for g1, d1 in next, c do - t1[indices[g1]] = d1 + local ug1 = indices[g1] + if ug1 then + t1[ug1] = d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) + end end done[c] = t1 end @@ -267,7 +363,12 @@ local function unifyresources(fontdata,indices) if not t2 then t2 = { } for g2, d2 in next, d1 do - t2[indices[g2]] = d2 + local ug2 = indices[g2] + if ug2 then + t2[ug2] = d2 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g2,nofindices) + end end done[d1] = t2 end @@ -276,7 +377,7 @@ local function unifyresources(fontdata,indices) done[c] = c end end - elseif kind == "gpos_single" then + elseif kind == "gpos_cursive" then local c = step.coverage if c then local t1 = done[c] @@ -285,47 +386,29 @@ local function unifyresources(fontdata,indices) if duplicates then for g1, d1 in next, c do local ug1 = indices[g1] - t1[ug1] = d1 - -- - local dg1 = duplicates[ug1] - if dg1 then - for u in next, dg1 do - t1[u] = d1 + if ug1 then + t1[ug1] = d1 + -- + local dg1 = duplicates[ug1] + if dg1 then + -- probably needs a bit more + for u in next, dg1 do + t1[u] = copy(d1) + end end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) end end else - for g1, d1 in next, c do - t1[indices[g1]] = d1 - end - end - done[c] = t1 - end - step.coverage = t1 - end - elseif kind == "gpos_cursive" then - local c = step.coverage - if c then - local t1 = done[c] - if not t1 then - t1 = { } - if duplicates then for g1, d1 in next, c do local ug1 = indices[g1] - t1[ug1] = d1 - -- - local dg1 = duplicates[ug1] - if dg1 then - -- probably needs a bit more - for u in next, dg1 do - t1[u] = copy(d1) - end + if ug1 then + t1[ug1] = d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end end - else - for g1, d1 in next, c do - t1[indices[g1]] = d1 - end end done[c] = t1 end @@ -376,9 +459,13 @@ local function copyduplicates(fontdata) if not ds or ds.width == 0 then if ds then descriptions[0xAD] = nil - report("patching soft hyphen") + if trace_unicodes then + report_unicodes("patching soft hyphen") + end else - report("adding soft hyphen") + if trace_unicodes then + report_unicodes("adding soft hyphen") + end end if not duplicates then duplicates = { } @@ -414,10 +501,12 @@ local function copyduplicates(fontdata) end n = n + 1 end - if n <= m then - report("duplicates: %i : % t",n,t) - else - report("duplicates: %i : % t ...",n,t) + if trace_unicodes then + if n <= m then + report_unicodes("%i : % t",n,t) + else + report_unicodes("%i : % t ...",n,t) + end end else -- what a mess @@ -548,7 +637,9 @@ local function checklookups(fontdata,missing,nofmissing) end end if nofmissing <= 0 then - report("all done in %s loops",loops) + if trace_unicodes then + report_unicodes("all missings done in %s loops",loops) + end return elseif old == nofmissing then break @@ -600,7 +691,9 @@ local function checklookups(fontdata,missing,nofmissing) recursed(ligatures[i]) end if nofmissing <= 0 then - report("all done in %s loops",loops) + if trace_unicodes then + report_unicodes("all missings done in %s loops",loops) + end return elseif old == nofmissing then break @@ -610,7 +703,7 @@ local function checklookups(fontdata,missing,nofmissing) n = 0 end - if nofmissing > 0 then + if trace_unicodes and nofmissing > 0 then local done = { } for i, r in next, missing do if r then @@ -622,7 +715,7 @@ local function checklookups(fontdata,missing,nofmissing) end end if next(done) then - report("not unicoded: % t",sortedkeys(done)) + report_unicode("not unicoded: % t",sortedkeys(done)) end end end @@ -647,6 +740,10 @@ local function unifymissing(fontdata) resources.unicodes = nil end +local firstprivate = 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 @@ -670,45 +767,107 @@ local function unifyglyphs(fontdata,usenames) indices[0] = zerocode end -- - for index=1,#glyphs do - local glyph = glyphs[index] - local unicode = glyph.unicode -- this is the primary one - -- if not unicode then -- some fonts use the private space - if not unicode or unicode >= private or (unicode >= 0xE000 and unicode <= 0xF8FF) or unicode == 0xFFFE or unicode == 0xFFFF then - -- report("assigning private unicode %U to glyph indexed %05X (%s)",private,index,"unset") - unicode = private - -- glyph.unicode = -1 - if names then + if names then + -- seldom uses, we don't issue message ... this branch might even go away + for index=1,#glyphs do + local glyph = glyphs[index] + local unicode = glyph.unicode -- this is the primary one + if not unicode then + unicode = private local name = glyph.name or f_private(unicode) indices[index] = name names[name] = unicode - else - indices[index] = unicode - end - private = private + 1 - elseif descriptions[unicode] then - -- real weird - report("assigning private unicode %U to glyph indexed %05X (%C)",private,index,unicode) - unicode = private - -- glyph.unicode = -1 - if names then + private = private + 1 + elseif unicode >= firstprivate then + unicode = private + local name = glyph.name or f_private(unicode) + indices[index] = name + names[name] = unicode + private = private + 1 + elseif unicode >= puafirst and unicode <= pualast then local name = glyph.name or f_private(unicode) indices[index] = name names[name] = unicode + elseif descriptions[unicode] then + unicode = private + local name = glyph.name or f_private(unicode) + indices[index] = name + names[name] = unicode + private = private + 1 else - indices[index] = unicode - end - private = private + 1 - else - if names then local name = glyph.name or f_unicode(unicode) indices[index] = name names[name] = unicode + end + descriptions[unicode] = glyph + end + elseif trace_unicodes then + for index=1,#glyphs do + local glyph = glyphs[index] + local unicode = glyph.unicode -- this is the primary one + if not unicode then + unicode = private + indices[index] = unicode + private = private + 1 + elseif unicode >= firstprivate then + local name = glyph.name + if name then + report_unicodes("moving glyph %a indexed %05X from private %U to %U ",name,index,unicode,private) + else + report_unicodes("moving glyph indexed %05X from private %U to %U ",index,unicode,private) + end + unicode = private + indices[index] = unicode + private = private + 1 + elseif unicode >= puafirst and unicode <= pualast then + local name = glyph.name + if name then + report_unicodes("keeping private unicode %U for glyph %a indexed %05X",unicode,name,index) + else + report_unicodes("keeping private unicode %U for glyph indexed %05X",unicode,index) + end + indices[index] = unicode + elseif descriptions[unicode] then + local name = glyph.name + if name then + report_unicodes("assigning duplicate unicode %U to %U for glyph %a indexed %05X ",unicode,private,name,index) + else + report_unicodes("assigning duplicate unicode %U to %U for glyph indexed %05X ",unicode,private,index) + end + unicode = private + indices[index] = unicode + private = private + 1 + else + indices[index] = unicode + end + descriptions[unicode] = glyph + end + else + for index=1,#glyphs do + local glyph = glyphs[index] + local unicode = glyph.unicode -- this is the primary one + if not unicode then + unicode = private + indices[index] = unicode + private = private + 1 + elseif unicode >= firstprivate then + local name = glyph.name + unicode = private + indices[index] = unicode + private = private + 1 + elseif unicode >= puafirst and unicode <= pualast then + local name = glyph.name + indices[index] = unicode + elseif descriptions[unicode] then + local name = glyph.name + unicode = private + indices[index] = unicode + private = private + 1 else indices[index] = unicode end + descriptions[unicode] = glyph end - descriptions[unicode] = glyph end -- for index=1,#glyphs do @@ -761,29 +920,42 @@ local p_bogusname = ( (P("uni") + P("UNI") + P("Uni") + P("U") + P("u")) * S("Xx")^0 * R("09","AF")^1 + (P("identity") + P("Identity") + P("IDENTITY")) * R("09","AF")^1 + (P("index") + P("Index") + P("INDEX")) * R("09")^1 -) * P(-1) +) * (P(-1) + P(".")) + local function stripredundant(fontdata) local descriptions = fontdata.descriptions if descriptions then local n = 0 local c = 0 - for unicode, d in next, descriptions do - local name = d.name - if name and lpegmatch(p_bogusname,name) then - d.name = nil - n = n + 1 + -- in context we always strip + if not context and fonts.privateoffsets.keepnames then + for unicode, d in next, descriptions do + if d.class == "base" then + d.class = nil + c = c + 1 + end end - if d.class == "base" then - d.class = nil - c = c + 1 + else + for unicode, d in next, descriptions do + local name = d.name + if name and lpegmatch(p_bogusname,name) then + d.name = nil + n = n + 1 + end + if d.class == "base" then + d.class = nil + c = c + 1 + end end end - if n > 0 then - report("%s bogus names removed (verbose unicode)",n) - end - if c > 0 then - report("%s base class tags removed (default is base)",c) + if trace_cleanup then + if n > 0 then + report_cleanup("%s bogus names removed (verbose unicode)",n) + end + if c > 0 then + report_cleanup("%s base class tags removed (default is base)",c) + end end end end @@ -2125,12 +2297,16 @@ local function mergesteps_1(lookup,strict) local f = first.format for i=2,nofsteps do if steps[i].format ~= f then - report("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + end return 0 end end end - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target = first.coverage for i=2,nofsteps do local c = steps[i].coverage @@ -2159,12 +2335,16 @@ local function mergesteps_2(lookup) -- pairs local f = first.format for i=2,nofsteps do if steps[i].format ~= f then - report("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + end return 0 end end end - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target = first.coverage for i=2,nofsteps do local c = steps[i].coverage @@ -2195,7 +2375,9 @@ end local function mergesteps_3(lookup,strict) -- marks local steps = lookup.steps local nofsteps = lookup.nofsteps - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end -- check first local coverage = { } for i=1,nofsteps do @@ -2204,7 +2386,9 @@ local function mergesteps_3(lookup,strict) -- marks for k, v in next, c do local tk = coverage[k] -- { class, { x, y } } if tk then - report("quitting merge due to multiple checks") + if trace_optimizations then + report_optimizations("quitting merge due to multiple checks") + end return nofsteps else coverage[k] = v @@ -2254,7 +2438,9 @@ local function mergesteps_4(lookup) -- ligatures local steps = lookup.steps local nofsteps = lookup.nofsteps local first = steps[1] - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target = first.coverage for i=2,nofsteps do local c = steps[i].coverage @@ -2282,7 +2468,9 @@ local function mergesteps_5(lookup) -- cursive local steps = lookup.steps local nofsteps = lookup.nofsteps local first = steps[1] - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target = first.coverage local hash = nil for k, v in next, target do @@ -2334,7 +2522,9 @@ local function checkkerns(lookup) end end if kerns then - report("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + end local c = { } for g1, d1 in next, coverage do if d1 and d1 ~= true then @@ -2394,7 +2584,9 @@ local function checkpairs(lookup) if step.format == "pair" then local coverage = onlykerns(step) if coverage then - report("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + end for g1, d1 in next, coverage do local d = { } for g2, d2 in next, d1 do @@ -2517,17 +2709,19 @@ function readers.compact(data) end end end - else - report("no lookups in %a",what) + elseif trace_optimizations then + report_optimizations("no lookups in %a",what) end end compact("sequences") compact("sublookups") - if merged > 0 then - report("%i steps of %i removed due to merging",merged,allsteps) - end - if kerned > 0 then - report("%i steps of %i steps turned from pairs into kerns",kerned,allsteps) + if trace_optimizations then + if merged > 0 then + report_optimizations("%i steps of %i removed due to merging",merged,allsteps) + end + if kerned > 0 then + report_optimizations("%i steps of %i steps turned from pairs into kerns",kerned,allsteps) + end end end @@ -2627,7 +2821,7 @@ function readers.expand(data) -- or bb? d.width = defaultwidth elseif trace_markwidth and wd ~= 0 and d.class == "mark" then - report("mark %a with width %b found in %a",d.name or "",wd,basename) + report_markwidth("mark %a with width %b found in %a",d.name or "",wd,basename) end if bb then local ht = bb[4] diff --git a/tex/context/base/mkiv/font-prv.lua b/tex/context/base/mkiv/font-prv.lua index 914e9ccdf..20c06d2e5 100644 --- a/tex/context/base/mkiv/font-prv.lua +++ b/tex/context/base/mkiv/font-prv.lua @@ -15,8 +15,8 @@ local fontdata = fonts.hashes.identifiers local setmetatableindex = table.setmetatableindex -local currentprivate = 0xE000 -local maximumprivate = 0xEFFF +local currentprivate = fonts.privateoffsets.textextrabase +local maximumprivate = currentprivate + 0xFFF local extraprivates = { } helpers.extraprivates = extraprivates diff --git a/tex/context/base/mkiv/good-ctx.lua b/tex/context/base/mkiv/good-ctx.lua index b7dd15fb8..0ab10fdfc 100644 --- a/tex/context/base/mkiv/good-ctx.lua +++ b/tex/context/base/mkiv/good-ctx.lua @@ -99,10 +99,10 @@ local function setcolorscheme(tfmdata,scheme) end end if privatestoo then - local private = fonts.constructors.privateoffset - local descriptions = tfmdata.descriptions + local privateoffset = fonts.constructors.privateoffset + local descriptions = tfmdata.descriptions for unicode, data in next, characters do - if unicode >= private then + if unicode >= privateoffset then if not reverse[unicode] then local d = descriptions[unicode] if d then diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua index ff37e7b6d..09084606d 100644 --- a/tex/context/base/mkiv/grph-inc.lua +++ b/tex/context/base/mkiv/grph-inc.lua @@ -2071,7 +2071,7 @@ implement { -- new (lightweight, small and statically compiled) library. More on that later. -- -- The method implemented below has the same performance as the hard coded inclusion --- but opens up some possibilities (like merhing fonts) that I will look into some +-- but opens up some possibilities (like merging fonts) that I will look into some -- day. local function pdf_checker(data) diff --git a/tex/context/base/mkiv/java-imp-fld.mkiv b/tex/context/base/mkiv/java-imp-fld.mkiv index 6e51681b0..559ab01b3 100644 --- a/tex/context/base/mkiv/java-imp-fld.mkiv +++ b/tex/context/base/mkiv/java-imp-fld.mkiv @@ -297,7 +297,7 @@ function Field_Name(FieldSet,i) { function Reset_Fields(FieldSet) { var i = 1 ; while (true) { - v = Field_Name(FieldSet,i) ; + var v = Field_Name(FieldSet,i) ; if (!v) { break ; } else { @@ -311,7 +311,7 @@ function Reset_Fields(FieldSet) { function Set_Fields(FieldSet) { var i = 1 ; while (true) { - v = Field_Name(FieldSet,i) ; + var v = Field_Name(FieldSet,i) ; if (!v) { break ; } else { @@ -324,7 +324,7 @@ function Set_Fields(FieldSet) { function Set_Field(FieldSet, FieldName) { Reset_Fields(FieldSet) ; - v = Field_Name(FieldSet,FieldName) ; + var v = Field_Name(FieldSet,FieldName) ; if (v) { v.value = "Yes" ; this.dirty = false ; @@ -333,7 +333,7 @@ function Set_Field(FieldSet, FieldName) { function Reset_Field(FieldSet, FieldName) { Set_Fields(FieldSet) ; - v = Field_Name(FieldSet,FieldName) ; + var v = Field_Name(FieldSet,FieldName) ; if (v) { v.value = "Off" ; this.dirty = false ; @@ -342,16 +342,16 @@ function Reset_Field(FieldSet, FieldName) { function Walk_Field(FieldSet) { var i = 1 ; + this.syncAnnotScan(); while (true) { - v = Field_Name(FieldSet,i) ; + var v = Field_Name(FieldSet,i) ; if (v) { if (v.value != "Off") { v.value = "Off" ; - var ii = i ; - ii++ ; - v = Field_Name(FieldSet,ii) ; + v = Field_Name(FieldSet,i + 1) ; if (! v) { v = Field_Name(FieldSet,1) ; + } else { } if (v) { v.value = "Yes" ; @@ -360,6 +360,10 @@ function Walk_Field(FieldSet) { } i++ ; } else { + v = Field_Name(FieldSet,1) ; + if (v) { + v.value = "Yes" ; + } break ; } } diff --git a/tex/context/base/mkiv/java-ini.lua b/tex/context/base/mkiv/java-ini.lua index a8868da60..b41b065e8 100644 --- a/tex/context/base/mkiv/java-ini.lua +++ b/tex/context/base/mkiv/java-ini.lua @@ -124,8 +124,9 @@ function javascripts.usepreamblenow(name) -- now later local names = settings_to_array(name) for i=1,#names do local somename = names[i] - if not preambled[somename] then - preambles[preambled[somename]][2] = "now" + local preamble = preambled[somename] + if preamble then + preambles[preamble][2] = "now" if trace_javascript then report_javascripts("used preamble %a, state %a, order %a",somename,"now","auto") end diff --git a/tex/context/base/mkiv/java-ini.mkiv b/tex/context/base/mkiv/java-ini.mkiv index e412b9d06..1a131d9da 100644 --- a/tex/context/base/mkiv/java-ini.mkiv +++ b/tex/context/base/mkiv/java-ini.mkiv @@ -156,4 +156,10 @@ {\clf_usejavascriptscripts {#1}% two steps as this one calls tex code \clf_usejavascriptpreamble{#2}}% so this one comes later +\unexpanded\def\useJSpreamble + {\dosingleempty\java_use_preamble} + +\def\java_use_preamble[#1]% + {\clf_usejavascriptpreamble{#1}}% so this one comes later + \protect \endinput diff --git a/tex/context/base/mkiv/lpdf-fld.lua b/tex/context/base/mkiv/lpdf-fld.lua index dea5c16d7..983be508f 100644 --- a/tex/context/base/mkiv/lpdf-fld.lua +++ b/tex/context/base/mkiv/lpdf-fld.lua @@ -412,86 +412,6 @@ local function fieldappearances(specification) -- return pdfreference(pdfflushobject(appearance)) end --- local YesorOn = "Yes" -- somehow On is not always working out well any longer (why o why this change) - --- beware ... maybe we should have unique /Yes1 ... we will probably --- change this one too. --- --- TODO: the same as radio .. play safe and use different names. - --- local function fieldstates_check(specification,forceyes,values,default,yesdefault) --- -- we don't use Opt here (too messy for radio buttons) --- local values, default = values or specification.values, default or specification.default --- if not values or values == "" then --- -- error --- return --- end --- local v = settings_to_array(values) --- local yes, off, yesn, yesr, yesd, offn, offr, offd --- if #v == 1 then --- yes, off = v[1], v[1] --- else --- yes, off = v[1], v[2] --- end --- local yesshown, yesvalue = lpegmatch(splitter,yes) --- if not (yesshown and yesvalue) then --- yesshown = yes, yes --- end --- yes = settings_to_array(yesshown) --- local offshown, offvalue = lpegmatch(splitter,off) --- if not (offshown and offvalue) then --- offshown = off, off --- end --- off = settings_to_array(offshown) --- if #yes == 1 then --- yesn, yesr, yesd = yes[1], yes[1], yes[1] --- elseif #yes == 2 then --- yesn, yesr, yesd = yes[1], yes[1], yes[2] --- else --- yesn, yesr, yesd = yes[1], yes[2], yes[3] --- end --- if #off == 1 then --- offn, offr, offd = off[1], off[1], off[1] --- elseif #off == 2 then --- offn, offr, offd = off[1], off[1], off[2] --- else --- offn, offr, offd = off[1], off[2], off[3] --- end --- if forceyes == true then --- forceyes = YesorOn -- spec likes Yes more but we've used On for ages now --- else --- -- false or string --- end --- if not yesvalue then --- yesvalue = yesdefault or yesn --- end --- if not offvalue then --- offvalue = offn --- end --- if default == yesn then --- default = pdfconstant(forceyes or yesn) --- else --- default = pdf_off --- end --- local appearance --- if false then -- needs testing --- appearance = pdfdictionary { -- maybe also cache components --- N = pdfshareobjectreference(pdfdictionary { [forceyes or yesn] = registeredsymbol(yesn), Off = registeredsymbol(offn) }), --- R = pdfshareobjectreference(pdfdictionary { [forceyes or yesr] = registeredsymbol(yesr), Off = registeredsymbol(offr) }), --- D = pdfshareobjectreference(pdfdictionary { [forceyes or yesd] = registeredsymbol(yesd), Off = registeredsymbol(offd) }), --- } --- else --- appearance = pdfdictionary { -- maybe also cache components --- N = pdfdictionary { [forceyes or yesn] = registeredsymbol(yesn), Off = registeredsymbol(offn) }, --- R = pdfdictionary { [forceyes or yesr] = registeredsymbol(yesr), Off = registeredsymbol(offr) }, --- D = pdfdictionary { [forceyes or yesd] = registeredsymbol(yesd), Off = registeredsymbol(offd) } --- } --- end --- local appearanceref = pdfshareobjectreference(appearance) --- -- local appearanceref = pdfreference(pdfflushobject(appearance)) --- return appearanceref, default, yesvalue --- end - -- The rendering part of form support has always been crappy and didn't really -- improve over time. Did bugs become features? Who knows. Why provide for instance -- control over appearance and then ignore it when the mouse clicks someplace else. @@ -511,10 +431,24 @@ end -- as well be the reason why no open source viewer ever bothered implementing forms. It's -- probably also why most forms out there look kind of bad. -local function fieldstates_check(specification,forceyes,values,default,yesdefault) +local function fieldstates_precheck(specification) + local values = specification.values + local default = specification.default + if not values or values == "" then + return + end + local yes = settings_to_array(values)[1] + local yesshown, yesvalue = lpegmatch(splitter,yes) + if not (yesshown and yesvalue) then + yesshown = yes + end + return default == settings_to_array(yesshown)[1] and pdf_yes or pdf_off +end + +local function fieldstates_check(specification) -- we don't use Opt here (too messy for radio buttons) - local values = values or specification.values - local default = default or specification.default + local values = specification.values + local default = specification.default if not values or values == "" then -- error return @@ -557,17 +491,16 @@ local function fieldstates_check(specification,forceyes,values,default,yesdefaul offvalue = offn end if default == yesn then - default = pdf_yes - else - default = pdf_off - end - if yesvalue == yesn then - yesvalue = "Yes" + default = pdf_yes + yesvalue = yesvalue == yesn and "Yes" or "Off" else + default = pdf_off yesvalue = "Off" end local appearance - if false then -- needs testing + -- if false then + if true then + -- needs testing appearance = pdfdictionary { -- maybe also cache components N = pdfshareobjectreference(pdfdictionary { Yes = registeredsymbol(yesn), Off = registeredsymbol(offn) }), R = pdfshareobjectreference(pdfdictionary { Yes = registeredsymbol(yesr), Off = registeredsymbol(offr) }), @@ -1276,6 +1209,7 @@ function methods.combo(name,specification) end local function makecheckparent(field,specification) + local default = fieldstates_precheck(field) local d = pdfdictionary { T = pdfunicode(specification.title), -- todo: when tracing use a string F = fieldplus(specification), @@ -1283,7 +1217,7 @@ local function makecheckparent(field,specification) OC = fieldlayer(specification), AA = fieldactions(specification), -- can be shared FT = pdf_btn, - V = fielddefault(field,pdf_yes), + V = fielddefault(field,default), } save_parent(field,specification,d,true) end @@ -1329,10 +1263,10 @@ local function makecheckchild(name,specification) d.MK = fieldrendering(specification) return save_kid(parent,specification,d) else - local appearance, default, value = fieldstates_check(field,true) + local appearance, default, value = fieldstates_check(field) d.AS = default d.AP = appearance - return save_kid(parent,specification,d,value) + return save_kid(parent,specification,d) end end diff --git a/tex/context/base/mkiv/math-ext.lua b/tex/context/base/mkiv/math-ext.lua index 15a93d62e..b923853f4 100644 --- a/tex/context/base/mkiv/math-ext.lua +++ b/tex/context/base/mkiv/math-ext.lua @@ -30,7 +30,7 @@ local mathplus = { } local function addextra(unicode) local min = mathematics.extrabase - local max = mathematics.privatebase - 1 + local max = min + 0xFFF if unicode >= min and unicode <= max then if chardata[unicode] then mathplus[unicode] = true diff --git a/tex/context/base/mkiv/math-ini.lua b/tex/context/base/mkiv/math-ini.lua index d301b0065..5491078f3 100644 --- a/tex/context/base/mkiv/math-ini.lua +++ b/tex/context/base/mkiv/math-ini.lua @@ -36,8 +36,15 @@ local report_math = logs.reporter("mathematics","initializing") mathematics = mathematics or { } local mathematics = mathematics -mathematics.extrabase = 0xFE000 -- here we push some virtuals -mathematics.privatebase = 0xFF000 -- here we push the ex +mathematics.extrabase = fonts.privateoffsets.mathextrabase -- here we push some virtuals +mathematics.privatebase = fonts.privateoffsets.mathbase -- here we push the ex + +fonts.privateoffsets = { + textbase = 0xF0000, -- used for hidden (opentype features) + textextrabase = 0xFD000, -- used for visible by name + mathextrabase = 0xFE000, -- used for visible by code + mathbase = 0xFF000, -- used for hidden (virtual math) +} local unsetvalue = attributes.unsetvalue local allocate = utilities.storage.allocate diff --git a/tex/context/base/mkiv/mtx-context-xml.tex b/tex/context/base/mkiv/mtx-context-xml.tex index f8bfeef3a..875f02da6 100644 --- a/tex/context/base/mkiv/mtx-context-xml.tex +++ b/tex/context/base/mkiv/mtx-context-xml.tex @@ -76,6 +76,11 @@ if template then moduledata.xml.analyzers.allsetups(files,type(template) == "string" and template or nil) end + context.page() + for i=1,#files do + context.type(files[i]) + context.par() + end else context("no action given") end diff --git a/tex/context/base/mkiv/scrn-fld.mkvi b/tex/context/base/mkiv/scrn-fld.mkvi index 7327f7c14..41d117480 100644 --- a/tex/context/base/mkiv/scrn-fld.mkvi +++ b/tex/context/base/mkiv/scrn-fld.mkvi @@ -756,7 +756,8 @@ {\ifcsname\??fieldstack#tag\endcsname % already done \else - \setgvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][#settings]}% + %setgvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][#settings]}% + \setxvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][\normalunexpanded{#settings}]}% \fi} \unexpanded\def\fieldstack @@ -770,26 +771,28 @@ \newbox\b_scrn_fieldstack_box +\definesymbol[\s!empty][] + \def\scrn_fieldstack_add#tag#settings#symbol% {\advance\scratchcounter\plusone \edef\currentfieldstackname{#tag:\number\scratchcounter}% \ifnum\scratchcounter=\fieldcategoryparameter\c!start\relax - \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\empty},\c!default={#symbol}]% + \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\s!empty},\c!default={#symbol}]% \else - \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\empty},\c!default=]% + \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\s!empty},\c!default=\s!empty]% \fi \setbox\b_scrn_fieldstack_box\hbox{\symbol[#symbol]}% \setcollector [fieldstack] {\fieldbody [\currentfieldstackname] - [\c!option=\v!readonly, + [\c!option={\v!readonly}, \c!width=\wd\b_scrn_fieldstack_box, \c!height=\ht\b_scrn_fieldstack_box, \c!depth=\dp\b_scrn_fieldstack_box, #settings]}} -\def\scrn_fieldstack_construct[#tag][#symbols][#settings]% start=n, 0 == leeg +\unexpanded\def\scrn_fieldstack_construct[#tag][#symbols][#settings]% start=n, 0 == leeg {\iflocation \dontleavehmode \begingroup diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index b95443a9a..8e33d0576 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index 0e8d79426..7ce0ed38d 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-def.mkiv b/tex/context/base/mkiv/strc-def.mkiv index 8d1fa371f..941f561c8 100644 --- a/tex/context/base/mkiv/strc-def.mkiv +++ b/tex/context/base/mkiv/strc-def.mkiv @@ -65,6 +65,17 @@ \setsectionblock [\v!bodypart] % default +% \setuphead[sectionsegments=\currentheadlevel] +% \setuphead[sectionsegments=current] +% +% \startchapter[title=One,ownnumber={A}] +% \startsection[title=OneOne,ownnumber={A.B}] +% \startsubsection[title=OneOneOne,ownnumber={A.B.C}] +% test +% \stopsubsection +% \stopsection +% \stopchapter + % \appendtoks % \setsectionblock[\v!bodypart]% default % \to \everyjob diff --git a/tex/context/base/mkiv/strc-doc.lua b/tex/context/base/mkiv/strc-doc.lua index f2674ea5a..3445cbd24 100644 --- a/tex/context/base/mkiv/strc-doc.lua +++ b/tex/context/base/mkiv/strc-doc.lua @@ -38,6 +38,7 @@ local v_auto = variables.auto local v_strict = variables.strict local v_all = variables.all local v_positive = variables.positive +local v_current = variables.current local trace_sectioning = false trackers.register("structures.sectioning", function(v) trace_sectioning = v end) local trace_detail = false trackers.register("structures.detail", function(v) trace_detail = v end) @@ -718,7 +719,10 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref end -- local firstprefix, lastprefix = 0, 16 -- too much, could max found level - if segments then + if segments == v_current then + firstprefix = data.depth + lastprefix = firstprefix + elseif segments then local f, l = match(tostring(segments),"^(.-):(.+)$") if l == "*" or l == v_all then l = 100 -- new diff --git a/tex/context/base/mkiv/tabl-xtb.mkvi b/tex/context/base/mkiv/tabl-xtb.mkvi index 0f8c4f214..ec0e9c25b 100644 --- a/tex/context/base/mkiv/tabl-xtb.mkvi +++ b/tex/context/base/mkiv/tabl-xtb.mkvi @@ -276,6 +276,8 @@ \let\tabl_x_start_cell_nop\relax \let\tabl_x_stop_cell \relax +\newtoks\t_table_x_cleanup + \unexpanded\def\tabl_x_process {\begingroup % * \forgetall % moved here @@ -358,6 +360,7 @@ \dostoptagged \resetbuffer[\tabl_x_current_buffer]% \resetcharacteralign + \the\t_table_x_cleanup \egroup} % text flow split modes @@ -929,7 +932,7 @@ \tabl_x_collect_allocate \fi \ifx\m_tabl_x_swapped_settings\empty - \gtoksapp\t_tabl_x_swapped{\tabl_x_c_cell_start#content\tabl_x_c_cell_stop} + \gtoksapp\t_tabl_x_swapped{\tabl_x_c_cell_start{}#content\tabl_x_c_cell_stop} \else \gtoksapp\t_tabl_x_swapped\expandafter{\expandafter\tabl_x_c_cell_start\expandafter{\m_tabl_x_swapped_settings}#content\tabl_x_c_cell_stop}% \fi} @@ -947,6 +950,11 @@ \unexpanded\def\stopxcolumn {\endgroup} +\appendtoks + \dorecurse\c_tabl_x_swapped_max + {\global\csname\??xtableswap\number#1\endcsname\emptytoks}% +\to \t_table_x_cleanup + %D \stopbuffer %D \setupxtable[one][foregroundcolor=red] %D \setupxtable[two][foregroundcolor=blue] diff --git a/tex/context/base/mkiv/trac-inf.lua b/tex/context/base/mkiv/trac-inf.lua index 51893d585..6c08f34f6 100644 --- a/tex/context/base/mkiv/trac-inf.lua +++ b/tex/context/base/mkiv/trac-inf.lua @@ -82,9 +82,13 @@ local seconds = function(n) return n or 0 end -- -- end -local function starttiming(instance) +local function starttiming(instance,reset) local timer = timers[instance or "notimer"] local it = timer.timing + if reset then + it = 0 + timer.loadtime = 0 + end if it == 0 then timer.starttime = ticks() if not timer.loadtime then diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 3ba9baa31..8bef643de 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -1247,6 +1247,7 @@ + diff --git a/tex/context/interface/mkiv/context-en.xml b/tex/context/interface/mkiv/context-en.xml index d53aebac3..9b1cbd0c2 100644 --- a/tex/context/interface/mkiv/context-en.xml +++ b/tex/context/interface/mkiv/context-en.xml @@ -1595,6 +1595,7 @@ + @@ -6734,6 +6735,7 @@ + @@ -20422,6 +20424,7 @@ + @@ -33248,6 +33251,7 @@ + @@ -33462,6 +33466,7 @@ + @@ -33675,6 +33680,7 @@ + @@ -34750,6 +34756,7 @@ + diff --git a/tex/context/interface/mkiv/i-common-value.xml b/tex/context/interface/mkiv/i-common-value.xml index 22db8a1b6..ba90de3be 100644 --- a/tex/context/interface/mkiv/i-common-value.xml +++ b/tex/context/interface/mkiv/i-common-value.xml @@ -100,6 +100,7 @@ + diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index ddec39373..7137482f0 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index a45f8b996..4b64b52c2 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/context/modules/mkiv/s-fonts-system.lua b/tex/context/modules/mkiv/s-fonts-system.lua index 5b58a4a53..b91b3e75d 100644 --- a/tex/context/modules/mkiv/s-fonts-system.lua +++ b/tex/context/modules/mkiv/s-fonts-system.lua @@ -36,8 +36,7 @@ local context = context local NC, NR, HL = context.NC, context.NR, context.HL local bold = context.bold -function moduledata.fonts.system.showinstalled(specification) - specification = interfaces.checkedspecification(specification) +local function allfiles(specification) local pattern = lower(specification.pattern or "") local list = fonts.names.list(pattern,false,true) if list then @@ -45,6 +44,14 @@ function moduledata.fonts.system.showinstalled(specification) for k, v in next, list do files[file.basename(string.lower(v.filename))] = v end + return files + end +end + +function moduledata.fonts.system.showinstalled(specification) + specification = interfaces.checkedspecification(specification) + local files = allfiles(specification) + if files then context.starttabulate { "|Tl|Tl|Tl|Tl|Tl|Tl|" } HL() NC() bold("filename") @@ -67,3 +74,31 @@ function moduledata.fonts.system.showinstalled(specification) context.stoptabulate() end end + +function moduledata.fonts.system.cacheinstalled(specification) + specification = interfaces.checkedspecification(specification) + local files = allfiles(specification) + if files then + local threshold = tonumber(specification.threshold) + for filename, data in table.sortedpairs(files) do + if string.find(filename," ") then + -- skip this one + else + local s = file.suffix(filename) + if s == "otf" or s == "ttf" then + local fullname = resolvers.findfile(filename) + context.start() + context.type(fullname) + context.par() + if threshold and file.size(fullname) > threshold then + logs.report("fonts","ignoring : %s",fullname) + else + logs.report("fonts","caching : %s",fullname) + context.definedfont { filename } + end + context.stop() + end + end + end + end +end diff --git a/tex/context/modules/mkiv/s-fonts-system.mkiv b/tex/context/modules/mkiv/s-fonts-system.mkiv index 6d9082a6b..a9d33d27e 100644 --- a/tex/context/modules/mkiv/s-fonts-system.mkiv +++ b/tex/context/modules/mkiv/s-fonts-system.mkiv @@ -24,7 +24,8 @@ \registerctxluafile{s-fonts-system}{} -\installmodulecommandluasingle \showinstalledfonts {moduledata.fonts.system.showinstalled} +\installmodulecommandluasingle \showinstalledfonts {moduledata.fonts.system.showinstalled} +\installmodulecommandluasingle \cacheinstalledfonts {moduledata.fonts.system.cacheinstalled} \stopmodule @@ -34,6 +35,7 @@ \starttext - \showinstalledfonts +% \showinstalledfonts + \cacheinstalledfonts[threshold=4000000] \stoptext diff --git a/tex/context/modules/mkiv/s-xml-analyzers.lua b/tex/context/modules/mkiv/s-xml-analyzers.lua index 6e7f7f2ba..93c6c37b6 100644 --- a/tex/context/modules/mkiv/s-xml-analyzers.lua +++ b/tex/context/modules/mkiv/s-xml-analyzers.lua @@ -230,6 +230,12 @@ local f_template = formatters [ [[ %% setups +\xmlregistersetup{xml:presets:all} + +\starttext + \xmlprocessfile{main}{somefile.xml}{} +\stoptext + %s ]] ] diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index ba46a517f..ccf6d3a7c 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 : 09/30/18 19:32:19 +-- merge date : 10/02/18 23:17:57 do -- begin closure to overcome local limits and interference @@ -9067,6 +9067,13 @@ if context then --removed end +fonts.privateoffsets={ + textbase=0xF0000, + textextrabase=0xFD000, + mathextrabase=0xFE000, + mathbase=0xFF000, + keepnames=false, +} end -- closure @@ -9137,7 +9144,7 @@ constructors.autocleanup=true constructors.namemode="fullpath" constructors.version=1.01 constructors.cache=containers.define("fonts","constructors",constructors.version,false) -constructors.privateoffset=0xF0000 +constructors.privateoffset=fonts.privateoffsets.textbase or 0xF0000 constructors.cacheintex=true local designsizes=allocate() constructors.designsizes=designsizes @@ -17159,7 +17166,7 @@ if not modules then modules={} end modules ['font-dsp']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local next,type=next,type +local next,type,tonumber=next,type,tonumber local band=bit32.band local extract=bit32.extract local bor=bit32.bor @@ -17944,8 +17951,9 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n rules=rules, } elseif subtype==3 then - local current=readarray(f) + local nofglyphs=readushort(f) local noflookups=readushort(f) + local current=readcardinaltable(f,nofglyphs,ushort) local lookups=readlookuparray(f,noflookups,#current) current=readcoveragearray(f,tableoffset,current,true) return { @@ -19025,7 +19033,6 @@ do if not rlookups then report_issue(i,what,sequence,"no") elseif not next(rlookups) then - report_issue(i,what,sequence,"empty") rule.lookups=nil else local length=#rlookups @@ -19214,7 +19221,7 @@ do elseif specification.globalkerns then name="globalkern" else - report("ignoring global kern table using gpos kern feature") + report("ignoring global kern table, using gpos kern feature") return end setposition(f,datatable.offset) @@ -20181,8 +20188,15 @@ local sortedkeys=table.sortedkeys local sortedhash=table.sortedhash local tohash=table.tohash local setmetatableindex=table.setmetatableindex -local report=logs.reporter("otf reader") +local report_error=logs.reporter("otf reader","error") +local report_markwidth=logs.reporter("otf reader","markwidth") +local report_cleanup=logs.reporter("otf reader","cleanup") +local report_optimizations=logs.reporter("otf reader","merges") +local report_unicodes=logs.reporter("otf reader","unicodes") local trace_markwidth=false trackers.register("otf.markwidth",function(v) trace_markwidth=v end) +local trace_cleanup=false trackers.register("otf.cleanups",function(v) trace_cleanups=v end) +local trace_optimizations=false trackers.register("otf.optimizations",function(v) trace_optimizations=v end) +local trace_unicodes=false trackers.register("otf.unicodes",function(v) trace_unicodes=v end) local readers=fonts.handlers.otf.readers local privateoffset=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 local f_private=formatters["P%05X"] @@ -20223,6 +20237,7 @@ local function unifyresources(fontdata,indices) if not descriptions or not resources then return end + local nofindices=#indices local variants=fontdata.resources.variants if variants then for selector,unicodes in next,variants do @@ -20238,8 +20253,8 @@ local function unifyresources(fontdata,indices) local u=indices[k] if u then newmarks[u]=v - else - report("discarding mark %i",k) + elseif trace_optimizations then + report_optimizations("discarding mark %i",k) end end return newmarks @@ -20272,18 +20287,28 @@ local function unifyresources(fontdata,indices) if not done[c] then local t={} for k,v in next,c do - t[indices[k]]=v + local ug=indices[k] + if ug then + t[ug]=v + else + report_error("case %i, bad index in unifying %s: %s of %s",1,"coverage",k,nofindices) + end end cover[i]=t done[c]=d end end end - local function recursed(c) + local function recursed(c,kind) local t={} for g,d in next,c do if type(d)=="table" then - t[indices[g]]=recursed(d) + local ug=indices[g] + if ug then + t[ug]=recursed(d,kind) + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g,nofindices) + end else t[g]=indices[d] end @@ -20311,18 +20336,31 @@ local function unifyresources(fontdata,indices) if duplicates then for g1,d1 in next,c do local ug1=indices[g1] - local ud1=indices[d1] - t1[ug1]=ud1 - local dg1=duplicates[ug1] - if dg1 then - for u in next,dg1 do - t1[u]=ud1 + if ug1 then + local ud1=indices[d1] + if ud1 then + t1[ug1]=ud1 + local dg1=duplicates[ug1] + if dg1 then + for u in next,dg1 do + t1[u]=ud1 + end + end + else + report_error("case %i, bad index in unifying %s: %s of %s",3,kind,d1,nofindices) end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) end end else for g1,d1 in next,c do - t1[indices[g1]]=indices[d1] + local ug1=indices[g1] + if ug1 then + t1[ug1]=indices[d1] + else + report_error("fuzzy case %i in unifying %s: %i",2,kind,g1) + end end end done[c]=t1 @@ -20336,15 +20374,25 @@ local function unifyresources(fontdata,indices) if not t1 then t1={} for g1,d1 in next,c do - local t2=done[d1] - if not t2 then - t2={} - for g2,d2 in next,d1 do - t2[indices[g2]]=d2 + local ug1=indices[g1] + if ug1 then + local t2=done[d1] + if not t2 then + t2={} + for g2,d2 in next,d1 do + local ug2=indices[g2] + if ug2 then + t2[ug2]=d2 + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g2,nofindices,nofindices) + end + end + done[d1]=t2 end - done[d1]=t2 + t1[ug1]=t2 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end - t1[indices[g1]]=t2 end done[c]=t1 end @@ -20353,7 +20401,7 @@ local function unifyresources(fontdata,indices) elseif kind=="gsub_ligature" then local c=step.coverage if c then - step.coverage=recursed(c) + step.coverage=recursed(c,kind) end elseif kind=="gsub_alternate" or kind=="gsub_multiple" then local c=step.coverage @@ -20364,21 +20412,37 @@ local function unifyresources(fontdata,indices) if duplicates then for g1,d1 in next,c do for i=1,#d1 do - d1[i]=indices[d1[i]] + local d1i=d1[i] + local d1u=indices[d1i] + if d1u then + d1[i]=d1u + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,i,d1i,nofindices) + end end local ug1=indices[g1] - t1[ug1]=d1 - local dg1=duplicates[ug1] - if dg1 then - for u in next,dg1 do - t1[u]=copy(d1) + if ug1 then + t1[ug1]=d1 + local dg1=duplicates[ug1] + if dg1 then + for u in next,dg1 do + t1[u]=copy(d1) + end end + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end end else for g1,d1 in next,c do for i=1,#d1 do - d1[i]=indices[d1[i]] + local d1i=d1[i] + local d1u=indices[d1i] + if d1u then + d1[i]=d1u + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,d1i,nofindices) + end end t1[indices[g1]]=d1 end @@ -20387,6 +20451,41 @@ local function unifyresources(fontdata,indices) end step.coverage=t1 end + elseif kind=="gpos_single" then + local c=step.coverage + if c then + local t1=done[c] + if not t1 then + t1={} + if duplicates then + for g1,d1 in next,c do + local ug1=indices[g1] + if ug1 then + t1[ug1]=d1 + local dg1=duplicates[ug1] + if dg1 then + for u in next,dg1 do + t1[u]=d1 + end + end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) + end + end + else + for g1,d1 in next,c do + local ug1=indices[g1] + if ug1 then + t1[ug1]=d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) + end + end + end + done[c]=t1 + end + step.coverage=t1 + end elseif kind=="gpos_mark2base" or kind=="gpos_mark2mark" or kind=="gpos_mark2ligature" then local c=step.coverage if c then @@ -20394,7 +20493,12 @@ local function unifyresources(fontdata,indices) if not t1 then t1={} for g1,d1 in next,c do - t1[indices[g1]]=d1 + local ug1=indices[g1] + if ug1 then + t1[ug1]=d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) + end end done[c]=t1 end @@ -20409,7 +20513,12 @@ local function unifyresources(fontdata,indices) if not t2 then t2={} for g2,d2 in next,d1 do - t2[indices[g2]]=d2 + local ug2=indices[g2] + if ug2 then + t2[ug2]=d2 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g2,nofindices) + end end done[d1]=t2 end @@ -20418,7 +20527,7 @@ local function unifyresources(fontdata,indices) done[c]=c end end - elseif kind=="gpos_single" then + elseif kind=="gpos_cursive" then local c=step.coverage if c then local t1=done[c] @@ -20427,44 +20536,27 @@ local function unifyresources(fontdata,indices) if duplicates then for g1,d1 in next,c do local ug1=indices[g1] - t1[ug1]=d1 - local dg1=duplicates[ug1] - if dg1 then - for u in next,dg1 do - t1[u]=d1 + if ug1 then + t1[ug1]=d1 + local dg1=duplicates[ug1] + if dg1 then + for u in next,dg1 do + t1[u]=copy(d1) + end end + else + report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) end end else - for g1,d1 in next,c do - t1[indices[g1]]=d1 - end - end - done[c]=t1 - end - step.coverage=t1 - end - elseif kind=="gpos_cursive" then - local c=step.coverage - if c then - local t1=done[c] - if not t1 then - t1={} - if duplicates then for g1,d1 in next,c do local ug1=indices[g1] - t1[ug1]=d1 - local dg1=duplicates[ug1] - if dg1 then - for u in next,dg1 do - t1[u]=copy(d1) - end + if ug1 then + t1[ug1]=d1 + else + report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) end end - else - for g1,d1 in next,c do - t1[indices[g1]]=d1 - end end done[c]=t1 end @@ -20508,9 +20600,13 @@ local function copyduplicates(fontdata) if not ds or ds.width==0 then if ds then descriptions[0xAD]=nil - report("patching soft hyphen") + if trace_unicodes then + report_unicodes("patching soft hyphen") + end else - report("adding soft hyphen") + if trace_unicodes then + report_unicodes("adding soft hyphen") + end end if not duplicates then duplicates={} @@ -20546,10 +20642,12 @@ local function copyduplicates(fontdata) end n=n+1 end - if n<=m then - report("duplicates: %i : % t",n,t) - else - report("duplicates: %i : % t ...",n,t) + if trace_unicodes then + if n<=m then + report_unicodes("%i : % t",n,t) + else + report_unicodes("%i : % t ...",n,t) + end end else end @@ -20671,7 +20769,9 @@ local function checklookups(fontdata,missing,nofmissing) end end if nofmissing<=0 then - report("all done in %s loops",loops) + if trace_unicodes then + report_unicodes("all missings done in %s loops",loops) + end return elseif old==nofmissing then break @@ -20720,7 +20820,9 @@ local function checklookups(fontdata,missing,nofmissing) recursed(ligatures[i]) end if nofmissing<=0 then - report("all done in %s loops",loops) + if trace_unicodes then + report_unicodes("all missings done in %s loops",loops) + end return elseif old==nofmissing then break @@ -20729,7 +20831,7 @@ local function checklookups(fontdata,missing,nofmissing) t=nil n=0 end - if nofmissing>0 then + if trace_unicodes and nofmissing>0 then local done={} for i,r in next,missing do if r then @@ -20741,7 +20843,7 @@ local function checklookups(fontdata,missing,nofmissing) end end if next(done) then - report("not unicoded: % t",sortedkeys(done)) + report_unicode("not unicoded: % t",sortedkeys(done)) end end end @@ -20764,6 +20866,9 @@ local function unifymissing(fontdata) fonts.mappings.addtounicode(fontdata,fontdata.filename,checklookups) resources.unicodes=nil end +local firstprivate=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 @@ -20786,40 +20891,106 @@ local function unifyglyphs(fontdata,usenames) else indices[0]=zerocode end - for index=1,#glyphs do - local glyph=glyphs[index] - local unicode=glyph.unicode - if not unicode or unicode>=private or (unicode>=0xE000 and unicode<=0xF8FF) or unicode==0xFFFE or unicode==0xFFFF then - unicode=private - if names then + if names then + for index=1,#glyphs do + local glyph=glyphs[index] + local unicode=glyph.unicode + if not unicode then + unicode=private local name=glyph.name or f_private(unicode) indices[index]=name names[name]=unicode - else - indices[index]=unicode - end - private=private+1 - elseif descriptions[unicode] then - report("assigning private unicode %U to glyph indexed %05X (%C)",private,index,unicode) - unicode=private - if names then + private=private+1 + elseif unicode>=firstprivate then + unicode=private + local name=glyph.name or f_private(unicode) + indices[index]=name + names[name]=unicode + private=private+1 + elseif unicode>=puafirst and unicode<=pualast then + local name=glyph.name or f_private(unicode) + indices[index]=name + names[name]=unicode + elseif descriptions[unicode] then + unicode=private local name=glyph.name or f_private(unicode) indices[index]=name names[name]=unicode + private=private+1 else - indices[index]=unicode - end - private=private+1 - else - if names then local name=glyph.name or f_unicode(unicode) indices[index]=name names[name]=unicode + end + descriptions[unicode]=glyph + end + elseif trace_unicodes then + for index=1,#glyphs do + local glyph=glyphs[index] + local unicode=glyph.unicode + if not unicode then + unicode=private + indices[index]=unicode + private=private+1 + elseif unicode>=firstprivate then + local name=glyph.name + if name then + report_unicodes("moving glyph %a indexed %05X from private %U to %U ",name,index,unicode,private) + else + report_unicodes("moving glyph indexed %05X from private %U to %U ",index,unicode,private) + end + unicode=private + indices[index]=unicode + private=private+1 + elseif unicode>=puafirst and unicode<=pualast then + local name=glyph.name + if name then + report_unicodes("keeping private unicode %U for glyph %a indexed %05X",unicode,name,index) + else + report_unicodes("keeping private unicode %U for glyph indexed %05X",unicode,index) + end + indices[index]=unicode + elseif descriptions[unicode] then + local name=glyph.name + if name then + report_unicodes("assigning duplicate unicode %U to %U for glyph %a indexed %05X ",unicode,private,name,index) + else + report_unicodes("assigning duplicate unicode %U to %U for glyph indexed %05X ",unicode,private,index) + end + unicode=private + indices[index]=unicode + private=private+1 else indices[index]=unicode end + descriptions[unicode]=glyph + end + else + for index=1,#glyphs do + local glyph=glyphs[index] + local unicode=glyph.unicode + if not unicode then + unicode=private + indices[index]=unicode + private=private+1 + elseif unicode>=firstprivate then + local name=glyph.name + unicode=private + indices[index]=unicode + private=private+1 + elseif unicode>=puafirst and unicode<=pualast then + local name=glyph.name + indices[index]=unicode + elseif descriptions[unicode] then + local name=glyph.name + unicode=private + indices[index]=unicode + private=private+1 + else + indices[index]=unicode + end + descriptions[unicode]=glyph end - descriptions[unicode]=glyph end for index=1,#glyphs do local math=glyphs[index].math @@ -20863,28 +21034,39 @@ local function unifyglyphs(fontdata,usenames) end local p_bogusname=( (P("uni")+P("UNI")+P("Uni")+P("U")+P("u"))*S("Xx")^0*R("09","AF")^1+(P("identity")+P("Identity")+P("IDENTITY"))*R("09","AF")^1+(P("index")+P("Index")+P("INDEX"))*R("09")^1 -)*P(-1) +)*(P(-1)+P(".")) local function stripredundant(fontdata) local descriptions=fontdata.descriptions if descriptions then local n=0 local c=0 - for unicode,d in next,descriptions do - local name=d.name - if name and lpegmatch(p_bogusname,name) then - d.name=nil - n=n+1 + if not context and fonts.privateoffsets.keepnames then + for unicode,d in next,descriptions do + if d.class=="base" then + d.class=nil + c=c+1 + end end - if d.class=="base" then - d.class=nil - c=c+1 + else + for unicode,d in next,descriptions do + local name=d.name + if name and lpegmatch(p_bogusname,name) then + d.name=nil + n=n+1 + end + if d.class=="base" then + d.class=nil + c=c+1 + end end end - if n>0 then - report("%s bogus names removed (verbose unicode)",n) - end - if c>0 then - report("%s base class tags removed (default is base)",c) + if trace_cleanup then + if n>0 then + report_cleanup("%s bogus names removed (verbose unicode)",n) + end + if c>0 then + report_cleanup("%s base class tags removed (default is base)",c) + end end end end @@ -21973,12 +22155,16 @@ local function mergesteps_1(lookup,strict) local f=first.format for i=2,nofsteps do if steps[i].format~=f then - report("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + end return 0 end end end - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target=first.coverage for i=2,nofsteps do local c=steps[i].coverage @@ -22003,12 +22189,16 @@ local function mergesteps_2(lookup) local f=first.format for i=2,nofsteps do if steps[i].format~=f then - report("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) + end return 0 end end end - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target=first.coverage for i=2,nofsteps do local c=steps[i].coverage @@ -22035,7 +22225,9 @@ end local function mergesteps_3(lookup,strict) local steps=lookup.steps local nofsteps=lookup.nofsteps - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local coverage={} for i=1,nofsteps do local c=steps[i].coverage @@ -22043,7 +22235,9 @@ local function mergesteps_3(lookup,strict) for k,v in next,c do local tk=coverage[k] if tk then - report("quitting merge due to multiple checks") + if trace_optimizations then + report_optimizations("quitting merge due to multiple checks") + end return nofsteps else coverage[k]=v @@ -22090,7 +22284,9 @@ local function mergesteps_4(lookup) local steps=lookup.steps local nofsteps=lookup.nofsteps local first=steps[1] - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target=first.coverage for i=2,nofsteps do local c=steps[i].coverage @@ -22113,7 +22309,9 @@ local function mergesteps_5(lookup) local steps=lookup.steps local nofsteps=lookup.nofsteps local first=steps[1] - report("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) + end local target=first.coverage local hash=nil for k,v in next,target do @@ -22162,7 +22360,9 @@ local function checkkerns(lookup) end end if kerns then - report("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + end local c={} for g1,d1 in next,coverage do if d1 and d1~=true then @@ -22203,7 +22403,9 @@ local function checkpairs(lookup) if step.format=="pair" then local coverage=onlykerns(step) if coverage then - report("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + if trace_optimizations then + report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) + end for g1,d1 in next,coverage do local d={} for g2,d2 in next,d1 do @@ -22319,17 +22521,19 @@ function readers.compact(data) end end end - else - report("no lookups in %a",what) + elseif trace_optimizations then + report_optimizations("no lookups in %a",what) end end compact("sequences") compact("sublookups") - if merged>0 then - report("%i steps of %i removed due to merging",merged,allsteps) - end - if kerned>0 then - report("%i steps of %i steps turned from pairs into kerns",kerned,allsteps) + if trace_optimizations then + if merged>0 then + report_optimizations("%i steps of %i removed due to merging",merged,allsteps) + end + if kerned>0 then + report_optimizations("%i steps of %i steps turned from pairs into kerns",kerned,allsteps) + end end end local function mergesteps(t,k) @@ -22420,7 +22624,7 @@ function readers.expand(data) if not wd then d.width=defaultwidth elseif trace_markwidth and wd~=0 and d.class=="mark" then - report("mark %a with width %b found in %a",d.name or "",wd,basename) + report_markwidth("mark %a with width %b found in %a",d.name or "",wd,basename) end if bb then local ht=bb[4] @@ -22600,7 +22804,7 @@ local trace_defining=false registertracker("fonts.defining",function(v) trace_de local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf -otf.version=3.105 +otf.version=3.106 otf.cache=containers.define("fonts","otl",otf.version,true) otf.svgcache=containers.define("fonts","svg",otf.version,true) otf.sbixcache=containers.define("fonts","sbix",otf.version,true) @@ -22676,7 +22880,7 @@ function otf.load(filename,sub,instance) end if reload then report_otf("loading %a, hash %a",filename,hash) - starttiming(otfreaders) + starttiming(otfreaders,true) data=otfreaders.loadfont(filename,sub or 1,instance) if data then local used=checkmemory() @@ -22759,6 +22963,7 @@ function otf.load(filename,sub,instance) checkmemory(used,threshold,tracememory) end else + stoptiming(otfreaders) data=nil report_otf("loading failed due to read error") end -- cgit v1.2.3