From 4ad4129b06a3b631031f39a778ebdd210ed09ab4 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 17 Feb 2012 18:52:00 +0100 Subject: beta 2012.02.17 18:52 --- tex/context/base/anch-bck.mkvi | 132 ++++------------------- tex/context/base/anch-pgr.lua | 199 ++++++++++++++++++++--------------- tex/context/base/anch-pgr.mkiv | 12 +++ tex/context/base/anch-pos.lua | 29 ++++- tex/context/base/back-exp.lua | 20 +++- tex/context/base/back-exp.mkiv | 2 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4074 -> 4070 bytes tex/context/base/context-version.png | Bin 105550 -> 105731 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/font-otf.lua | 2 +- tex/context/base/font-otn.lua | 94 ++++++++--------- tex/context/base/node-inj.lua | 79 +++++++++----- tex/context/base/pack-box.mkiv | 4 +- tex/context/base/status-files.pdf | Bin 24314 -> 24264 bytes tex/context/base/status-lua.pdf | Bin 172259 -> 172311 bytes tex/context/base/status-mkiv.lua | 7 ++ tex/context/base/strc-tag.mkiv | 8 +- tex/context/base/tabl-ntb.mkiv | 5 +- tex/context/base/tabl-xtb.mkvi | 1 + 22 files changed, 308 insertions(+), 294 deletions(-) (limited to 'tex/context') diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index 5ac1b039b..cc796edef 100644 --- a/tex/context/base/anch-bck.mkvi +++ b/tex/context/base/anch-bck.mkvi @@ -31,42 +31,35 @@ \newcount\c_anch_backgrounds_text_n -\def\v_anch_backgrounds_text_current {pbg:0} -\def\v_anch_backgrounds_text_next {pbg:1} - +\def\v_anch_backgrounds_text_current {tbg:0} \def\v_anch_backgrounds_anchor_current_b{b:\v_anch_backgrounds_text_current} \def\v_anch_backgrounds_anchor_current_e{e:\v_anch_backgrounds_text_current} -\def\v_anch_backgrounds_anchor_next_b {b:\v_anch_backgrounds_text_next} -\def\v_anch_backgrounds_anchor_next_e {e:\v_anch_backgrounds_text_next} - \def\anch_backgrounds_text_initialize_next {\global\advance\c_anch_backgrounds_text_n\plusone - \edef\v_anch_backgrounds_text_current{pbg:\number\c_anch_backgrounds_text_n}% - \xdef\v_anch_backgrounds_text_next {pbg:\number\numexpr\c_anch_backgrounds_text_n+\plusone\relax}} % x ? - -% todo : \synchonizepositionpage{b:\v_anch_backgrounds_text_current}{s:\v_anch_backgrounds_text_current}% - -\ifdefined\totalnoftextbackgrounds - % set in tuc -\else - \newcounter\totalnoftextbackgrounds -\fi + \edef\v_anch_backgrounds_text_current{tbg:\number\c_anch_backgrounds_text_n}} -\appendtoks - \savecurrentvalue\totalnoftextbackgrounds{\number\c_anch_backgrounds_text_n}% -\to \everybye +% \ifdefined\totalnoftextbackgrounds +% % set in tuc +% \else +% \newcounter\totalnoftextbackgrounds +% \fi +% +% \appendtoks +% \savecurrentvalue\totalnoftextbackgrounds{\number\c_anch_backgrounds_text_n}% +% \to \everybye % actually we can just ask lua to give us the nofpositions (or a least n<>0) -\def\anch_backgrounds_text_initialize - {\ifcase\totalnoftextbackgrounds\else - \enableparpositions - \fi} +% The first position can be used in the middle of a paragraph in which case we're +% too late with initializing par positions. Therefore we check if positions are +% used at all. + +\unexpanded\def\anch_backgrounds_text_initialize + {\ctxcommand{doifelsepositionsused()}\enableparpositions\donothing + \global\let\anch_backgrounds_text_initialize\relax} \appendtoks - % a position can be mid paragraph in which case we're behind - % this will change when we move positions to lua \anch_backgrounds_text_initialize \to \everystarttext @@ -77,7 +70,6 @@ \def\MPself {\MPvar{self}} \def\MPbself {b:\MPvar{self}} \def\MPeself {e:\MPvar{self}} -\def\MPwself {w:\MPvar{self}} \def\MPparanchor {p:\number\MPparcounter} % \carryoverpar is needed for left/right floats @@ -312,73 +304,6 @@ \endgraf % new \textbackgroundparameter\c!after} -\newcount\c_anch_backgrounds_text_par_pages -\newdimen\d_anch_backgrounds_text_par_height -\newdimen\d_anch_backgrounds_text_par_width - -\def\calculatetextpardimensions - {\docalculatetextpardimensions\v_anch_backgrounds_anchor_current_b\v_anch_backgrounds_anchor_current_e\MPparanchor} - -\def\calculatenexttextpardimensions - {\docalculatetextpardimensions\v_anch_backgrounds_anchor_next_b\v_anch_backgrounds_anchor_next_e\relax} - -\def\docalculatetextpardimensions#begin#end#par% - {\c_anch_backgrounds_text_par_pages\numexpr - \MPp#end-\MPp#begin% - \relax - \d_anch_backgrounds_text_par_height\dimexpr - \ifcase\c_anch_backgrounds_text_par_pages - % one page - \MPy#begin-\MPy#end% - \else - % two or more pages - \ifnum\c_anch_backgrounds_text_par_pages>\plustwo - \ifnum\c_anch_backgrounds_text_par_pages<\plusfive - % more pages - \textheight*\numexpr\c_anch_backgrounds_text_par_pages+\minusone - \else - % keep'm small - \plusfive\textheight % weird value - \fi - \else - \MPy#begin-\MPy#end-\MPy\textanchor+\MPy\textanchor+\MPh\textanchor - \fi - \fi - \relax - \d_anch_backgrounds_text_par_width\dimexpr - \ifcase\c_anch_backgrounds_text_par_pages - % one page - \MPx#end-\MPx#begin% - \else - % two or more pages / maybe also hang - \ifx#par\relax - \makeupwidth % \textwidth - \else - \MPw\MPparanchor-\MPleftskip\MPparanchor-\MPrightskip\MPparanchor - \fi - \fi - \relax} - -\def\mintextparheight{4\lineheight} - -\def\dontsplitnexttextbackground % dangerous but useful - {\ifdim\pagetotal>\textheight \else - \ifdim\pagegoal=\maxdimen \else - \calculatenexttextpardimensions - % too tricky - % \scratchdimen=\d_anch_backgrounds_text_par_height - % \advance\scratchdimen\pagetotal\relax - % \ifdim\scratchdimen>\pagegoal - % \page - % \fi - \ifdim\d_anch_backgrounds_text_par_height>\zeropoint - \ifdim\d_anch_backgrounds_text_par_height>\mintextparheight\else - \page % option - \fi - \fi - \fi - \fi} - \def\checktextbackgrounds {\ifproductionrun \enabletextarearegistration @@ -496,29 +421,15 @@ \startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete \MPparcounter\MPn\MPbself\relax - \directsetup{mpos:par:variant:\doifpositionelse\MPwself{w}{b}} - \MPpositiongraphic{mpos:par}{}% -\stopMPpositionmethod - -\startsetups mpos:par:variant:w \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} - initialize_area_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself) ; + initialize_par(\MPposset{\MPvar{self}}) ; \includeMPgraphic{mpos:par:setup} ; \includeMPgraphic{mpos:par:extra} ; \includeMPgraphic{\MPvar{mp}} ; anchor_par(\MPanchor\MPbself) ; \stopMPpositiongraphic -\stopsetups - -\startsetups mpos:par:variant:b - \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} - initialize_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\textanchor,\MPpos\MPparanchor,\MPpardata\MPparanchor) ; - \includeMPgraphic{mpos:par:setup} ; - \includeMPgraphic{mpos:par:extra} ; - \includeMPgraphic{\MPvar{mp}} ; - anchor_par(\MPanchor\MPbself) ; - \stopMPpositiongraphic -\stopsetups + \MPpositiongraphic{mpos:par}{}% +\stopMPpositionmethod %D The next alternative works in columnsets : @@ -554,7 +465,6 @@ \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} \includeMPgraphic{mpos:par:setup} ; \includeMPgraphic{mpos:par:extra} ; - % prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,\MPpos\MPparanchor,\MPpardata\MPparanchor) ; prepare_multi_pars(\MPposset{\MPvar{self}}) ; relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos \includeMPgraphic{\MPvar{mp}} ; diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index 821cec6be..6b7ce13be 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -64,95 +64,104 @@ local function clip(t,ytop,ybot) return lp end +-- todo: mark regions and free paragraphs in collected + local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot) -- we assume that we only hang per page and not cross pages -- which makes sense as hanging is only uses in special cases -- -- we can remove data as soon as a page is done so we could -- remember per page and discard areas after each shipout - local paragraphs = r.paragraphs - local left = { { rx, rh } } - local right = { { rw, rh } } - local extending = false - if paragraphs then - for i=1,#paragraphs do - local p = paragraphs[i] - local ha = p.ha - if ha and ha ~= 0 then - local py = p.y - local ph = p.h - local pd = p.d - local hi = p.hi - local hang = ha * (ph + pd) - local py_ph = py + ph - -- ha < 0 hi < 0 : right top - -- ha < 0 hi > 0 : left top - if ha < 0 then - if hi < 0 then -- right - add(right,rw , py_ph) - add(right,rw + hi, py_ph) - add(right,rw + hi, py_ph + hang) - add(right,rw , py_ph + hang) - else - -- left - add(left,rx, py_ph) - add(left,rx + hi, py_ph) - add(left,rx + hi, py_ph + hang) - add(left,rx, py_ph + hang) - end - end -extending = false - else -- we need to clip to the next par - local ps = p.ps - if ps then + local leftshape, rightshape +-- leftshape = r.leftshape +-- rightshape = r.rightshape +-- if not leftshape then + leftshape = { { rx, rh } } + rightshape = { { rw, rh } } + local paragraphs = r.paragraphs + local extending = false + if paragraphs then + for i=1,#paragraphs do + local p = paragraphs[i] + local ha = p.ha + if ha and ha ~= 0 then local py = p.y local ph = p.h local pd = p.d - local step = ph + pd - local size = #ps * step + local hi = p.hi + local hang = ha * (ph + pd) local py_ph = py + ph - add(left,rx,py_ph) - add(right,rw,py_ph) - for i=1,#ps do - local p = ps[i] - local l = p[1] - local w = p[2] - add(left,rx + l, py_ph) - add(right,rx + l + w, py_ph) - py_ph = py_ph - step - add(left,rx + l, py_ph) - add(right,rx + l + w, py_ph) + -- ha < 0 hi < 0 : right top + -- ha < 0 hi > 0 : left top + if ha < 0 then + if hi < 0 then -- right + add(rightshape,rw , py_ph) + add(rightshape,rw + hi, py_ph) + add(rightshape,rw + hi, py_ph + hang) + add(rightshape,rw , py_ph + hang) + else + -- left + add(leftshape,rx, py_ph) + add(leftshape,rx + hi, py_ph) + add(leftshape,rx + hi, py_ph + hang) + add(leftshape,rx, py_ph + hang) + end end - extending = true --- add(left,rx,py_ph) --- add(right,rw,py_ph) - else - if extending then +extending = false + else -- we need to clip to the next par + local ps = p.ps + if ps then local py = p.y local ph = p.h local pd = p.d + local step = ph + pd + local size = #ps * step local py_ph = py + ph - local py_pd = py - pd - add(left,left[#left][1],py_ph) - add(right,right[#right][1],py_ph) - add(left,rx,py_ph) - add(right,rw,py_ph) + add(leftshape,rx,py_ph) + add(rightshape,rw,py_ph) + for i=1,#ps do + local p = ps[i] + local l = p[1] + local w = p[2] + add(leftshape,rx + l, py_ph) + add(rightshape,rx + l + w, py_ph) + py_ph = py_ph - step + add(leftshape,rx + l, py_ph) + add(rightshape,rx + l + w, py_ph) + end + extending = true +-- add(left,rx,py_ph) +-- add(right,rw,py_ph) + else + if extending then + local py = p.y + local ph = p.h + local pd = p.d + local py_ph = py + ph + local py_pd = py - pd + add(leftshape,leftshape[#leftshape][1],py_ph) + add(rightshape,rightshape[#rightshape][1],py_ph) + add(leftshape,rx,py_ph) + add(rightshape,rw,py_ph) extending = false + end end end end end - end - -- we can have a simple variant when no paragraphs - if extending then - -- not ok - left[#left][2] = rd - right[#right][2] = rw - else - add(left,rx,rd) - add(right,rw,rd) - end - return clip(left,lytop,lybot), clip(right,rytop,rybot) + -- we can have a simple variant when no paragraphs + if extending then + -- not ok + leftshape[#leftshape][2] = rd + rightshape[#rightshape][2] = rw + else + add(leftshape,rx,rd) + add(rightshape,rw,rd) + end +-- r.leftshape = leftshape +-- r.rightshape = rightshape +-- end + return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot) end local function singlepart(b,e,r,left,right) @@ -170,25 +179,41 @@ local function singlepart(b,e,r,left,right) local bd = by - b.d local eh = ey + e.h local ed = ey - e.d - local area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh) - add(area,bx,bh-ry) - for i=1,#rightshapes do - local ri = rightshapes[i] - add(area,ri[1],ri[2]-ry) - end - add(area,ex,eh-ry) - add(area,ex,ed-ry) - for i=#leftshapes,1,-1 do - local li = leftshapes[i] - add(area,li[1],li[2]-ry) - end - add(area,bx,bd-ry) - for i=1,#area do - local a = area[i] - area[i] = pair(a[1],a[2]) + if ex == rx then + -- We probably have a strut at the next line so we force a width + -- although of course it is better to move up. But as we have whitespace + -- (at least visually) injected then it's best to stress the issue. + ex = rw + end + local area + if by == ey then + area = { + pair(bx,bh-ry), + pair(ex,eh-ry), + pair(ex,ed-ry), + pair(bx,bd-ry), + } + else + area = { } + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh) + add(area,bx,bh-ry) + for i=1,#rightshapes do + local ri = rightshapes[i] + add(area,ri[1],ri[2]-ry) + end + add(area,ex,eh-ry) + add(area,ex,ed-ry) + for i=#leftshapes,1,-1 do + local li = leftshapes[i] + add(area,li[1],li[2]-ry) + end + add(area,bx,bd-ry) + for i=1,#area do + local a = area[i] + area[i] = pair(a[1],a[2]) + end end - return { -- no collapsing yet + return { location = "single", region = r, area = area, diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index e882dba41..5f6157268 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -269,6 +269,18 @@ \fi \endgroup} +\def\anch_positions_region_overlay_compose + {\vbox to \overlayheight + {\let\MPanchorid\currentpositionregion + \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used + \the\everyinsertpositionaction + \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid + \setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% + \ht\scratchbox\overlayheight + \dp\scratchbox\zeropoint + \box\scratchbox + \vfill}} + % \let\anch_positions_overlay_nop\gobbleoneargument \unexpanded\def\startpositionoverlay diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index d6fefd3b8..ff7b3ca7b 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -75,6 +75,12 @@ local function sorter(a,b) return a.y > b.y end +local nofusedregions = 0 +local nofmissingregions = 0 +local nofregular = 0 + +-- todo: register subsets and count them indepently + local function initializer() tobesaved = jobpositions.tobesaved collected = jobpositions.collected @@ -90,7 +96,12 @@ local function initializer() else paragraphs[#paragraphs+1] = data end + nofusedregions = nofusedregions + 1 + else + nofmissingregions = nofmissingregions + 1 end + else + nofregular = nofregular + 1 end setmetatable(data,default) end @@ -98,7 +109,7 @@ local function initializer() -- for tag, data in next, collected do -- setmetatable(data,default) -- end - -- sort this data and add metatable + -- sort this data for tag, data in next, collected do local region = data.r if region then @@ -977,5 +988,21 @@ function commands.doifpositionsonthispageelse(list) commands.testcase(onsamepage(list,tostring(tex.count.realpageno))) end +function commands.doifelsepositionsused() + commands.testcase(next(collected)) +end + commands.markcolumnbox = jobpositions.markcolumnbox commands.markregionbox = jobpositions.markregionbox + +-- statistics (at least for the moment, when testing) + +statistics.register("positions", function() + local total = nofregular + nofusedregions + nofmissingregions + if total > 0 then + return format("%s collected, %s regulars, %s regions, %s unresolved regions", + total, nofregular, nofusedregions, nofmissingregions) + else + return nil + end +end) diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 4e2bab1f9..3ce40a6c5 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -1413,14 +1413,14 @@ local function flushtree(result,data,nature,depth) if i == nofdata and sub(content,-1) == "\n" then -- move check -- can be an end of line in par but can also be the last line if trace_spacing then - result[#result+1] = format("%s",di.parnumber,sub(content,1,-2)) + result[#result+1] = format("%s",di.parnumber or 0,sub(content,1,-2)) else result[#result+1] = sub(content,1,-2) end result[#result+1] = " " else if trace_spacing then - result[#result+1] = format("%s",di.parnumber,content) + result[#result+1] = format("%s",di.parnumber or 0,content) else result[#result+1] = content end @@ -1827,6 +1827,16 @@ end -- whatsit_code localpar_code +local function tracedchar(c) + if c == 0x20 then + return "[space]" + elseif c == 0 then + return "[signal]" + else + return utfchar(c) + end +end + local function collectresults(head,list) -- is last used (we also have currentattribute) local p for n in traverse_nodes(head) do @@ -1856,7 +1866,7 @@ local function collectresults(head,list) -- is last used (we also have currentat last = at pushentry(currentnesting) if trace_export then - report_export("%s",spaces[currentdepth],utfchar(c),at) + report_export("%s",spaces[currentdepth],tracedchar(c),at) end -- We need to intercept this here; maybe I will also move this -- to a regular setter at the tex end. @@ -1874,11 +1884,11 @@ local function collectresults(head,list) -- is last used (we also have currentat currentparagraph = ap end if trace_export then - report_export("%s",spaces[currentdepth],utfchar(c),last) + report_export("%s",spaces[currentdepth],tracedchar(c),last) end else if trace_export then - report_export("%s",spaces[currentdepth],utfchar(c),at) + report_export("%s",spaces[currentdepth],tracedchar(c),at) end end local s = has_attribute(n,a_exportstatus) diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index 7811ee5ed..871d08b19 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -72,7 +72,7 @@ \to \everyenableelements \appendtoks - \unexpanded\def\dotagtabulatecell {\taggedctxcommand{settagtabulatecell(\number\tabulatealign)}}% + \unexpanded\def\dotagtabulatecell {\taggedctxcommand{settagtabulatecell(\number\c_tabl_tabulate_align)}}% \unexpanded\def\dotagtabulatesignal{\dontleavehmode\char\zerocount\ignorespaces}% \to \everyenableelements diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 568e161f9..6446020e8 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.02.16 23:57} +\newcontextversion{2012.02.17 18:52} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 3c9cbb3ef..68ad069c4 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.02.16 23:57} +\newcontextversion{2012.02.17 18:52} %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/context-version.pdf b/tex/context/base/context-version.pdf index 31d8cfdf5..4c0eba78e 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index ac35a6918..0024ab229 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 489dfd378..3edaefddf 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.02.16 23:57} +\edef\contextversion{2012.02.17 18:52} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 6c6cf6145..bdbba20a2 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.02.16 23:57} +\edef\contextversion{2012.02.17 18:52} %D For those who want to use this: diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 7b2936dbf..27a64e917 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -848,7 +848,7 @@ actions["analyze glyphs"] = function(data,filename,raw) -- maybe integrate this local properties = data.properties local hasitalics = false local widths = { } - local marks = { } + local marks = { } -- always present (saves checking) for unicode, description in next, descriptions do local glyph = description.glyph local italic = glyph.italic_correction diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 7512abfb6..1e552d35a 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -352,7 +352,7 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- return lignode else -- start is the ligature - local deletemarks = markflag ~= "mark" + -- local deletemarks = markflag ~= "mark" local n = copy_node(start) local current current, start = insert_node_after(start,start,n) @@ -367,16 +367,16 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- current.subtype = ligature_code current.components = start local head = current - if deletemarks then - if trace_marks then - while start do - if marks[start.char] then - logwarning("%s: remove mark %s",pref(kind,lookupname),gref(start.char)) - end - start = start.next - end - end - else + -- if deletemarks then -- KE: was wrong + -- if trace_marks then + -- while start do + -- if marks[start.char] then + -- logwarning("%s: remove mark %s",pref(kind,lookupname),gref(start.char)) + -- end + -- start = start.next + -- end + -- end + -- else local i = 0 while start do if marks[start.char] then @@ -402,7 +402,8 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- end start = start.next end - end + -- end + -- -- we do need components in funny kerning mode but maybe I can better reconstruct then -- as we do have the font components info available; removing components makes the -- previous code much simpler @@ -681,8 +682,9 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) end end end - local i = has_attribute(start,markdone) - if i then index = i end +-- local i = has_attribute(start,markdone) +-- if i then index = i end -- needed +local index = has_attribute(start,markdone) local baseanchors = descriptions[basechar] if baseanchors then baseanchors = baseanchors.anchors @@ -696,7 +698,7 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) if ma then ba = ba[index] if ba then - local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,index) + local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) -- ,index) if trace_marks then logprocess("%s, anchor %s, index %s, bound %s: anchoring mark %s to baselig %s at index %s => (%s,%s)", pref(kind,lookupname),anchor,index,bound,gref(markchar),gref(basechar),index,dx,dy) @@ -727,46 +729,44 @@ end function handlers.gpos_mark2mark(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then ---~ local alreadydone = markonce and has_attribute(start,markmark) ---~ if not alreadydone then - local base = start.prev -- [glyph] [basemark] [start=mark] - if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then -- subtype test can go - local basechar = base.char - local baseanchors = descriptions[basechar] + local base = start.prev -- [glyph] [basemark] [start=mark] +while base and has_attribute(base,markdone) and has_attribute(base,markdone) ~= has_attribute(start,markdone) do + base = base.prev -- KE: prevents mknk fo rmarks on different components of a ligature +end + if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then -- subtype test can go + local basechar = base.char + local baseanchors = descriptions[basechar] + if baseanchors then + baseanchors = baseanchors.anchors if baseanchors then - baseanchors = baseanchors.anchors + baseanchors = baseanchors['basemark'] if baseanchors then - baseanchors = baseanchors['basemark'] - if baseanchors then - local al = anchorlookups[lookupname] - for anchor,ba in next, baseanchors do - if al[anchor] then - local ma = markanchors[anchor] - if ma then - local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) - if trace_marks then - logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%s,%s)", - pref(kind,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) - end - return start,true + local al = anchorlookups[lookupname] + for anchor,ba in next, baseanchors do + if al[anchor] then + local ma = markanchors[anchor] + if ma then + local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) + if trace_marks then + logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%s,%s)", + pref(kind,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy) end + return start,true end end - if trace_bugs then - logwarning("%s: no matching anchors for mark %s and basemark %s",pref(kind,lookupname),gref(markchar),gref(basechar)) - end + end + if trace_bugs then + logwarning("%s: no matching anchors for mark %s and basemark %s",pref(kind,lookupname),gref(markchar),gref(basechar)) end end - else -- if trace_bugs then - -- logwarning("%s: char %s is missing in font",pref(kind,lookupname),gref(basechar)) - onetimemessage(currentfont,basechar,"no base anchors",report_fonts) end - elseif trace_bugs then - logwarning("%s: prev node is no mark",pref(kind,lookupname)) + else -- if trace_bugs then + -- logwarning("%s: char %s is missing in font",pref(kind,lookupname),gref(basechar)) + onetimemessage(currentfont,basechar,"no base anchors",report_fonts) end ---~ elseif trace_marks and trace_details then ---~ logprocess("%s, mark %s is already bound (n=%s), ignoring mark2mark",pref(kind,lookupname),gref(markchar),alreadydone) ---~ end + elseif trace_bugs then + logwarning("%s: prev node is no mark",pref(kind,lookupname)) + end elseif trace_bugs then logwarning("%s: mark %s is no mark",pref(kind,lookupname),gref(markchar)) end @@ -1584,7 +1584,7 @@ local function show_skip(kind,chainname,char,ck,class) end local function normal_handle_contextchain(start,kind,chainname,contexts,sequence,lookuphash) - -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] + -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6] local flags = sequence.flags local done = false local skipmark = flags[1] diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua index 7c91016b6..34f839c6c 100644 --- a/tex/context/base/node-inj.lua +++ b/tex/context/base/node-inj.lua @@ -61,16 +61,22 @@ if context then end -local cursives = { } -local marks = { } -local kerns = { } +-- This injector has been tested by Idris Samawi Hamid (several arabic fonts as well as +-- the rather demanding Husayni font), Khaled Hosny (latin and arabic) and Kaj Eigner +-- (arabic, hebrew and thai) and myself (whatever font I come across). + +local cursives = { } +local marks = { } +local kerns = { } +local markcount = { } -- currently we do gpos/kern in a bit inofficial way but when we -- have the extra fields in glyphnodes to manipulate ht/dp/wd -- explicitly i will provide an alternative; also, we can share -- tables --- for the moment we pass the r2l key ... volt/arabtype tests +-- for the moment we pass the r2l key ... volt/arabtype tests .. idris: this needs +-- checking with husayni (volt and fontforge) function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) local dx, dy = factor*(exit[1]-entry[1]), factor*(exit[2]-entry[2]) @@ -113,14 +119,14 @@ function injections.setkern(current,factor,rlmode,x,tfmchr) end end -function injections.setmark(start,base,factor,rlmode,ba,ma,index) --ba=baseanchor, ma=markanchor - local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) +function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanchor, ma=markanchor + local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- index argument no longer used local bound = has_attribute(base,markbase) if bound then local mb = marks[bound] if mb then if not index then index = #mb + 1 end - mb[index] = { dx, dy } + mb[index] = { dx, dy, rlmode } set_attribute(start,markmark,bound) set_attribute(start,markdone,index) return dx, dy, bound @@ -174,7 +180,7 @@ local function trace(head) end else m = m[1] - report_injections(" markmark: bound=%s, dx=%s, dy=%s",mm,m[1] or "?",m[2] or "?") + report_injections(" markmark: bound=%s, dx=%s, dy=%s",mm,m and m[1] or "?",m and m[2] or "?") end end if cb then @@ -193,6 +199,7 @@ end -- todo: check for attribute -- we can have a fast test on a font being processed, so we can check faster for marks etc +-- but I'll make a context variant anyway function injections.handler(head,where,keep) local has_marks, has_cursives, has_kerns = next(marks), next(cursives), next(kerns) @@ -343,7 +350,7 @@ function injections.handler(head,where,keep) -- that makes sense but we no longer do that so as a -- consequence the sign of p.width was changed (we need -- to keep an eye on it as we don't have that many fonts - -- that enter this branch .. i'm still not sure if this + -- that enter this branch .. I'm still not sure if this -- one is right local k = wx[p] if k then @@ -366,37 +373,51 @@ function injections.handler(head,where,keep) else n.yoffset = n.yoffset + p.yoffset + d[2] end +-- markcount[n_markmark] = (markcount[n_markmark] or 0) + 1 +-- if markcount[n_markmark] == #mrks then +-- break -- KE +-- end end - else - break + -- else + -- break -- KE: there can be sequences in ligatures end end end end if not keep then marks = { } +-- markcount = { } end end -- todo : combine if next(wx) then for n, k in next, wx do - -- only w can be nil, can be sped up when w == nil - local rl, x, w, r2l = k[1], k[2] or 0, k[4] or 0, k[6] - local wx = w - x - if r2l then - if wx ~= 0 then - insert_node_before(head,n,newkern(wx)) - end - if x ~= 0 then - insert_node_after (head,n,newkern(x)) - end - else - if x ~= 0 then - insert_node_before(head,n,newkern(x)) - end - if wx ~= 0 then - insert_node_after(head,n,newkern(wx)) + -- only w can be nil (kernclasses), can be sped up when w == nil + local x, w = k[2] or 0, k[4] + if w then + local rl = k[1] -- r2l = k[6] + local wx = w - x + if rl < 0 then -- KE: don't use r2l here + if wx ~= 0 then + insert_node_before(head,n,newkern(wx)) + end + if x ~= 0 then + insert_node_after (head,n,newkern(x)) + end + else + if x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end end + elseif x ~= 0 then + -- this needs checking for rl < 0 but it is unlikely that a r2l script + -- uses kernclasses between glyphs so we're probably safe (KE has a + -- problematic font where marks interfere with rl < 0 in the previous + -- case) + insert_node_before(head,n,newkern(x)) end end end @@ -435,9 +456,9 @@ function injections.handler(head,where,keep) end if w then -- copied from above - local r2l = kk[6] + -- local r2l = kk[6] local wx = w - x - if r2l then + if rl < 0 then -- KE: don't use r2l here if wx ~= 0 then insert_node_before(head,n,newkern(wx)) end diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index 89eb017a3..f91f8a299 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -39,8 +39,8 @@ \def\internaltextoverlay#1% will become more generic and installable {\startoverlay % i.e. probably an overlay by itself - {\positionoverlay{\v!text#1}}% see later - {\composedlayer {\v!text#1}}% + {\positionregionoverlay\textanchor{\v!text#1}}% see later + {\composedlayer {\v!text#1}}% \stopoverlay} % todo: share info, so that tuo will be smaller diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 56def7add..73a12ab77 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index b36798788..5a5fda95d 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index df7b57d5a..19ef5e91d 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -611,6 +611,13 @@ return { filename = "anch-pos", marktype = "mkiv", status = "okay", + comment = "in transition", + }, + { + filename = "anch-pgr", + marktype = "mkiv", + status = "okay", + comment = "in transition", }, { filename = "scrn-ini", diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv index 61225329c..84d6fb2d3 100644 --- a/tex/context/base/strc-tag.mkiv +++ b/tex/context/base/strc-tag.mkiv @@ -163,16 +163,16 @@ \unexpanded\def\strc_tags_element_start_yes_indeed {\iftrialtypesetting - \expandafter\strc_tags_element_start_yes_indeed_yes - \else \expandafter\strc_tags_element_start_nop_indeed + \else + \expandafter\strc_tags_element_start_yes_indeed_yes \fi} \unexpanded\def\strc_tags_element_stop {\iftrialtypesetting - \expandafter\strc_tags_element_stop_yes - \else \expandafter\strc_tags_element_stop_nop + \else + \expandafter\strc_tags_element_stop_yes \fi} \unexpanded\def\strc_tags_element_start_yes_indeed_yes[#1][#2]% diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index fa1e121f1..99da4b5e8 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -126,7 +126,8 @@ %D %D \typebuffer \getbuffer -\ifdefined\dotagTABLEcell \else \let\dotagTABLEcell\relax \fi +\ifdefined\dotagTABLEcell \else \let\dotagTABLEcell \relax \fi +\ifdefined\dotagTABLEsignal \else \let\dotagTABLEsignal\relax \fi \def\bTBLCELL % why not \doinhibitblank {\inhibitblank @@ -1040,7 +1041,7 @@ \edef\widthTBL{\the\dimexpr\scratchdimen-\tbltblcolumndistance\relax}% % cell \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute \bgroup - % \dotagTABLEsignal + \dotagTABLEsignal % maybe we need to add some packaging in this case \gettbltxt{#1}{#2}% \egroup \ifnum\!!counta=\maximumcol\relax diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index f6e1707e9..86bc3f346 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -508,6 +508,7 @@ \unexpanded\def\tabl_x_stop_cell_construct {\tabl_x_end_of_cell \egroup + \dotagxtablesignal % harmless spot \egroup \ctxcommand{x_table_set_construct()}% \dostoptagged} -- cgit v1.2.3