diff options
Diffstat (limited to 'tex')
41 files changed, 816 insertions, 381 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 49c89aecc..98286f8e9 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{2021.09.06 11:44} +\newcontextversion{2021.09.13 09:37} %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 cbe239ec2..a39318d4b 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{2021.09.06 11:44} +\edef\contextversion{2021.09.13 09:37} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index e26f62fa3..68a07fb83 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{2021.09.06 11:44} +\newcontextversion{2021.09.13 09:37} %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 3ad868f86..159c8ebc7 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{2021.09.06 11:44} +\edef\contextversion{2021.09.13 09:37} %D Kind of special: diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index 8e8be6f95..7de108d4c 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -163,6 +163,8 @@ local trace_testruns = false registertracker("otf.testruns", function local forcediscretionaries = false local forcepairadvance = false -- for testing +local repeatablemultiples = context or false + directives.register("otf.forcediscretionaries",function(v) forcediscretionaries = v end) @@ -648,16 +650,52 @@ local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what t insertnodeafter(head,start,n) start = n end - if what == true then - -- we're ok - elseif what > 1 then - local m = multiple[nofmultiples] - for i=2,what do - local n = copy_node(start) -- ignore components - resetinjection(n) - setchar(n,m) - insertnodeafter(head,start,n) - start = n + if what ~= true and repeatablemultiples then + -- This is just some experimental code; we might introduce gsub_extensible + -- some day instead. Beware: when we have a feature that mixes alternates and + -- multiples we need to make sure we don't handle the alternate string values + -- here. This might eventually become an lmtx only feature. + local kind = type(what) + local m, f, l + if kind == "string" then + local what, n = string.match(what,"^repeat(.-)[:=](%d+)$") + if what == "middle" then + m = tonumber(n) + elseif what == "first" then + f = tonumber(n) + elseif what == "last" then + l = tonumber(n) + end + elseif kind == "table" then + -- won't happen because currently we don't split these values + m = what.middle + f = what.first + l = what.last + end + if f or m or l then + if m and m > 1 and nofmultiples == 3 then + local middle = getnext(first) + for i=2,m do + local n = copynode(middle) -- ignore components + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if f and f > 1 then + for i=2,f do + local n = copynode(first) -- ignore components + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if l and l > 1 then + for i=2,l do + local n = copynode(start) -- ignore components + resetinjection(n) + insertnodeafter(head,start,n) + start = n + end + end end end end @@ -1052,7 +1090,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode, end return head, start, true elseif trace_bugs then - -- onetimemessage(currentfont,basechar,"no base anchors",report_fonts) + -- onetimemessage(currentfont,basechar,"no base anchors") logwarning("%s: mark %s is not anchored to %s",pref(dataset,sequence),gref(markchar),gref(basechar)) end elseif trace_bugs then @@ -1118,7 +1156,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm end elseif trace_bugs then -- logwarning("%s: char %s is missing in font",pref(dataset,sequence),gref(basechar)) - onetimemessage(currentfont,basechar,"no base anchors",report_fonts) + onetimemessage(currentfont,basechar,"no base anchors") end elseif trace_bugs then logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),1) @@ -1858,7 +1896,7 @@ function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup, end end elseif trace_bugs then - onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) + onetimemessage(currentfont,startchar,"no entry anchors") end break end diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 28a8f41de..288067563 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -401,6 +401,8 @@ return { "insertmode", "insertmultiplier", "insertprogress", + "insertstorage", + "insertstoring", "insertunbox", "insertuncopy", "insertwidth", @@ -511,6 +513,7 @@ return { "tracingexpressions", "tracingfonts", "tracinghyphenation", + "tracinginserts", "tracingmarks", "tracingmath", "undent", @@ -864,6 +867,7 @@ return { "pageshrink", "pagestretch", "pagetotal", + "pagevsize", "par", "parfillleftskip", "parfillskip", diff --git a/tex/context/base/mkiv/node-fin.lua b/tex/context/base/mkiv/node-fin.lua index 42c24378f..b9ba169dd 100644 --- a/tex/context/base/mkiv/node-fin.lua +++ b/tex/context/base/mkiv/node-fin.lua @@ -203,7 +203,7 @@ local function process(attribute,head,inheritance,default) -- one attribute current = default end elseif current ~= outer then - head = insertnodebefore(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[c])) -- hm, what is c ... bug current = outer end elseif default and inheritance then diff --git a/tex/context/base/mkiv/node-tra.lua b/tex/context/base/mkiv/node-tra.lua index d3d35dae0..67435f1c7 100644 --- a/tex/context/base/mkiv/node-tra.lua +++ b/tex/context/base/mkiv/node-tra.lua @@ -77,6 +77,7 @@ local rule_code = nodecodes.rule local dir_code = nodecodes.dir local par_code = nodecodes.par local whatsit_code = nodecodes.whatsit +local passive_code = nodecodes.passive local dimenfactors = number.dimenfactors local formatters = string.formatters @@ -303,57 +304,68 @@ end nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end local function listtoutf(h,joiner,textonly,last,nodisc) - local w = { } - local n = 0 - local g = formatters["<%i>"] - local d = formatters["[%s|%s|%s]"] - while h do - local c, id = isglyph(h) - if c then - n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif id == disc_code then - local pre, pos, rep = getdisc(h) - if not nodisc then - n = n + 1 ; w[n] = d( - pre and listtoutf(pre,joiner,textonly) or "", - pos and listtoutf(pos,joiner,textonly) or "", - rep and listtoutf(rep,joiner,textonly) or "" - ) - elseif rep then - n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" - end - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif textonly then - if id == glue_code then - if getwidth(h) > 0 then - n = n + 1 ; w[n] = " " + if h then + local w = { } + local n = 0 + local g = formatters["<%i>"] + local d = formatters["[%s|%s|%s]"] + while h do + local c, id = isglyph(h) + if c then + n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif id == disc_code then + local pre, pos, rep = getdisc(h) + if not nodisc then + n = n + 1 ; w[n] = d( + pre and listtoutf(pre,joiner,textonly) or "", + pos and listtoutf(pos,joiner,textonly) or "", + rep and listtoutf(rep,joiner,textonly) or "" + ) + elseif rep then + n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" + end + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif id == passive_code then + -- smells like a bug in luatex + print("weird: passive node in listtoutf") + return "" + elseif textonly then + if id == glue_code then + if getwidth(h) > 0 then + n = n + 1 ; w[n] = " " + end + elseif id == hlist_code or id == vlist_code then + local l = getlist(h) + n = n + 1 ; w[n] = "[" + if l then + n = n + 1 ; w[n] = listtoutf(l,joiner,textonly,last,nodisc) + end + n = n + 1 ; w[n] = "]" end - elseif id == hlist_code or id == vlist_code then - n = n + 1 ; w[n] = "[" - n = n + 1 ; w[n] = listtoutf(getlist(h),joiner,textonly,last,nodisc) - n = n + 1 ; w[n] = "]" + else + n = n + 1 ; w[n] = "[-]" + end + if h == last then + break + else + h = getnext(h) end - else - n = n + 1 ; w[n] = "[-]" - end - if h == last then - break - else - h = getnext(h) end + return concat(w,"",1,(w[n] == joiner) and (n-1) or n) + else + return "" end - return concat(w,"",1,(w[n] == joiner) and (n-1) or n) end function nodes.listtoutf(h,joiner,textonly,last,nodisc) if h then local joiner = joiner == true and utfchar(0x200C) or joiner -- zwnj - return listtoutf(tonut(h),joiner,textonly,last and tonut(last),nodisc) + return listtoutf(tonut(h),joiner,textonly,last and tonut(last) or nil,nodisc) else return "" end diff --git a/tex/context/base/mkiv/page-inj.mkvi b/tex/context/base/mkiv/page-inj.mkvi index f1b520f5e..0adfca92d 100644 --- a/tex/context/base/mkiv/page-inj.mkvi +++ b/tex/context/base/mkiv/page-inj.mkvi @@ -33,8 +33,14 @@ \let\page_boxes_flush_after \clf_flushpageinjectionsafter \def\page_injections_flush_indeed - {\scrn_canvas_synchronize_set{\pageinjectionparameter\c!width}{\pageinjectionparameter\c!height}% - \invokepagehandler\v!normal{\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}% + {\begingroup + \setbox\scratchbox\normalhpack + {\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}% + \printpaperwidth \wd\scratchbox + \printpaperheight\ht\scratchbox + \scrn_canvas_synchronize_only + \invokepagehandler\v!normal{\box\scratchbox}% + \endgroup \scrn_canvas_synchronize_reset} \def\page_injections_flush_saved#name#parameters% diff --git a/tex/context/base/mkiv/page-mix.lua b/tex/context/base/mkiv/page-mix.lua index 7828b7e56..a4e08063d 100644 --- a/tex/context/base/mkiv/page-mix.lua +++ b/tex/context/base/mkiv/page-mix.lua @@ -251,12 +251,19 @@ local function preparesplit(specification) -- a rather large function report_state("fatal error, no list") return end - local head = getlist(list) or specification.originalhead + local head = nil + if getid(list) == hlist_code then + head = list + else + head = getlist(list) or specification.originalhead + end if not head then report_state("fatal error, no head") return end + slidenodes(head) -- we can have set prev's to nil to prevent backtracking + local discarded = { } local originalhead = head local originalwidth = specification.originalwidth or getwidth(list) @@ -441,6 +448,7 @@ local function preparesplit(specification) -- a rather large function if column == nofcolumns then column = 0 -- nicer in trace rest = head +-- rest = nil return false, 0 else local skipped @@ -637,7 +645,6 @@ local function preparesplit(specification) -- a rather large function end local function process_list(current,nxt) --- print(nuts.getpre(current),nuts.getpost(current)) local nxtid = nxt and getid(nxt) line = line + 1 local inserts, insertskips, nextskips, inserttotal = nil, 0, 0, 0 @@ -773,7 +780,6 @@ local function preparesplit(specification) -- a rather large function specification.rest = rest specification.overflow = overflow specification.discarded = discarded - setlist(getbox(specification.box)) return specification @@ -900,6 +906,7 @@ local function getsplit(result,n) end setprev(h) -- move up + local strutht = result.strutht local strutdp = result.strutdp local lineheight = strutht + strutdp @@ -908,6 +915,19 @@ local function getsplit(result,n) local v = new_vlist() setlist(v,h) + -- safeguard ... i need to figure this out some day + + local c = r.head + while c do + if c == result.rest then + report_state("flush, column %s, %s",n,"suspicous rest") + result.rest = nil + break + else + c = getnext(c) + end + end + -- local v = vpack(h,"exactly",height) if isglobal then -- option @@ -1067,7 +1087,10 @@ implement { arguments = "integer", actions = function(n) if result then - context(tonode(getsplit(result,n))) + local list = getsplit(result,n) + if list then + context(tonode(list)) + end end end, } @@ -1085,7 +1108,10 @@ implement { name = "mixflushrest", actions = function() if result then - context(tonode(getrest(result))) + local rest = getrest(result) + if rest then + context(tonode(rest)) + end end end } @@ -1094,7 +1120,10 @@ implement { name = "mixflushlist", actions = function() if result then - context(tonode(getlist(result))) + local list = getlist(result) + if list then + context(tonode(list)) + end end end } diff --git a/tex/context/base/mkiv/page-one.mkiv b/tex/context/base/mkiv/page-one.mkiv index 54e53035f..dbed7429a 100644 --- a/tex/context/base/mkiv/page-one.mkiv +++ b/tex/context/base/mkiv/page-one.mkiv @@ -63,6 +63,22 @@ % \fi % \fi} +% \unexpanded\def\page_one_command_set_vsize +% {\ifgridsnapping +% \ifcase\layoutlines +% \getrawnoflines\textheight +% \else +% \noflines\layoutlines +% \fi +% \global\vsize\noflines\openlineheight +% \else +% \global\vsize\textheight +% \fi +% \global\advance\vsize\d_page_adapts_delta +% % alternatively we could set it in builders.buildpage_filter +% % \ifdim\pagegoal<\maxdimen .. \fi +% \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax} + \unexpanded\def\page_one_command_set_vsize {\ifgridsnapping \ifcase\layoutlines @@ -75,10 +91,10 @@ \global\vsize\textheight \fi \global\advance\vsize\d_page_adapts_delta - % alternatively we could set it in builders.buildpage_filter - % \ifdim\pagegoal<\maxdimen .. \fi - \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax} - + % \pagegoal\dimexpr\vsize-\d_page_floats_inserted_top-\d_page_floats_inserted_bottom\relax} + % per 2021/9/9 : otherwise weird notes overlap with side floats + \settotalinsertionheight + \pagegoal\dimexpr\vsize-\totalinsertionheight\relax} % 1 = partial page, 2 = whole page, 3 = partial page diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 9c9066b38..2eaad3b9c 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 3812c41a2..05e942bc1 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua index 6fcc66082..f74bc3b12 100644 --- a/tex/context/base/mkiv/util-prs.lua +++ b/tex/context/base/mkiv/util-prs.lua @@ -572,9 +572,9 @@ end -- "1","2","3","4" -- "5","6","7","8" -- ]] --- + -- local mycsvsplitter = parsers.csvsplitter { numbers = true } --- + -- local list = mycsvsplitter(crap) inspect(list) -- and this is a slightly patched version of a version posted by Philipp Gesang diff --git a/tex/context/base/mkxl/buff-ver.mkxl b/tex/context/base/mkxl/buff-ver.mkxl index 3cde23d5e..fd49bd421 100644 --- a/tex/context/base/mkxl/buff-ver.mkxl +++ b/tex/context/base/mkxl/buff-ver.mkxl @@ -149,7 +149,7 @@ \installcommandhandler \??type {type} \??type \appendtoks - \frozen\instance\setuevalue{\currenttype}{\buff_verbatim_type{\currenttype}}% + \frozen\instance\protected\edefcsname\currenttype\endcsname{\buff_verbatim_type{\currenttype}}% \to \everydefinetype \appendtoks diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 61a039f6b..c9e67279a 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.09.06 11:44} +\newcontextversion{2021.09.13 09:37} %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/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index a923267f2..97035d34e 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.09.06 11:44} +\immutable\edef\contextversion{2021.09.13 09:37} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt index dcafac025..f83fd8776 100644 --- a/tex/context/base/mkxl/font-ots.lmt +++ b/tex/context/base/mkxl/font-ots.lmt @@ -162,6 +162,8 @@ local trace_testruns = false registertracker("otf.testruns", function local forcediscretionaries = false local forcepairadvance = false -- for testing +local repeatlastmultiple = context and true + directives.register("otf.forcediscretionaries",function(v) forcediscretionaries = v end) @@ -650,11 +652,12 @@ end local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what to do with skiphash matches here local nofmultiples = #multiple if nofmultiples > 0 then + local first = start resetinjection(start) setchar(start,multiple[1]) if nofmultiples > 1 then - local sn = getnext(start) - for k=2,nofmultiples do + -- local sn = getnext(start) + for i=2,nofmultiples do -- untested: -- -- while ignoremarks and marks[getchar(sn)] then @@ -662,20 +665,56 @@ local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what t -- end local n = copynode(start) -- ignore components resetinjection(n) - setchar(n,multiple[k]) + setchar(n,multiple[i]) insertnodeafter(head,start,n) start = n end - if what == true then - -- we're ok - elseif what > 1 then - local m = multiple[nofmultiples] - for i=2,what do - local n = copynode(start) -- ignore components - resetinjection(n) - setchar(n,m) - insertnodeafter(head,start,n) - start = n + end + if what ~= true then + -- This is just some experimental code; we might introduce gsub_extensible + -- some day instead. Beware: when we have a feature that mixes alternates and + -- multiples we need to make sure we don't handle the alternate string values + -- here. + local kind = type(what) + local m, f, l + if kind == "string" then + local what, n = string.match(what,"^repeat(.-)[:=](%d+)$") + if what == "middle" then + m = tonumber(n) + elseif what == "first" then + f = tonumber(n) + elseif what == "last" then + l = tonumber(n) + end + elseif kind == "table" then + -- won't happen because currently we don't split these values + m = what.middle + f = what.first + l = what.last + end + if f or m or l then + if m and m > 1 and nofmultiples == 3 then + local middle = getnext(first) + for i=2,m do + local n = copynode(middle) -- ignore components + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if f and f > 1 then + for i=2,f do + local n = copynode(first) -- ignore components + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if l and l > 1 then + for i=2,l do + local n = copynode(start) -- ignore components + resetinjection(n) + insertnodeafter(head,start,n) + start = n + end end end end @@ -1085,7 +1124,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode, end return head, start, true elseif trace_bugs then - -- onetimemessage(currentfont,basechar,"no base anchors",report_fonts) + -- onetimemessage(currentfont,basechar,"no base anchors") logwarning("%s: mark %s is not anchored to %s",pref(dataset,sequence),gref(markchar),gref(basechar)) end elseif trace_bugs then @@ -1152,7 +1191,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm end elseif trace_bugs then -- logwarning("%s: char %s is missing in font",pref(dataset,sequence),gref(basechar)) - onetimemessage(currentfont,basechar,"no base anchors",report_fonts) + onetimemessage(currentfont,basechar,"no base anchors") end elseif trace_bugs then logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),1) @@ -1900,7 +1939,7 @@ function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup, end end elseif trace_bugs then - onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) + onetimemessage(currentfont,startchar,"no entry anchors") end break end diff --git a/tex/context/base/mkxl/lpdf-img.lmt b/tex/context/base/mkxl/lpdf-img.lmt index ecd154bbf..8e7427ae6 100644 --- a/tex/context/base/mkxl/lpdf-img.lmt +++ b/tex/context/base/mkxl/lpdf-img.lmt @@ -1239,38 +1239,41 @@ do s = - s end if s > 0 then - if s == 1 then - for i=1,y do - local r = d[i] - for j=1,x do - n = n + 1 ; t[n] = chars[r[j]] - end - end - elseif s == 2 then - for i=1,y do - local r = d[i] - for j=1,x do - local c = r[j] - n = n + 1 ; t[n] = chars[c[1]] - n = n + 1 ; t[n] = chars[c[2]] - n = n + 1 ; t[n] = chars[c[3]] - -- n = n + 1 ; t[n] = char(c[1],c[2],c[3]) -- test this - end - end - elseif s == 3 then - for i=1,y do - local r = d[i] - for j=1,x do - local c = r[j] - n = n + 1 ; t[n] = chars[c[1]] - n = n + 1 ; t[n] = chars[c[2]] - n = n + 1 ; t[n] = chars[c[3]] - n = n + 1 ; t[n] = chars[c[4]] - -- n = n + 1 ; t[n] = char(c[1],c[2],c[3],c[4]) -- test this - end - end - end - return concat(t) + -- if true then + return string.packrowscolumns(d) + -- end + -- if s == 1 then + -- for i=1,y do + -- local r = d[i] + -- for j=1,x do + -- n = n + 1 ; t[n] = chars[r[j]] + -- end + -- end + -- elseif s == 2 then + -- for i=1,y do + -- local r = d[i] + -- for j=1,x do + -- local c = r[j] + -- n = n + 1 ; t[n] = chars[c[1]] + -- n = n + 1 ; t[n] = chars[c[2]] + -- n = n + 1 ; t[n] = chars[c[3]] + -- -- n = n + 1 ; t[n] = char(c[1],c[2],c[3]) -- test this + -- end + -- end + -- elseif s == 3 then + -- for i=1,y do + -- local r = d[i] + -- for j=1,x do + -- local c = r[j] + -- n = n + 1 ; t[n] = chars[c[1]] + -- n = n + 1 ; t[n] = chars[c[2]] + -- n = n + 1 ; t[n] = chars[c[3]] + -- n = n + 1 ; t[n] = chars[c[4]] + -- -- n = n + 1 ; t[n] = char(c[1],c[2],c[3],c[4]) -- test this + -- end + -- end + -- end + -- return concat(t) else local z = d[0] and 0 or 1 if s == -1 then diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 8d3fc7fde..e1637228a 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -47,6 +47,7 @@ local zlibcompresssize = xzip.compresssize local nuts = nodes.nuts local tonut = nodes.tonut +local tonode = nuts.tonode local pdfreference = lpdf.reference local pdfdictionary = lpdf.dictionary @@ -986,16 +987,18 @@ local localconverter = nil -- will be set local flushimage do - local rulecodes = nodes.rulecodes - local newrule = nodes.pool.rule + local newimagerule = nuts.pool.imagerule + local newboxrule = nuts.pool.boxrule local setprop = nuts.setprop local getprop = nuts.getprop + local setattrlist = nuts.setattrlist local getwhd = nuts.getwhd local flushlist = nuts.flushlist local getdata = nuts.getdata + local rulecodes = nodes.rulecodes local normalrule_code = rulecodes.normal local boxrule_code = rulecodes.box local imagerule_code = rulecodes.image @@ -1083,10 +1086,10 @@ local flushimage do else wd, ht, dp = l.width, l.height, l.depth end - local rule = newrule(wd,ht,dp) -- newboxrule - rule.subtype = boxrule_code - setprop(tonut(rule),"index",index) - return rule, wd, ht, dp + local rule = newboxrule(wd,ht,dp) + setattrlist(rule,true) + setprop(rule,"index",index) + return tonode(rule), wd, ht, dp else report("no box resource %S",index) end @@ -2749,9 +2752,9 @@ do local imagetypes = images.types -- pdf png jpg jp2 jbig2 stream local img_none = imagetypes.none - local rulecodes = nodes.rulecodes - - local setprop = nodes.nuts.setprop + local newimagerule = nuts.pool.imagerule + local setattrlist = nuts.setattrlist + local setprop = nuts.setprop local report_images = logs.reporter("backend","images") @@ -2759,7 +2762,6 @@ do local indices = { } local bpfactor = number.dimenfactors.bp - local imagerule_code = rulecodes.image function codeinjections.newimage(specification) return specification @@ -2849,14 +2851,14 @@ do embedimage(specification) end -- - local width = specification.width or 0 - local height = specification.height or 0 - local depth = specification.depth or 0 - -- newimagerule - local n = nodes.pool.rule(width,height,depth) - n.subtype = imagerule_code - setprop(tonut(n),"index",specification.index) - return n + local n = newimagerule( + specification.width or 0, + specification.height or 0, + specification.depth or 0 + ) + setattrlist(n,true) + setprop(n,"index",specification.index) + return tonode(n) end pdfincludeimage = function(index) diff --git a/tex/context/base/mkxl/meta-imp-bitmaps.mkxl b/tex/context/base/mkxl/meta-imp-bitmaps.mkxl index e7846a1e8..069b74207 100644 --- a/tex/context/base/mkxl/meta-imp-bitmaps.mkxl +++ b/tex/context/base/mkxl/meta-imp-bitmaps.mkxl @@ -251,6 +251,21 @@ end end + function graphics.bitmaps.manipulators.evening(b,m) + local xsize = b.xsize + local ysize = b.ysize + local data = b.data + local colorspace = b.colorspace + if colorspace == 1 then + for r=1,ysize do + local row = data[r] + for c=1,xsize do + row[c] = row[c] // 2 + end + end + end + end + context.startTEXpage() local b = graphics.bitmaps.load("hacker.jpg") graphics.bitmaps.manipulators.myframe(b,20) @@ -265,20 +280,34 @@ graphics.bitmaps.tocontext(b,50*65536,nil) context.stopTEXpage() - local m = table.setmetatableindex(function(t,k) local v = { k, k, k } t[k] = v return v end) + do + + local m = table.setmetatableindex(function(t,k) local v = { k, k, k } t[k] = v return v end) + + -- local c = { 255, 0, 0 } for i=0x00,0x1F do m[i] = c end + -- local c = { 0, 255, 0 } for i=0x20,0x3F do m[i] = c end + -- local c = { 0, 0, 255 } for i=0x40,0x5F do m[i] = c end + -- local c = { 255, 255, 0 } for i=0x60,0x7F do m[i] = c end + -- local c = { 255, 0, 255 } for i=0x80,0x9F do m[i] = c end + -- local c = { 0, 255, 255 } for i=0xA0,0xBF do m[i] = c end + -- local c = { 255, 255, 255 } for i=0xC0,0xDF do m[i] = c end + -- local c = { 0, 0, 0 } for i=0xE0,0xFF do m[i] = c end --- local c = { 255, 0, 0 } for i=0x00,0x1F do m[i] = c end --- local c = { 0, 255, 0 } for i=0x20,0x3F do m[i] = c end - local c = { 0, 0, 255 } for i=0x40,0x5F do m[i] = c end --- local c = { 255, 255, 0 } for i=0x60,0x7F do m[i] = c end --- local c = { 255, 0, 255 } for i=0x80,0x9F do m[i] = c end --- local c = { 0, 255, 255 } for i=0xA0,0xBF do m[i] = c end --- local c = { 255, 255, 255 } for i=0xC0,0xDF do m[i] = c end --- local c = { 0, 0, 0 } for i=0xE0,0xFF do m[i] = c end + local c = { 0, 0, 255 } for i=0x40,0x5F do m[i] = c end + local c = { 0, 255, 0 } for i=0x80,0x9F do m[i] = c end + local c = { 255, 0, 0 } for i=0xB0,0xCF do m[i] = c end + + context.startTEXpage() + local b = graphics.bitmaps.load("mill.png") + graphics.bitmaps.manipulators.colorize(b,m) + graphics.bitmaps.tocontext(b,50*65536,nil) + context.stopTEXpage() + + end context.startTEXpage() local b = graphics.bitmaps.load("mill.png") - graphics.bitmaps.manipulators.colorize(b,m) + graphics.bitmaps.manipulators.evening(b) graphics.bitmaps.tocontext(b,50*65536,nil) context.stopTEXpage() @@ -291,6 +320,8 @@ graphics.bitmaps.tocontext(b,50*65536,nil) }} +% This is inefficient because textext processes twice, so a "todo". + \startMPpage picture p ; p := textext("\MyImage{mill.png}") ; diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index d92ef1385..33aa74ad2 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -658,6 +658,11 @@ local function getparameterpath() end if type(v) == "table" then return injectpath(v,connector,close) + elseif type(v) == "string" then + local code = load("return " .. v) + if code then + return code() + end else return injectpair(0,0) end diff --git a/tex/context/base/mkxl/mult-aux.mkxl b/tex/context/base/mkxl/mult-aux.mkxl index ba0572d15..64623efe6 100644 --- a/tex/context/base/mkxl/mult-aux.mkxl +++ b/tex/context/base/mkxl/mult-aux.mkxl @@ -957,6 +957,9 @@ \expandafter\firstofoneargument \fi} +\permanent\def\ifcommandhandler#1#2% namespace name + {\ifcsname#1#2:\s!parent\endcsname} + % another set of (fast) helpers (grep for usage): \permanent\def\expandnamespaceparameter#1#2#3% \??xx \getp \c!xx \v!yy diff --git a/tex/context/base/mkxl/node-fin.lmt b/tex/context/base/mkxl/node-fin.lmt index 2e744a48a..4bf8663be 100644 --- a/tex/context/base/mkxl/node-fin.lmt +++ b/tex/context/base/mkxl/node-fin.lmt @@ -193,7 +193,7 @@ local function process(attribute,head,inheritance,default) -- one attribute current = default end elseif current ~= outer then - head = insertnodebefore(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[outer])) current = outer end elseif default and inheritance then diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index f78e1add6..8675ba05e 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -263,6 +263,8 @@ local nuts = { xscaled = direct.xscaled, yscaled = direct.yscaled, -- getxyoffsets = direct.getxyoffsets, + getspeciallist = direct.getspeciallist, + setspeciallist = direct.setspeciallist, } nodes.nuts = nuts diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt index a1fa24bbd..4c456b263 100644 --- a/tex/context/base/mkxl/node-res.lmt +++ b/tex/context/base/mkxl/node-res.lmt @@ -183,6 +183,8 @@ local rule = register_nut(new_nut(rule_code)) -- local emptyrule = register_nut(new_nut(rule_code,rulecodes.empty)) -- setdirection(rule, lefttoright_code) local userrule = register_nut(new_nut(rule_code,rulecodes.user)) -- setdirection(rule, lefttoright_code) local outlinerule = register_nut(new_nut(rule_code,rulecodes.outline)) -- setdirection(rule, lefttoright_code) +local imagerule = register_nut(new_nut(rule_code,rulecodes.image)) -- setdirection(rule, lefttoright_code) +local boxrule = register_nut(new_nut(rule_code,rulecodes.box)) -- setdirection(rule, lefttoright_code) local hlist = register_nut(new_nut(nodecodes.hlist)) setdirection(hlist,lefttoright_code) local vlist = register_nut(new_nut(nodecodes.vlist)) setdirection(vlist,lefttoright_code) @@ -374,6 +376,22 @@ function nutpool.outlinerule(width,height,depth,line) -- w/h/d == nil will let t return n end +function nutpool.imagerule(width,height,depth) -- w/h/d == nil will let them adapt + local n = copy_nut(imagerule) + if width or height or depth then + setwhd(n,width,height,depth) + end + return n +end + +function nutpool.boxrule(width,height,depth) -- w/h/d == nil will let them adapt + local n = copy_nut(boxrule) + if width or height or depth then + setwhd(n,width,height,depth) + end + return n +end + function nutpool.leader(width,list) local n = copy_nut(cleader) if width then diff --git a/tex/context/base/mkxl/node-tra.lmt b/tex/context/base/mkxl/node-tra.lmt index 6fe2e2081..214c8a27c 100644 --- a/tex/context/base/mkxl/node-tra.lmt +++ b/tex/context/base/mkxl/node-tra.lmt @@ -307,57 +307,64 @@ end nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end local function listtoutf(h,joiner,textonly,last,nodisc) - local w = { } - local n = 0 - local g = formatters["<%i>"] - local d = formatters["[%s|%s|%s]"] - while h do - local c, id = isglyph(h) - if c then - n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif id == disc_code then - local pre, pos, rep = getdisc(h) - if not nodisc then - n = n + 1 ; w[n] = d( - pre and listtoutf(pre,joiner,textonly) or "", - pos and listtoutf(pos,joiner,textonly) or "", - rep and listtoutf(rep,joiner,textonly) or "" - ) - elseif rep then - n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" - end - if joiner then - n = n + 1 ; w[n] = joiner - end - elseif textonly then - if id == glue_code then - if getwidth(h) > 0 then - n = n + 1 ; w[n] = " " + if h then + local w = { } + local n = 0 + local g = formatters["<%i>"] + local d = formatters["[%s|%s|%s]"] + while h do + local c, id = isglyph(h) + if c then + n = n + 1 ; w[n] = c >= 0 and utfchar(c) or g(c) + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif id == disc_code then + local pre, pos, rep = getdisc(h) + if not nodisc then + n = n + 1 ; w[n] = d( + pre and listtoutf(pre,joiner,textonly) or "", + pos and listtoutf(pos,joiner,textonly) or "", + rep and listtoutf(rep,joiner,textonly) or "" + ) + elseif rep then + n = n + 1 ; w[n] = listtoutf(rep,joiner,textonly) or "" + end + if joiner then + n = n + 1 ; w[n] = joiner + end + elseif textonly then + if id == glue_code then + if getwidth(h) > 0 then + n = n + 1 ; w[n] = " " + end + elseif id == hlist_code or id == vlist_code then + local l = getlist(h) + n = n + 1 ; w[n] = "[" + if l then + n = n + 1 ; w[n] = listtoutf(l,joiner,textonly,last,nodisc) + end + n = n + 1 ; w[n] = "]" end - elseif id == hlist_code or id == vlist_code then - n = n + 1 ; w[n] = "[" - n = n + 1 ; w[n] = listtoutf(getlist(h),joiner,textonly,last,nodisc) - n = n + 1 ; w[n] = "]" + else + n = n + 1 ; w[n] = "[-]" + end + if h == last then + break + else + h = getnext(h) end - else - n = n + 1 ; w[n] = "[-]" - end - if h == last then - break - else - h = getnext(h) end + return concat(w,"",1,(w[n] == joiner) and (n-1) or n) + else + return "" end - return concat(w,"",1,(w[n] == joiner) and (n-1) or n) end function nodes.listtoutf(h,joiner,textonly,last,nodisc) if h then local joiner = joiner == true and utfchar(0x200C) or joiner -- zwnj - return listtoutf(tonut(h),joiner,textonly,last and tonut(last),nodisc) + return listtoutf(tonut(h),joiner,textonly,last and tonut(last) or nil,nodisc) else return "" end diff --git a/tex/context/base/mkxl/page-ini.mkxl b/tex/context/base/mkxl/page-ini.mkxl index 71158e0a7..e179b6d03 100644 --- a/tex/context/base/mkxl/page-ini.mkxl +++ b/tex/context/base/mkxl/page-ini.mkxl @@ -353,18 +353,20 @@ \newconstant\c_page_force_strut_depth_trace_mode -\installtextracker - {otr.forcestrutdepth} - {\c_page_force_strut_depth_trace_mode\plusone} - {\c_page_force_strut_depth_trace_mode\zerocount} - -\installoutputroutine\forcestrutdepth - {\clf_forcestrutdepth\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode - \unvbox\normalpagebox} - -\installoutputroutine\forcestrutdepthplus % experimental - {\clf_forcestrutdepthplus\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode - \unvbox\normalpagebox} +% \installtextracker +% {otr.forcestrutdepth} +% {\c_page_force_strut_depth_trace_mode\plusone} +% {\c_page_force_strut_depth_trace_mode\zerocount} + +% todo: only in mvl! + +% \installoutputroutine\forcestrutdepth +% {\clf_forcestrutdepth\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode +% \unvbox\normalpagebox} + +% \installoutputroutine\forcestrutdepthplus % experimental +% {\clf_forcestrutdepthplus\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode +% \unvbox\normalpagebox} % maybe better: % diff --git a/tex/context/base/mkxl/page-inj.mklx b/tex/context/base/mkxl/page-inj.mklx index fda757dbe..8732e2628 100644 --- a/tex/context/base/mkxl/page-inj.mklx +++ b/tex/context/base/mkxl/page-inj.mklx @@ -33,8 +33,14 @@ \let\page_boxes_flush_after \clf_flushpageinjectionsafter \def\page_injections_flush_indeed - {\scrn_canvas_synchronize_set{\pageinjectionparameter\c!width}{\pageinjectionparameter\c!height}% - \invokepagehandler\v!normal{\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}% + {\begingroup + \setbox\scratchbox\normalhpack + {\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}% + \printpaperwidth \wd\scratchbox + \printpaperheight\ht\scratchbox + \scrn_canvas_synchronize_only + \invokepagehandler\v!normal{\box\scratchbox}% + \endgroup \scrn_canvas_synchronize_reset} \def\page_injections_flush_saved#name#parameters% diff --git a/tex/context/base/mkxl/page-ins.mkxl b/tex/context/base/mkxl/page-ins.mkxl index 978f62f7c..b1e0d7bd7 100644 --- a/tex/context/base/mkxl/page-ins.mkxl +++ b/tex/context/base/mkxl/page-ins.mkxl @@ -60,7 +60,7 @@ \newtoks\t_page_inserts_list -\mutable\let\doprocessinsert\relax % probably kind of obsolete now +\mutable\let\doprocessinsert\gobbleoneargument % probably kind of obsolete now %D Maybe some day we will move settings here. @@ -87,14 +87,14 @@ \permanent\protected\def\processinsertions {\the\t_page_inserts_list} -\permanent\protected\def\synchronizeinsertions - {\let\doprocessinsert\page_inserts_synchronize - \processinsertions} - -\protected\def\page_inserts_synchronize#1% yes or no - {\ifvoid#1\else - \page_inserts_inject#1{\unvbox#1}% - \fi} +% \permanent\protected\def\synchronizeinsertions +% {\let\doprocessinsert\page_inserts_synchronize +% \processinsertions} +% +% \protected\def\page_inserts_synchronize#1% yes or no +% {\ifvoid#1\else +% \page_inserts_inject#1{\unvbox#1}% +% \fi} \permanent\protected\def\doifelseinsertion#1% {\ifcsname\??insertionnumber#1\endcsname @@ -180,9 +180,10 @@ number \currentinsertionnumber }% \relax - \t_page_inserts_list\expandafter\expandafter\expandafter - {\expandafter\the\expandafter\t_page_inserts_list - \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}% +% \t_page_inserts_list\expandafter\expandafter\expandafter +% {\expandafter\the\expandafter\t_page_inserts_list +% \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}% + \xtoksapp\t_page_inserts_list{\page_inserts_process{\currentinsertion}}% \page_inserts_set_multiplier\currentinsertionnumber\plusthousand \page_inserts_set_distance \currentinsertionnumber\zeropoint \page_inserts_set_limit \currentinsertionnumber\maxdimen diff --git a/tex/context/base/mkxl/page-mix.mkxl b/tex/context/base/mkxl/page-mix.mkxl index daafa4843..446185e43 100644 --- a/tex/context/base/mkxl/page-mix.mkxl +++ b/tex/context/base/mkxl/page-mix.mkxl @@ -31,6 +31,24 @@ % offsets (inner ones, so we change the hsize ... needed with backgrounds % when no content we currently loose the page +% nasty test case from mailing list (rest issue) +% +% \starttext +% . \blank[32*big] +% \startitemize +% \item 0 \startchoice[text] \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice \blank[6*big] +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \item 0 \startchoice \item 0 \item 0 \item 0 \item 0 \stopchoice +% \stopitemize +% \stoptext + \registerctxluafile{page-mix}{} \unprotect diff --git a/tex/context/base/mkxl/page-one.mkxl b/tex/context/base/mkxl/page-one.mkxl index 4a4ce6014..116f2146d 100644 --- a/tex/context/base/mkxl/page-one.mkxl +++ b/tex/context/base/mkxl/page-one.mkxl @@ -35,6 +35,39 @@ \protected\def\page_one_command_set_float_hsize {\global\hsize\textwidth} +%D It's complicated: + +\newconditional\c_page_one_set_vsize_tmp + +\installtextracker{otr.insertheights} + {\settrue\c_page_one_set_vsize_tmp} + {\setfalse\c_page_one_set_vsize_tmp} + +\def\page_one_command_set_vsize_tmp + {\settotalinsertionheight + \writestatus + {set vsize one} + {insert heights=\the\insertheights, + total insertion height=\the\totalinsertionheight, + delta=\the\dimexpr\insertheights-\totalinsertionheight}% + \page_one_command_set_vsize_new} + +\def\page_one_command_set_vsize_old + {\settotalinsertionheight + \pagegoal\dimexpr + \vsize + -\totalinsertionheight + \relax} + +\def\page_one_command_set_vsize_new + {\pagegoal\dimexpr + \vsize + -\d_page_floats_inserted_top + -\d_page_floats_inserted_bottom + -\insertheights + \relax + \insertheights\zeropoint} + \protected\def\page_one_command_set_vsize {\ifgridsnapping \ifcase\layoutlines @@ -49,12 +82,14 @@ \global\advance\vsize\d_page_adapts_delta % alternatively we could set it in builders.buildpage_filter % \ifdim\pagegoal<\maxdimen .. \fi - \pagegoal\dimexpr - \vsize - -\d_page_floats_inserted_top - -\d_page_floats_inserted_bottom - -\insertheights - \relax} + % \writestatus{!!!!!!!!}{\the\vsize-> v:\the\pagevsize,g:\the\pagegoal,t:\the\pagetotal,i:\the\insertheights}% + \ifconditional\c_page_one_set_vsize_tmp + \page_one_command_set_vsize_tmp + \orelse\ifzeropt\insertheights + \page_one_command_set_vsize_old + \else + \page_one_command_set_vsize_new + \fi} % 1 = partial page, 2 = whole page, 3 = partial page @@ -581,14 +616,24 @@ % \page_floats_report_total % \dohandlenextfloatindent} +% \def\page_one_place_float_here_indeed +% {\ifgridsnapping +% % otherwise real bad outcome +% \else +% % this was not really applied (delayed) +% % \baselinecorrection % this has to be done better (and definitely not in column mode) +% % so we now use this: +% \checkprevdepth +% \fi +% \doplacefloatbox +% \page_floats_report_total +% \dohandlenextfloatindent} + \def\page_one_place_float_here_indeed {\ifgridsnapping % otherwise real bad outcome \else - % this was not really applied (delayed) - % \baselinecorrection % this has to be done better (and definitely not in column mode) - % so we now use this: - \checkprevdepth + \forcestrutdepth \fi \doplacefloatbox \page_floats_report_total diff --git a/tex/context/base/mkxl/page-pcl.mkxl b/tex/context/base/mkxl/page-pcl.mkxl index 3ef07c9c5..b9838e771 100644 --- a/tex/context/base/mkxl/page-pcl.mkxl +++ b/tex/context/base/mkxl/page-pcl.mkxl @@ -100,20 +100,6 @@ %D \unknown -\protected\def\page_col_command_set_vsize % \page_one_command_set_vsize minus the pagegoal setting - {\ifgridsnapping - \ifcase\layoutlines - \getrawnoflines\textheight - \else - \noflines\layoutlines - \fi - \global\vsize\noflines\openlineheight - \else - \global\vsize\textheight - \fi} - -%D \unknown - \def\page_col_registered_text_area_b#1% {\begingroup \makeupwidth\d_page_col_column_width @@ -234,6 +220,8 @@ \global\advance\c_page_col_current\plusone \fi % + \page_col_notes_synchronize + % \page_col_command_set_vsize \page_col_command_set_hsize} @@ -719,8 +707,8 @@ \c!direction=\v!normal] \appendtoks % could become an option - \frozen\instance\setuevalue{\e!start\currentpagecolumns}{\startpagecolumns[\currentpagecolumns]}% - \frozen\instance\setuevalue{\e!stop \currentpagecolumns}{\stoppagecolumns}% + \frozen\instance\protected\edefcsname\e!start\currentpagecolumns\endcsname{\startpagecolumns[\currentpagecolumns]}% + \frozen\instance\protected\edefcsname\e!stop \currentpagecolumns\endcsname{\stoppagecolumns}% \to \everydefinepagecolumns \def\page_col_pickup_preceding @@ -754,6 +742,47 @@ \endgroup \fi} +% \let\page_col_notes_initialize \relax +% \let\page_col_notes_synchronize\relax +% \let\page_col_notes_reset \relax +% +% \protected\def\page_col_command_set_vsize % \page_one_command_set_vsize minus the pagegoal setting +% {\ifgridsnapping +% \ifcase\layoutlines +% \getrawnoflines\textheight +% \else +% \noflines\layoutlines +% \fi +% \global\vsize\noflines\openlineheight +% \else +% \global\vsize\textheight +% \fi} + +\newconditional\c_page_col_notes_lastcolumn + +\def\page_col_notes_synchronize + {\insertstoring\zerocount + \ifnum\c_page_col_current=\c_page_col_n_of_columns\relax + \strc_notes_process\page_col_notes_inject + \ifconditional\c_page_col_notes_lastcolumn + \insertstoring\plusone + \fi + \else + \strc_notes_process\page_col_notes_delay + \ifconditional\c_page_col_notes_lastcolumn + \insertstoring\plustwo + \fi + \fi} + +\def\page_col_notes_delay {\setfalse\c_page_col_notes_lastcolumn\ifcstok{\noteparameter\c!location}\v!lastcolumn\settrue\c_page_col_notes_lastcolumn\insertstorage\currentnoteinsertionnumber\plusone \fi} +\def\page_col_notes_inject{\setfalse\c_page_col_notes_lastcolumn\ifcstok{\noteparameter\c!location}\v!lastcolumn\settrue\c_page_col_notes_lastcolumn\insertstorage\currentnoteinsertionnumber\zerocount\fi} + +\def\page_col_notes_initialize {\insertstoring\zerocount\strc_notes_process\page_col_notes_delay} +\def\page_col_notes_reset {\insertstoring\zerocount\strc_notes_process\page_col_notes_inject} + +\protected\def\page_col_command_set_vsize % different ! + {\page_one_command_set_vsize} + \permanent\tolerant\protected\def\startpagecolumns[#1]% {\begingroup \begingroup @@ -824,6 +853,8 @@ \setupfloats[\c!ntop=\plusthousand]% % \setupfloats[\c!nbottom=\plusthousand]% % + \page_col_notes_initialize + % \page_col_command_set_vsize \page_col_command_set_hsize % @@ -843,6 +874,7 @@ \page_otr_command_set_vsize \page_otr_command_set_hsize \page + \page_col_notes_reset \endgroup} \protected\def\page_col_stop_nop diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl index dccfcbce9..20e92ad19 100644 --- a/tex/context/base/mkxl/page-sid.mkxl +++ b/tex/context/base/mkxl/page-sid.mkxl @@ -84,7 +84,7 @@ \newcount \c_page_sides_m_of_lines \newconditional \c_page_sides_delayed -\newconditional \c_page_sides_check_same_page +%newconditional \c_page_sides_check_same_page \newif \iftracesidefloats % public (might change) @@ -397,24 +397,31 @@ %D preceding material has more depth than that already. This way anchoring %D becomes predictable. +% \protected\def\page_sides_force_depth +% {\iftracesidefloats +% \begingroup +% \c_page_force_strut_depth_trace_mode\plusone +% \ifconditional\c_page_sides_check_same_page +% \forcestrutdepthplus +% \else +% \forcestrutdepth +% \fi +% \endgroup +% \else +% \ifconditional\c_page_sides_check_same_page +% \forcestrutdepthplus +% \else +% \forcestrutdepth +% \fi +% \fi +% \page_otr_command_set_vsize} % new + \protected\def\page_sides_force_depth {\iftracesidefloats - \begingroup - \c_page_force_strut_depth_trace_mode\plusone - \ifconditional\c_page_sides_check_same_page - \forcestrutdepthplus - \else - \forcestrutdepth - \fi - \endgroup - \else - \ifconditional\c_page_sides_check_same_page - \forcestrutdepthplus - \else - \forcestrutdepth - \fi + \enabletrackers[otr.forcestrutdepth]% \c_page_force_strut_depth_trace_mode\plusone \fi - \page_otr_command_set_vsize} % new + \forcestrutdepth + \page_otr_command_set_vsize} % new, no longer really needed \def\page_sides_flush_floats {\par @@ -781,18 +788,18 @@ \def\page_sides_analyse_space {\page_sides_analyse_space_stage_one - \ifconditional\c_page_sides_check_same_page - \ifdim\d_spac_prevcontent>\zeropoint - \ifdim\dimexpr\scratchdimenone+\d_spac_prevcontent>\scratchdimentwo - \clf_pushatsame - \setbox\scratchbox\vpack{\clf_popatsame}% - \page - \box\scratchbox - \vskip-\lineskip - \page_sides_analyse_space_stage_one - \fi - \fi - \fi + % \ifconditional\c_page_sides_check_same_page + % \ifdim\d_spac_prevcontent>\zeropoint + % \ifdim\dimexpr\scratchdimenone+\d_spac_prevcontent>\scratchdimentwo + % \clf_pushatsame + % \setbox\scratchbox\vpack{\clf_popatsame}% + % \page + % \box\scratchbox + % \vskip-\lineskip + % \page_sides_analyse_space_stage_one + % \fi + % \fi + % \fi \page_sides_analyse_space_stage_two} %D As we have no clear end of one or more paragraphs we only have pre float diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt index 26ad8e43a..cd6dd46ad 100644 --- a/tex/context/base/mkxl/spac-ver.lmt +++ b/tex/context/base/mkxl/spac-ver.lmt @@ -2331,14 +2331,14 @@ do end local trace = false - local last = nil + -- local last = nil local vmode_code = tex.modelevels.vertical local temp_code = nodecodes.temp local texgetnest = tex.getnest local texgetlist = tex.getlist local getnodetail = nodes.tail - trackers.register("vspacing.forcestrutdepth",function(v) trace = v end) + -- trackers.register("vspacing.forcestrutdepth",function(v) trace = v end) -- abs : negative is inner @@ -2375,69 +2375,144 @@ do actions = vspacing.checkstrutdepth, } - function vspacing.forcestrutdepth(n,depth,trace_mode,plus) - local box = texgetbox(n) - if box then - box = tonut(box) - local head = getlist(box) - if head then - local tail = find_node_tail(head) - if tail then - if getid(tail) == hlist_code then - local dp = getdepth(tail) - if dp < depth then - setdepth(tail,depth) - outer.prevdepth = depth - if trace or trace_mode > 0 then - nuts.setvisual(tail,"depth") - end - end + -- function vspacing.forcestrutdepth(n,depth,trace_mode,plus) + -- local box = texgetbox(n) + -- if box then + -- box = tonut(box) + -- local head = getlist(box) + -- if head then + -- local tail = find_node_tail(head) + -- if tail then + -- if getid(tail) == hlist_code then + -- local dp = getdepth(tail) + -- if dp < depth then + -- setdepth(tail,depth) + -- outer.prevdepth = depth + -- if trace or trace_mode > 0 then + -- nuts.setvisual(tail,"depth") + -- end + -- end + -- end + -- -- last = nil + -- -- if plus then + -- -- -- penalty / skip ... + -- -- local height = 0 + -- -- local sofar = 0 + -- -- local same = false + -- -- local seen = false + -- -- local list = { } + -- -- last = nil + -- -- while tail do + -- -- local id = getid(tail) + -- -- if id == hlist_code or id == vlist_code then + -- -- local w, h, d = getwhd(tail) + -- -- height = height + h + d + sofar + -- -- sofar = 0 + -- -- last = tail + -- -- elseif id == kern_code then + -- -- sofar = sofar + getkern(tail) + -- -- elseif id == glue_code then + -- -- if seen then + -- -- sofar = sofar + getwidth(tail) + -- -- seen = false + -- -- else + -- -- break + -- -- end + -- -- elseif id == penalty_code then + -- -- local p = getpenalty(tail) + -- -- if p >= 10000 then + -- -- same = true + -- -- seen = true + -- -- else + -- -- break + -- -- end + -- -- else + -- -- break + -- -- end + -- -- tail = getprev(tail) + -- -- end + -- -- texsetdimen("global","d_spac_prevcontent",same and height or 0) + -- -- end + -- end + -- end + -- end + -- end + + local hlist_code = nodes.nodecodes.hlist + local line_code = nodes.listcodes.line + + local nuts = nodes.nuts + local getid = nuts.getid + local getsubtype = nuts.getsubtype + local getdepth = nuts.getdepth + local setdepth = nuts.setdepth + local gettotal = nuts.gettotal + local getspeciallist = nuts.getspeciallist + local setspeciallist = nuts.setspeciallist + + local triggerbuildpage = tex.triggerbuildpage + + local texgetdimen = tex.getdimen + local texsetdimen = tex.setdimen + local texgetnest = tex.getnest + local texget = tex.get + local texset = tex.set + + local trace = false trackers.register("otr.forcestrutdepth", function(v) + trace = v and function(n) + nuts.setvisual(nuts.tonut(n),nodes.visualizers.modes.depth) + end + end) + + function vspacing.forcestrutdepth() + -- check if in mvl + if texgetnest("ptr") == 0 then + triggerbuildpage() -- return true when mvl + local head, tail = getspeciallist("page_head") + if tail and getid(tail) == hlist_code and getsubtype(tail) == line_code then -- isline(tail) + local strutdp = texgetdimen("strutdp") + local delta = strutdp - getdepth(tail) + if delta > 0 then + setdepth(tail,strutdp) + texset("pagetotal",texget("pagetotal") + delta) + texset("pagedepth",strutdp) + if trace then + trace(tail) end - last = nil - if plus then - -- penalty / skip ... - local height = 0 - local sofar = 0 - local same = false - local seen = false - local list = { } - last = nil - while tail do - local id = getid(tail) - if id == hlist_code or id == vlist_code then - local w, h, d = getwhd(tail) - height = height + h + d + sofar - sofar = 0 - last = tail - elseif id == kern_code then - sofar = sofar + getkern(tail) - elseif id == glue_code then - if seen then - sofar = sofar + getwidth(tail) - seen = false - else - break - end - elseif id == penalty_code then - local p = getpenalty(tail) - if p >= 10000 then - same = true - seen = true - else - break - end - else - break - end - tail = getprev(tail) - end - texsetdimen("global","d_spac_prevcontent",same and height or 0) + end + end + else + local nest = texgetnest() + -- if abs(nest.mode) == vmode_code and nest.head then + local tail = nest.tail + if tail.id == hlist_code and tail.subtype == line_code then + local strutdp = texgetdimen("strutdp") + if tail.depth < strutdp then + tail.depth = strutdp + end + nest.prevdepth = strutdp + if trace then + trace(tail) end end - end + -- end end end + -- interfaces.implement { + -- name = "removelastline", + -- actions = function() + -- local h, t = getspeciallist("page_head") + -- if t and getid(t) == hlist_code and getsubtype(t) == line_code then + -- local total = gettotal(t) + -- h = remove_node(h,t,true) + -- setspeciallist(h) + -- texset("pagetotal",texget("pagetotal") - total) + -- -- set prevdepth + -- end + -- end + -- } + function vspacing.pushatsame() -- needs better checking ! if last then -- setsplit @@ -2488,18 +2563,25 @@ do scope = "private" } - implement { - name = "forcestrutdepth", - arguments = { "integer", "dimension", "integer" }, - actions = vspacing.forcestrutdepth, - scope = "private" - } + -- implement { + -- name = "forcestrutdepth", + -- arguments = { "integer", "dimension", "integer" }, + -- actions = vspacing.forcestrutdepth, + -- scope = "private" + -- } + + -- implement { + -- name = "forcestrutdepthplus", + -- arguments = { "integer", "dimension", "integer", true }, + -- actions = vspacing.forcestrutdepth, + -- scope = "private" + -- } implement { - name = "forcestrutdepthplus", - arguments = { "integer", "dimension", "integer", true }, + name = "forcestrutdepth", + public = true, + protected = true, actions = vspacing.forcestrutdepth, - scope = "private" } implement { diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 94a273f80..5f929b5db 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -144,15 +144,15 @@ \definelist[\v!formula] -\permanent\defcsname\e!start\v!formula\endcsname{\strc_formulas_start_formula{}} -\permanent\defcsname\e!stop \v!formula\endcsname{\strc_formulas_stop_formula} +\permanent\protected\defcsname\e!start\v!formula\endcsname{\strc_formulas_start_formula{}} +\permanent\protected\defcsname\e!stop \v!formula\endcsname{\strc_formulas_stop_formula} \let\strc_formulas_start_formula\relax % defined later \let\strc_formulas_stop_formula \relax % defined later \permanent\tolerant\protected\def\defineformulaalternative[#1]#*[#2]#*[#3]% - {\frozen\instance\defcsname\e!start#1\v!formula\endcsname{#2}% - \frozen\instance\defcsname\e!stop #1\v!formula\endcsname{#3}} + {\frozen\instance\protected\defcsname\e!start#1\v!formula\endcsname{#2}% + \frozen\instance\protected\defcsname\e!stop #1\v!formula\endcsname{#3}} % sp = single line paragraph sd = single line display % mp = multi line paragraph md = multy line display diff --git a/tex/context/base/mkxl/strc-not.mklx b/tex/context/base/mkxl/strc-not.mklx index 857e7ce24..3bc6bf581 100644 --- a/tex/context/base/mkxl/strc-not.mklx +++ b/tex/context/base/mkxl/strc-not.mklx @@ -419,7 +419,8 @@ \doifelseinsertion\currentnote \donothing {\defineinsertion[\currentnote]% could be an option - \normalexpanded{\t_strc_notes{\the\t_strc_notes\noexpand\strc_notes_process_list{\currentnote}}}}% +% \normalexpanded{\t_strc_notes{\the\t_strc_notes\noexpand\strc_notes_process_list{\currentnote}}}}% + \xtoksapp\t_strc_notes{\noexpand\strc_notes_process_list{\currentnote}}}% \letnoteparameter\s!insert\currentnote \definenotation[\currentnote][\c!type=\v!note]% \else diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 911d0144b..a873d15a3 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -779,6 +779,12 @@ \showboxbreadth \maxcount \showboxdepth \maxcount} +\permanent\protected\def\tracingless + {\tracingall + \tracingoutput \zerocount + \showboxbreadth \maxcount + \showboxdepth \plusten} + \permanent\protected\def\loggingall {\tracingall \tracingonline \zerocount} diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 48e8ceeb8..3300d2f75 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -109,23 +109,6 @@ local a_layer = attributes.private("viewerlayer") local enableaction = nodes.tasks.enableaction --- local trace_hbox --- local trace_vbox --- local trace_vtop --- local trace_kern --- local trace_glue --- local trace_penalty --- local trace_fontkern --- local trace_strut --- local trace_whatsit --- local trace_user --- local trace_math --- local trace_italic --- local trace_discretionary --- local trace_expansion --- local trace_line --- local trace_space - local report_visualize = logs.reporter("visualize") local modes = { @@ -161,6 +144,8 @@ local modes = { insert = 0x4000000, } +visualizers.modes = modes + 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_mathlistkern, l_italic, l_origin, l_discretionary, l_expansion, l_line, l_space, l_depth, l_dir, l_whatsit, l_mark, l_insert @@ -280,7 +265,7 @@ local function setvisual(n,a,what,list) -- this will become more efficient when else a = a | preset_all end - else + elseif type(n) == "string" then for s in gmatch(n,"[a-z]+") do local m = modes[s] if not m then @@ -291,6 +276,8 @@ local function setvisual(n,a,what,list) -- this will become more efficient when a = a | m end end + elseif type(n) == "number" then + a = a | n end if not a or a == 0 or a == unsetvalue then return unsetvalue diff --git a/tex/context/base/mkxl/typo-bld.lmt b/tex/context/base/mkxl/typo-bld.lmt index d9cd78385..31cc0bb59 100644 --- a/tex/context/base/mkxl/typo-bld.lmt +++ b/tex/context/base/mkxl/typo-bld.lmt @@ -259,8 +259,8 @@ function builders.buildpage_filter(groupcode) end end -registercallback('vpack_filter', builders.vpack_filter, "vertical spacing etc") -registercallback('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") +registercallback('vpack_filter', builders.vpack_filter, "vertical spacing etc") +registercallback('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") statistics.register("v-node processing time", function() return statistics.elapsedseconds(builders) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c83cc1320..66e8b627e 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 : 2021-09-06 11:44 +-- merge date : 2021-09-13 09:37 do -- begin closure to overcome local limits and interference @@ -26899,6 +26899,7 @@ local trace_compruns=false registertracker("otf.compruns",function(v) trace_com local trace_testruns=false registertracker("otf.testruns",function(v) trace_testruns=v end) local forcediscretionaries=false local forcepairadvance=false +local repeatablemultiples=context or false directives.register("otf.forcediscretionaries",function(v) forcediscretionaries=v end) @@ -27277,15 +27278,47 @@ local function multiple_glyphs(head,start,multiple,skiphash,what,stop) insertnodeafter(head,start,n) start=n end - if what==true then - elseif what>1 then - local m=multiple[nofmultiples] - for i=2,what do - local n=copy_node(start) - resetinjection(n) - setchar(n,m) - insertnodeafter(head,start,n) - start=n + if what~=true and repeatablemultiples then + local kind=type(what) + local m,f,l + if kind=="string" then + local what,n=string.match(what,"^repeat(.-)[:=](%d+)$") + if what=="middle" then + m=tonumber(n) + elseif what=="first" then + f=tonumber(n) + elseif what=="last" then + l=tonumber(n) + end + elseif kind=="table" then + m=what.middle + f=what.first + l=what.last + end + if f or m or l then + if m and m>1 and nofmultiples==3 then + local middle=getnext(first) + for i=2,m do + local n=copynode(middle) + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if f and f>1 then + for i=2,f do + local n=copynode(first) + resetinjection(n) + insertnodeafter(head,first,n) + end + end + if l and l>1 then + for i=2,l do + local n=copynode(start) + resetinjection(n) + insertnodeafter(head,start,n) + start=n + end + end end end end @@ -27699,7 +27732,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm end end elseif trace_bugs then - onetimemessage(currentfont,basechar,"no base anchors",report_fonts) + onetimemessage(currentfont,basechar,"no base anchors") end elseif trace_bugs then logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),1) @@ -28339,7 +28372,7 @@ function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup, end end elseif trace_bugs then - onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) + onetimemessage(currentfont,startchar,"no entry anchors") end break end |