From 1b8f320120195d4a8a523c4bdba45d811bd81048 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sun, 26 Apr 2020 20:17:14 +0200 Subject: 2020-04-26 19:56:00 --- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 2 +- tex/context/base/mkiv/driv-shp.lua | 4 +- tex/context/base/mkiv/font-shp.lua | 2 +- tex/context/base/mkiv/lpdf-lmt.lua | 43 +++++++-- tex/context/base/mkiv/math-frc.lua | 37 ++++++++ tex/context/base/mkiv/mult-low.lua | 2 +- tex/context/base/mkiv/mult-prm.lua | 9 +- tex/context/base/mkiv/status-files.pdf | Bin 27734 -> 27732 bytes tex/context/base/mkiv/status-lua.pdf | Bin 251331 -> 251337 bytes tex/context/base/mkiv/strc-not.mkvi | 7 ++ tex/context/base/mkiv/syst-ini.mkxl | 9 +- tex/context/base/mkiv/trac-vis.lua | 153 ++++++++++++++++----------------- 14 files changed, 172 insertions(+), 100 deletions(-) (limited to 'tex/context/base/mkiv') diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index d3c1125f4..f97f5b90f 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{2020.04.19 19:20} +\newcontextversion{2020.04.26 19:53} %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 d290c3ab1..b600b8c94 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.04.19 19:20} +\edef\contextversion{2020.04.26 19:53} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index cef37c41e..da99d2af5 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.04.19 19:20} +\edef\contextversion{2020.04.26 19:53} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/driv-shp.lua b/tex/context/base/mkiv/driv-shp.lua index 5cf7cfcc6..47cb57dd7 100644 --- a/tex/context/base/mkiv/driv-shp.lua +++ b/tex/context/base/mkiv/driv-shp.lua @@ -790,8 +790,8 @@ local hlist_out, vlist_out do pos_v = pos_v - depth flushrule(current,pos_h + xoffset,pos_v + yoffset,pos_r,width,total,subtype) end - cur_h = cur_h + width end + cur_h = cur_h + width elseif id == math_code then -- local kern = getkern(current) -- if kern ~= 0 then @@ -1091,8 +1091,8 @@ local hlist_out, vlist_out do end flushrule(current,pos_h + xoffset,pos_v - total - yoffset,pos_r,width,total,subtype) end - cur_v = cur_v + total end + cur_v = cur_v + total elseif id == whatsit_code then if subtype == literalwhatsit_code then flushliteral(current,pos_h,pos_v) diff --git a/tex/context/base/mkiv/font-shp.lua b/tex/context/base/mkiv/font-shp.lua index 3d2e5b7c9..4d5254760 100644 --- a/tex/context/base/mkiv/font-shp.lua +++ b/tex/context/base/mkiv/font-shp.lua @@ -346,7 +346,7 @@ local function getstreamhash(fontid) local fontdata = identifiers[fontid] if fontdata then local properties = fontdata.properties - return makehash(properties.filename,fontdata.subindex,properties.instance) + return makehash(properties.filename,properties.subfont,properties.instance) end end diff --git a/tex/context/base/mkiv/lpdf-lmt.lua b/tex/context/base/mkiv/lpdf-lmt.lua index 3966143b4..8148bec01 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lua +++ b/tex/context/base/mkiv/lpdf-lmt.lua @@ -378,23 +378,52 @@ local flushcharacter do local naturalwidth = nil + -- local naturalwidths = setmetatableindex(function(t,font) + -- local d = descriptions[font] + -- local c = characters[font] + -- local f = parameters[font].hfactor + -- local v = setmetatableindex(function(t,char) + -- local w + -- local e = d and d[char] + -- if e then + -- w = e.width + -- if w then + -- w = w * f + -- end + -- end + -- if not w then + -- e = c[char] + -- if e then + -- w = e.width or 0 + -- end + -- end + -- if not w then + -- w = 0 + -- end + -- t[char] = w + -- return w + -- end) + -- t[font] = v + -- return v + -- end) + local naturalwidths = setmetatableindex(function(t,font) local d = descriptions[font] local c = characters[font] local f = parameters[font].hfactor local v = setmetatableindex(function(t,char) - local e = d and d[char] local w + local e = c[char] if e then - w = e.width - if w then - w = w * f - end + w = e.width or 0 end if not w then - e = c[char] + e = d and d[char] if e then - w = e.width or 0 + w = e.width + if w then + w = w * f + end end end if not w then diff --git a/tex/context/base/mkiv/math-frc.lua b/tex/context/base/mkiv/math-frc.lua index 190c36410..af30a03b5 100644 --- a/tex/context/base/mkiv/math-frc.lua +++ b/tex/context/base/mkiv/math-frc.lua @@ -55,3 +55,40 @@ interfaces.implement { actions = mathfraction, arguments = { "string", "number", "number", "dimen" } } + +-- experimental code in lmtx + +if CONTEXTLMTXMODE > 0 then + + local ctx_normalUatop = context.normalUatop + local ctx_normalUover = context.normalUover + + local function umathfraction(how,left,right,width) + if how == v_no then + if left == 0x002E and right == 0x002E then + ctx_normalUatop() + else + context("\\Uatopwithdelims%s%s",resolved[left],resolved[right]) + end + elseif how == v_yes then + if left == 0x002E and right == 0x002E then + context("\\normalUabove%ssp",width) + else + context("\\Uabovewithdelims%s%s%ssp",resolved[left],resolved[right],width) + end + else -- v_auto + if left == 0x002E and right == 0x002E then + ctx_normalUover() + else + context("\\Uoverwithdelims%s%s",resolved[left],resolved[right]) + end + end + end + + interfaces.implement { + name = "umathfraction", + actions = umathfraction, + arguments = { "string", "number", "number", "dimen" } + } + +end diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index aa0329e48..2b3c1380c 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -74,7 +74,7 @@ return { -- "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", - "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", + "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathabovegroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", -- "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index ffce2b40f..5ff7f6bfc 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -65,6 +65,12 @@ return { "widowpenalties", }, ["luatex"]={ + "UUskewed", + "UUskewedwithdelims", + "Uabove", + "Uabovewithdelims", + "Uatop", + "Uatopwithdelims", "Uchar", "Udelcode", "Udelcodenum", @@ -200,7 +206,9 @@ return { "Umiddle", "Unosubscript", "Unosuperscript", + "Uover", "Uoverdelimiter", + "Uoverwithdelims", "Uradical", "Uright", "Uroot", @@ -368,7 +376,6 @@ return { "tracingfonts", "unletfrozen", "unletprotected", - "vcentermode", "vpack", "wordboundary", "xtoksapp", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 2e95a65c9..35750fc43 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 bd4830f83..095e10a1a 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-not.mkvi b/tex/context/base/mkiv/strc-not.mkvi index 05aa1eb6b..0ea6e88ea 100644 --- a/tex/context/base/mkiv/strc-not.mkvi +++ b/tex/context/base/mkiv/strc-not.mkvi @@ -1357,6 +1357,13 @@ \newtoks\everyinsidenoteinsert \newtoks\everyafternoteinsert +\unexpanded\def\doifelseinnote + {\ifconditional\processingnote + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + \appendtoks \let\flushnotes\relax \let\postponenotes\relax diff --git a/tex/context/base/mkiv/syst-ini.mkxl b/tex/context/base/mkiv/syst-ini.mkxl index 88fe2211b..09ab93d58 100644 --- a/tex/context/base/mkiv/syst-ini.mkxl +++ b/tex/context/base/mkiv/syst-ini.mkxl @@ -630,10 +630,11 @@ \chardef\discretionarygroupcode = 10 \chardef\insertgroupcode = 11 \chardef\vcentergroupcode = 12 -\chardef\mathchoicegroupcode = 13 -\chardef\semisimplegroupcode = 14 -\chardef\mathshiftgroupcode = 15 -\chardef\mathleftgroupcode = 16 +\chardef\mathabovegroupcode = 13 +\chardef\mathchoicegroupcode = 14 +\chardef\semisimplegroupcode = 15 +\chardef\mathshiftgroupcode = 16 +\chardef\mathleftgroupcode = 17 \chardef\vadjustgroupcode = \insertgroupcode %D Constants to be used with \type {\interactionmode}. diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua index 34c60f1c9..760ba8726 100644 --- a/tex/context/base/mkiv/trac-vis.lua +++ b/tex/context/base/mkiv/trac-vis.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['trac-vis'] = { license = "see context related readme files" } -local node, nodes, attributes, fonts, tex = node, nodes, attributes, fonts, tex +local node, nodes, attributes, tex = node, nodes, attributes, tex local type, tonumber, next, rawget = type, tonumber, next, rawget local gmatch = string.gmatch local formatters = string.formatters @@ -34,7 +34,6 @@ local nuts = nodes.nuts local tonut = nuts.tonut local tonode = nuts.tonode ------ setfield = nuts.setfield local setboth = nuts.setboth local setlink = nuts.setlink local setdisc = nuts.setdisc @@ -166,10 +165,11 @@ local modes = { space = 0x040000, depth = 0x080000, marginkern = 0x100000, + mathlistkern = 0x200000, } local usedfont, exheight, emwidth -local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth +local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph, l_user, l_math, l_marginkern, l_mathlistkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth local enabled = false local layers = { } @@ -178,7 +178,8 @@ local preset_boxes = modes.hbox + modes.vbox + modes.origin local preset_makeup = preset_boxes + modes.kern + modes.glue + modes.penalty local preset_all = preset_makeup - + modes.fontkern + modes.marginkern + modes.whatsit + modes.glyph + modes.user + modes.math + + modes.fontkern + modes.marginkern + modes.mathlistkern + + modes.whatsit + modes.glyph + modes.user + modes.math function visualizers.setfont(id) usedfont = id or current_font() @@ -223,6 +224,7 @@ local function initialize() l_math = layers.math l_italic = layers.italic l_marginkern = layers.marginkern + l_mathlistkern = layers.mathlistkern l_origin = layers.origin l_discretionary = layers.discretionary l_expansion = layers.expansion @@ -366,10 +368,6 @@ for mode, value in next, modes do trackers.register(formatters["visualizers.%s"](mode), function(v) set(mode,v) end) end -local raisepenalties = false - -directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end) - local fraction = 10 trackers .register("visualizers.reset", function(v) set("reset", v) end) @@ -463,11 +461,12 @@ end local caches = setmetatableindex("table") -local fontkern, italickern, marginkern do +local fontkern, italickern, marginkern, mathlistkern do local f_cache = caches["fontkern"] local i_cache = caches["italickern"] local m_cache = caches["marginkern"] + local l_cache = caches["mathlistkern"] local function somekern(head,current,cache,color,layer) local width = getkern(current) @@ -509,6 +508,10 @@ local fontkern, italickern, marginkern do return somekern(head,current,m_cache,c_glyph_d,l_marginkern) end + mathlistkern = function(head,current) + return somekern(head,current,l_cache,c_glyph_d,l_mathlistkern) + end + end local glyphexpansion do @@ -1084,6 +1087,31 @@ local ruledmarginkern do end +local ruledmathlistkern do + + local l_cache = caches["mathlistkern"] + + ruledmathlistkern = function(head,current) + local kern = getkern(current) + local info = l_cache[kern] + if not info then + local amount = formatters["%s:%0.3f"]("LK",kern*pt_factor) + if kern > 0 then + info = sometext(amount,l_mathlistkern,c_positive) + elseif kern < 0 then + info = sometext(amount,l_mathlistkern,c_negative) + else + info = sometext(amount,l_mathlistkern,c_zero) + end + l_cache[kern] = info + end + info = copy_list(info) + head, current = insert_node_before(head,current,info) + return head, getnext(current) + end + +end + local ruleddiscretionary do local d_cache = caches["discretionary"] @@ -1111,6 +1139,10 @@ local ruledpenalty do local p_cache_v = caches["vpenalty"] local p_cache_h = caches["hpenalty"] + local raisepenalties = false + + directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end) + ruledpenalty = function(head,current,vertical) local penalty = getpenalty(current) local info = (vertical and p_cache_v or p_cache_h)[penalty] @@ -1141,23 +1173,25 @@ end do - local disc_code = nodecodes.disc - local kern_code = nodecodes.kern - local glyph_code = nodecodes.glyph - local glue_code = nodecodes.glue - local penalty_code = nodecodes.penalty - local whatsit_code = nodecodes.whatsit - local user_code = nodecodes.user - local math_code = nodecodes.math - local hlist_code = nodecodes.hlist - local vlist_code = nodecodes.vlist - local marginkern_code = nodecodes.marginkern + local disc_code = nodecodes.disc + local kern_code = nodecodes.kern + local glyph_code = nodecodes.glyph + local glue_code = nodecodes.glue + local penalty_code = nodecodes.penalty + local whatsit_code = nodecodes.whatsit + local user_code = nodecodes.user + local math_code = nodecodes.math + local hlist_code = nodecodes.hlist + local vlist_code = nodecodes.vlist + local marginkern_code = nodecodes.marginkern + local mathlistkern_code = nodecodes.mathlistkern local kerncodes = nodes.kerncodes local fontkern_code = kerncodes.fontkern local italickern_code = kerncodes.italiccorrection local leftmarginkern_code = kerncodes.leftmarginkern local rightmarginkern_code = kerncodes.rightmarginkern + local mathlistkern_code = kerncodes.mathlistkern ----- userkern_code = kerncodes.userkern local listcodes = nodes.listcodes @@ -1190,70 +1224,21 @@ do local previous = nil local attr = unsetvalue local prev_trace_fontkern = nil - local prev_trace_marginkern = nil local prev_trace_italic = nil + local prev_trace_marginkern = nil +-- local prev_trace_mathlist = nil local prev_trace_expansion = nil - -- local function setthem(t,k) - -- local v_trace_hbox = band(k, 1) ~= 0 - -- local v_trace_vbox = band(k, 2) ~= 0 - -- local v_trace_vtop = band(k, 4) ~= 0 - -- local v_trace_kern = band(k, 8) ~= 0 - -- local v_trace_glue = band(k, 16) ~= 0 - -- local v_trace_penalty = band(k, 32) ~= 0 - -- local v_trace_fontkern = band(k, 64) ~= 0 - -- local v_trace_strut = band(k, 128) ~= 0 - -- local v_trace_whatsit = band(k, 256) ~= 0 - -- local v_trace_glyph = band(k, 512) ~= 0 - -- local v_trace_simple = band(k, 1024) ~= 0 - -- local v_trace_user = band(k, 2048) ~= 0 - -- local v_trace_math = band(k, 4096) ~= 0 - -- local v_trace_italic = band(k, 8192) ~= 0 - -- local v_trace_origin = band(k, 16384) ~= 0 - -- local v_trace_discretionary = band(k, 32768) ~= 0 - -- local v_trace_expansion = band(k, 65536) ~= 0 - -- local v_trace_line = band(k,131072) ~= 0 - -- local v_trace_space = band(k,262144) ~= 0 - -- local v_trace_depth = band(k,524288) ~= 0 - -- local v = function() - -- trace_hbox = v_trace_hbox - -- trace_vbox = v_trace_vbox - -- trace_vtop = v_trace_vtop - -- trace_kern = v_trace_kern - -- trace_glue = v_trace_glue - -- trace_penalty = v_trace_penalty - -- trace_fontkern = v_trace_fontkern - -- trace_strut = v_trace_strut - -- trace_whatsit = v_trace_whatsit - -- trace_glyph = v_trace_glyph - -- trace_simple = v_trace_simple - -- trace_user = v_trace_user - -- trace_math = v_trace_math - -- trace_italic = v_trace_italic - -- trace_origin = v_trace_origin - -- trace_discretionary = v_trace_discretionary - -- trace_expansion = v_trace_expansion - -- trace_line = v_trace_line - -- trace_space = v_trace_space - -- trace_depth = v_trace_depth - -- end - -- t[k] = v - -- return v - -- end - -- - -- if not cache then - -- cache = setmetatableindex(setthem) - -- end - while current do local id = getid(current) local a = forced or getattr(current,a_visual) or unsetvalue local subtype if a ~= attr then - prev_trace_fontkern = trace_fontkern - prev_trace_italic = trace_italic - prev_trace_marginkern = trace_marginkern - prev_trace_expansion = trace_expansion + prev_trace_fontkern = trace_fontkern + prev_trace_italic = trace_italic + prev_trace_marginkern = trace_marginkern +-- prev_trace_mathlistkern = trace_mathlistkern + prev_trace_expansion = trace_expansion attr = a if a == unsetvalue then trace_hbox = false @@ -1277,6 +1262,7 @@ do trace_space = false trace_depth = false trace_marginkern = false + trace_mathlistkern = false if id == kern_code then goto kern else @@ -1305,6 +1291,7 @@ do trace_space = band(a,0x040000) ~= 0 trace_depth = band(a,0x080000) ~= 0 trace_marginkern = band(a,0x100000) ~= 0 + trace_mathlistkern = band(a,0x200000) ~= 0 end elseif a == unsetvalue then goto list @@ -1389,6 +1376,12 @@ do elseif trace_kern then head, current = ruledmarginkern(head,current) end + elseif subtype == mathlistkern_code then + if trace_mathlist then -- or prev_trace_mathlist then + head, current = mathlistkern(head,current) + elseif trace_kern then + head, current = ruledmathlistkern(head,current) + end else if trace_kern then head, current = ruledkern(head,current,vertical) @@ -1438,7 +1431,9 @@ do end end - local function handler(head) + luatex.registerstopactions(cleanup) + + function visualizers.handler(head) if usedfont then starttiming(visualizers) head = visualize(head,true) @@ -1449,10 +1444,6 @@ do end end - visualizers.handler = handler - - luatex.registerstopactions(cleanup) - function visualizers.box(n) if usedfont then starttiming(visualizers) -- cgit v1.2.3