diff options
author | Hans Hagen <pragma@wxs.nl> | 2022-03-24 21:42:40 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2022-03-24 21:42:40 +0100 |
commit | 6a2738578157926c6ebd64048ddabb7d923b2be5 (patch) | |
tree | 908336b6d20b32c00548f2ee75ef8ae947979fb9 /tex/context/base/mkiv | |
parent | 188632f4b0f71c5170a20f1b151bde68f603bfd9 (diff) | |
download | context-6a2738578157926c6ebd64048ddabb7d923b2be5.tar.gz |
2022-03-24 21:17:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-dsp.lua | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-map.lua | 6 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-mis.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-otl.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-otr.lua | 6 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-oup.lua | 210 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-ttf.lua | 235 | ||||
-rw-r--r-- | tex/context/base/mkiv/l-os.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/mtx-context-compare.tex | 4 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-low.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-prm.lua | 15 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 24667 -> 24656 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 258099 -> 258263 bytes |
15 files changed, 330 insertions, 159 deletions
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index f33357f04..883269f4b 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.03.12 11:24} +\newcontextversion{2022.03.24 21:14} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 1e81770dc..7f27d0ba5 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2022.03.12 11:24} +\edef\contextversion{2022.03.24 21:14} %D Kind of special: diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index 7028f7c08..74a0a1f38 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -3820,6 +3820,7 @@ function readers.hvar(f,fontdata,specification) local variations = { } local innerindex = { } -- size is mapcount local outerindex = { } -- size is mapcount + local deltas = { } if variationoffset > 0 then regions, deltas = readvariationdata(f,variationoffset,factors) diff --git a/tex/context/base/mkiv/font-map.lua b/tex/context/base/mkiv/font-map.lua index c983ea963..4aa937ed1 100644 --- a/tex/context/base/mkiv/font-map.lua +++ b/tex/context/base/mkiv/font-map.lua @@ -253,9 +253,9 @@ function mappings.addtounicode(data,filename,checklookups,forceligatures) local usedmap = cidinfo and fonts.cid.getmap(cidinfo) local uparser = makenameparser() -- hm, every time? if usedmap then - oparser = usedmap and makenameparser(cidinfo.ordering) - cidnames = usedmap.names - cidcodes = usedmap.unicodes + oparser = usedmap and makenameparser(cidinfo.ordering) + cidnames = usedmap.names + cidcodes = usedmap.unicodes end local ns = 0 local nl = 0 diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index 9bb8d4cc1..c294bd638 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.119 + otf.version = otf.version or 3.120 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 ae2dda4f3..f36e533ca 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.119 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.120 -- 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.pngcache = containers.define("fonts", "png", otf.version, true) diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index 286367ed9..339de109f 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -2499,15 +2499,15 @@ function readers.getinfo(filename,specification) -- string, nil|number|table end end -function readers.rehash(fontdata,hashmethod) +function readers.rehash() -- fontdata,hashmethod report("the %a helper is not yet implemented","rehash") end -function readers.checkhash(fontdata) +function readers.checkhash() --fontdata report("the %a helper is not yet implemented","checkhash") end -function readers.pack(fontdata,hashmethod) +function readers.pack() -- fontdata,hashmethod report("the %a helper is not yet implemented","pack") end diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua index 3bd2fe482..248aad04d 100644 --- a/tex/context/base/mkiv/font-oup.lua +++ b/tex/context/base/mkiv/font-oup.lua @@ -10,6 +10,7 @@ local next, type = next, type 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 find = string.find local formatters = string.formatters local sortedkeys = table.sortedkeys @@ -944,15 +945,18 @@ local function unifyglyphs(fontdata,usenames) return indices, names end -local p_crappyname do +local stripredundant do + local p_hex = R("af","AF","09") local p_digit = R("09") local p_done = S("._-")^0 + P(-1) + -- local p_style = P(".ss") * p_digit * p_digit * P(-1) + local p_style = P(".") local p_alpha = R("az","AZ") local p_ALPHA = R("AZ") - p_crappyname = ( + local p_crappyname = ( -- (P("uni") + P("UNI") + P("Uni") + P("U") + P("u")) lpeg.utfchartabletopattern({ "uni", "u" },true) * S("Xx_")^0 @@ -980,56 +984,182 @@ local p_crappyname do * P(1)^1 ) * p_done -end + -- In context we only keep glyph names because of tracing and access by name + -- so weird names make no sense. --- In context we only keep glyph names because of tracing and access by name --- so weird names make no sense. + if context then -local forcekeep = false -- only for testing something + local forcekeep = false -- only for testing something +-- local forcekeep = true -directives.register("otf.keepnames",function(v) - report_cleanup("keeping weird glyph names, expect larger files and more memory usage") - forcekeep = v -end) + directives.register("otf.keepnames",function(v) + report_cleanup("keeping weird glyph names, expect larger files and more memory usage") + forcekeep = v + end) -local function stripredundant(fontdata) - local descriptions = fontdata.descriptions - if descriptions then - local n = 0 - local c = 0 - -- in context we always strip - if (not context and fonts.privateoffsets.keepnames) or forcekeep then - for unicode, d in next, descriptions do - if d.class == "base" then - d.class = nil - c = c + 1 + -- local p_lesscrappyname = + -- lpeg.utfchartabletopattern({ "uni", "u" },true) + -- * S("Xx")^0 + -- * p_hex^1 + -- * p_style + + local function stripvariants(descriptions,list) + local n = list and #list or 0 + if n > 0 then + for i=1,n do + local g = list[i] + if g then + local d = descriptions[g] + if d and d.name then + d.name = nil + n = n + 1 + end + end end end - else - for unicode, d in next, descriptions do - local name = d.name - if name and lpegmatch(p_crappyname,name) then - d.name = nil - n = n + 1 + return n + end + + local function stripparts(descriptions,list) + local n = list and #list or 0 + if n > 0 then + for i=1,n do + local g = list[i].glyph + if g then + local d = descriptions[g] + if d and d.name then + d.name = nil + n = n + 1 + end + end end - if d.class == "base" then - d.class = nil - c = c + 1 + end + return n + end + + -- local function collectsimple(fontdata) + -- local resources = fontdata.resources + -- local sequences = resources and resources.sequences + -- if sequences then + -- local keeplist = { } + -- for i=1,#sequences do + -- local s = sequences[i] + -- if s.type == "gsub_single" then + -- -- only simple ones + -- local features = s.features + -- local steps = s.steps + -- if features and steps then + -- local okay = false + -- for k, v in next, features do + -- if find(k,"^ss%d%d") then + -- okay = true + -- break + -- end + -- end + -- if okay then + -- for i=1,#steps do + -- local coverage = steps[i].coverage + -- if coverage then + -- for k, v in next, coverage do + -- keeplist[k] = v + -- end + -- end + -- end + -- end + -- end + -- end + -- end + -- return next(keeplist) and keeplist or nil + -- end + -- end + + local function collectsimple(fontdata) + return nil + end + + stripredundant = function(fontdata) + local descriptions = fontdata.descriptions + if descriptions then + local n = 0 + local c = 0 + for unicode, d in next, descriptions do + local m = d.math + if m then + n = n + stripvariants(descriptions,m.vvariants) + n = n + stripvariants(descriptions,m.hvariants) + n = n + stripparts (descriptions,m.vparts) + n = n + stripparts (descriptions,m.hparts) + end + end + if forcekeep then + for unicode, d in next, descriptions do + if d.class == "base" then + d.class = nil + c = c + 1 + end + end + else + local keeplist = collectsimple(fontdata) + for unicode, d in next, descriptions do + local name = d.name + if name then + -- if lpegmatch(p_lesscrappyname,name) then + if keeplist and keeplist[name] then + -- keep name + elseif lpegmatch(p_crappyname,name) then + d.name = nil + n = n + 1 + end + end + if d.class == "base" then + d.class = nil + c = c + 1 + end + end + end + 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 - 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) + + else + + stripredundant = function(fontdata) + local descriptions = fontdata.descriptions + if descriptions then + if fonts.privateoffsets.keepnames then + for unicode, d in next, descriptions do + if d.class == "base" then + d.class = nil + end + end + else + for unicode, d in next, descriptions do + local name = d.name + if name then + if lpegmatch(p_crappyname,name) then + d.name = nil + end + end + if d.class == "base" then + d.class = nil + end + end + end end end + end -end -readers.stripredundant = stripredundant + readers.stripredundant = stripredundant + +end function readers.getcomponents(fontdata) -- handy for resolving ligatures when names are missing local resources = fontdata.resources @@ -1128,8 +1258,7 @@ readers.unifymissing = unifymissing function readers.rehash(fontdata,hashmethod) -- TODO: combine loops in one if not (fontdata and fontdata.glyphs) then return - end - if hashmethod == "indices" then + elseif hashmethod == "indices" then fontdata.hashmethod = "indices" elseif hashmethod == "names" then fontdata.hashmethod = "names" @@ -1137,7 +1266,6 @@ function readers.rehash(fontdata,hashmethod) -- TODO: combine loops in one unifyresources(fontdata,indices) copyduplicates(fontdata) unifymissing(fontdata) - -- stripredundant(fontdata) else fontdata.hashmethod = "unicodes" local indices = unifyglyphs(fontdata) diff --git a/tex/context/base/mkiv/font-ttf.lua b/tex/context/base/mkiv/font-ttf.lua index a2658d595..d1a3972b2 100644 --- a/tex/context/base/mkiv/font-ttf.lua +++ b/tex/context/base/mkiv/font-ttf.lua @@ -247,115 +247,148 @@ local function applyaxis(glyph,shape,deltas,dowidth) -- Not the most efficient solution but we seldom do this. We -- actually need to avoid the extra points here but I'll deal -- with that when needed. - local function find(i) - local prv = cnt - for j=1,cnt do - local nxt = dpoints[j] - if nxt == i then - return false, j, false - elseif nxt > i then - return prv, false, j - end - prv = j - end - return prv, false, 1 - end - -- We need the first and last points untouched so we first - -- collect data. - for i=1,nofpoints do - local d1, d2, d3 = find(i) - local p2 = points[i] - if d2 then - xv[i] = xvalues[d2] - yv[i] = yvalues[d2] - else - local n1 = dpoints[d1] - local n3 = dpoints[d3] - -- Some day I need to figure out these extra points but - -- I'll wait till the standard is more clear and fonts - -- become better (ntg-context: fraunces.ttf > abcdef). - if n1 > nofpoints then - n1 = nofpoints - end - if n3 > nofpoints then - n3 = nofpoints - end - -- - local p1 = points[n1] - local p3 = points[n3] - local p1x = p1[1] - local p2x = p2[1] - local p3x = p3[1] - local p1y = p1[2] - local p2y = p2[2] - local p3y = p3[2] - local x1 = xvalues[d1] - local y1 = yvalues[d1] - local x3 = xvalues[d3] - local y3 = yvalues[d3] - -- - local fx - local fy - -- - if p1x == p3x then - if x1 == x3 then - fx = x1 - else - fx = 0 - end - elseif p2x <= min(p1x,p3x) then - if p1x < p3x then - fx = x1 - else - fx = x3 - end - elseif p2x >= max(p1x,p3x) then - if p1x > p3x then - fx = x1 - else - fx = x3 + local contours = shape.contours + local nofcontours = #contours + local first = 1 + local firstindex = 1 + for contour=1,nofcontours do + local last = contours[contour] + if last >= first then + local lastindex = cnt + if firstindex < cnt then + for currentindex=firstindex,cnt do + local found = dpoints[currentindex] + if found <= first then + firstindex = currentindex + end + if found == last then + lastindex = currentindex + break; + elseif found > last then + break + end end - else - fx = (p2x - p1x)/(p3x - p1x) - fx = (1 - fx) * x1 + fx * x3 end - -- - if p1y == p3y then - if y1 == y3 then - fy = y1 - else - fy = 0 - end - elseif p2y <= min(p1y,p3y) then - if p1y < p3y then - fy = y1 - else - fy = y3 + -- print("unicode: ",glyph.unicode or "?") + -- print("contour: ",first,contour,last) + -- print("index : ",firstindex,lastindex,cnt) + -- print("points : ",dpoints[firstindex],dpoints[lastindex]) + local function find(i) + local prv = lastindex + for j=firstindex,lastindex do + local nxt = dpoints[j] + if nxt == i then + return false, j, false + elseif nxt > i then + return prv, false, j + end + prv = j end - elseif p2y >= max(p1y,p3y) then - if p1y > p3y then - fy = y1 + return prv, false, firstindex + end + -- We need the first and last points untouched so we first + -- collect data. + for point=first,last do + local d1, d2, d3 = find(point) + local p2 = points[point] + if d2 then + xv[point] = xvalues[d2] + yv[point] = yvalues[d2] else - fy = y3 + local n1 = dpoints[d1] + local n3 = dpoints[d3] + -- Some day I need to figure out these extra points but + -- I'll wait till the standard is more clear and fonts + -- become better (ntg-context: fraunces.ttf > abcdef). + if n1 > nofpoints then + n1 = nofpoints + end + if n3 > nofpoints then + n3 = nofpoints + end + -- + local p1 = points[n1] + local p3 = points[n3] + local p1x = p1[1] + local p2x = p2[1] + local p3x = p3[1] + local p1y = p1[2] + local p2y = p2[2] + local p3y = p3[2] + local x1 = xvalues[d1] + local y1 = yvalues[d1] + local x3 = xvalues[d3] + local y3 = yvalues[d3] + -- + local fx + local fy + -- + if p1x == p3x then + if x1 == x3 then + fx = x1 + else + fx = 0 + end + elseif p2x <= min(p1x,p3x) then + if p1x < p3x then + fx = x1 + else + fx = x3 + end + elseif p2x >= max(p1x,p3x) then + if p1x > p3x then + fx = x1 + else + fx = x3 + end + else + fx = (p2x - p1x)/(p3x - p1x) + fx = (1 - fx) * x1 + fx * x3 + end + -- + if p1y == p3y then + if y1 == y3 then + fy = y1 + else + fy = 0 + end + elseif p2y <= min(p1y,p3y) then + if p1y < p3y then + fy = y1 + else + fy = y3 + end + elseif p2y >= max(p1y,p3y) then + if p1y > p3y then + fy = y1 + else + fy = y3 + end + else + fy = (p2y - p1y)/(p3y - p1y) + fy = (1 - fy) * y1 + fy * y3 + end + -- -- maybe: + -- if p1y ~= p3y then + -- fy = (p2y - p1y)/(p3y - p1y) + -- fy = (1 - fy) * y1 + fy * y3 + -- elseif abs(p1y-p2y) < abs(p3y-p2y) then + -- fy = y1 + -- else + -- fy = y3 + -- end + -- + xv[point] = fx + yv[point] = fy end - else - fy = (p2y - p1y)/(p3y - p1y) - fy = (1 - fy) * y1 + fy * y3 end - -- -- maybe: - -- if p1y ~= p3y then - -- fy = (p2y - p1y)/(p3y - p1y) - -- fy = (1 - fy) * y1 + fy * y3 - -- elseif abs(p1y-p2y) < abs(p3y-p2y) then - -- fy = y1 - -- else - -- fy = y3 - -- end - -- - xv[i] = fx - yv[i] = fy + if lastindex < cnt then + firstindex = lastindex + 1 + end end + first = last + 1 end + for i=1,nofpoints do local pi = points[i] local fx = xv[i] diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua index 7f4f3876b..faae76881 100644 --- a/tex/context/base/mkiv/l-os.lua +++ b/tex/context/base/mkiv/l-os.lua @@ -168,7 +168,7 @@ if not os.__getenv__ then end function os.getenv(k) - local K = upper(k) + local K = upper(k) -- hm utf local v = osenv[K] or osgetenv(K) or osgetenv(k) if v == "" then return nil diff --git a/tex/context/base/mkiv/mtx-context-compare.tex b/tex/context/base/mkiv/mtx-context-compare.tex index 163ea5747..16f8a5408 100644 --- a/tex/context/base/mkiv/mtx-context-compare.tex +++ b/tex/context/base/mkiv/mtx-context-compare.tex @@ -69,8 +69,8 @@ local function check(name) return used end -local one = check(fileone) -local two = check(filetwo) +local one = check(fileone) -- can crash +local two = check(filetwo) -- can crash if not one then report("invalid file %a",fileone) diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index e5feab5d6..f24c66d12 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -164,7 +164,7 @@ return { "mathrelationcode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctuationcode", "mathpunctcode", "mathovercode", "mathundercode", "mathinnercode", "mathradicalcode", "mathfractioncode", "mathmiddlecode", "mathaccentcode", "mathfencedcode", "mathghostcode", - "mathvariablecode", "mathactivecode", "mathvcentercode", + "mathvariablecode", "mathactivecode", "mathvcentercode", "mathconstructcode", "mathwrappedcode", "mathbegincode", "mathendcode", "mathexplicitcode", "mathdivisioncode", "mathfactorialcode", -- "mathimaginarycode", "mathdifferentialcode", "mathexponentialcode", "mathfunctioncode", "mathdigitcode", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index bbc41176b..b366ea336 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -77,7 +77,10 @@ return { "Uhextensible", "Uleft", "Umathaccent", + "Umathaccentbasedepth", "Umathaccentbaseheight", + "Umathaccentbottomshiftdown", + "Umathaccenttopshiftup", "Umathaccentvariant", "Umathadapttoleft", "Umathadapttoright", @@ -106,6 +109,10 @@ return { "Umathextrasupprespace", "Umathextrasupshift", "Umathextrasupspace", + "Umathflattenedaccentbasedepth", + "Umathflattenedaccentbaseheight", + "Umathflattenedaccentbottomshiftdown", + "Umathflattenedaccenttopshiftup", "Umathfractiondelsize", "Umathfractiondenomdown", "Umathfractiondenomvgap", @@ -143,8 +150,9 @@ return { "Umathprimeraise", "Umathprimeshiftdrop", "Umathprimeshiftup", - "Umathprimesupspace", + "Umathprimespaceafter", "Umathprimevariant", + "Umathprimewidth", "Umathquad", "Umathradicaldegreeafter", "Umathradicaldegreebefore", @@ -443,12 +451,14 @@ return { "luatexversion", "mathaccent", "mathatom", + "mathatomglue", "mathatomskip", "mathbackwardpenalties", - "mathcontrolmode", + "mathbeginclass", "mathdelimitersmode", "mathdirection", "mathdisplayskipmode", + "mathendclass", "matheqnogapstep", "mathfenced", "mathfencesmode", @@ -463,7 +473,6 @@ return { "mathrad", "mathrulesfam", "mathrulesmode", - "mathrulethicknessmode", "mathscale", "mathscriptboxmode", "mathscriptcharmode", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 75450daa5..3f451abe0 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 63b45c4c1..b642259b7 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf |