From 183dc1310ce5237533807ce07b2d3cd2d40962a1 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 21 Feb 2012 02:20:25 +0200 Subject: beta 2012.02.21 00:51 --- tex/context/base/anch-bar.mkiv | 86 +++--- tex/context/base/anch-bck.mkvi | 313 +++++++-------------- tex/context/base/anch-pgr.lua | 74 ++++- tex/context/base/anch-pgr.mkiv | 100 ++++--- tex/context/base/anch-pos.lua | 41 +-- tex/context/base/anch-pos.mkiv | 124 ++++---- tex/context/base/anch-snc.mkiv | 14 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4075 -> 4066 bytes tex/context/base/context-version.png | Bin 105299 -> 105621 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 4 +- tex/context/base/core-ini.mkiv | 16 +- tex/context/base/font-otn.lua | 132 +++++---- tex/context/base/meta-pag.mkiv | 71 ----- tex/context/base/mlib-run.lua | 4 +- tex/context/base/mult-sys.mkiv | 1 - tex/context/base/node-inj.lua | 50 ++-- tex/context/base/pack-mis.mkvi | 6 +- tex/context/base/pack-rul.mkiv | 6 +- tex/context/base/page-bck.mkiv | 144 ++-------- tex/context/base/page-box.mkvi | 23 -- tex/context/base/page-mrk.mkiv | 4 + tex/context/base/page-plg.mkiv | 16 +- tex/context/base/page-txt.mkvi | 4 +- tex/context/base/spac-ali.mkiv | 3 +- tex/context/base/status-files.pdf | Bin 24275 -> 24246 bytes tex/context/base/status-lua.pdf | Bin 172321 -> 172402 bytes tex/context/base/strc-con.mkvi | 4 +- tex/context/base/strc-des.mkvi | 2 +- tex/context/base/strc-enu.mkvi | 2 +- tex/context/base/strc-flt.mkvi | 10 +- tex/context/base/x-set-11.mkiv | 2 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 188 +++++++------ 35 files changed, 607 insertions(+), 843 deletions(-) (limited to 'tex') diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv index bebfaa714..87f21facd 100644 --- a/tex/context/base/anch-bar.mkiv +++ b/tex/context/base/anch-bar.mkiv @@ -53,78 +53,64 @@ %D \stopsidebar %D \stoptyping -\newcount\currentsidebar -\newdimen\sidebardistance +\installcorenamespace{sidebar} -\unexpanded\def\setupsidebars - {\dodoubleargument\dosetupsidebars} +\installcommandhandler \??sidebar {sidebar} \??sidebar -\def\dosetupsidebars[#1][#2]% - {\ifsecondargument - \getparameters[\??br#1][#2]% - \else - \getparameters[\??br][#1]% - \fi} +\newcount\c_anch_sidebars_n +\newdimen\c_anch_sidebars_distance % \setupMPvariables -% [mpos:bar] +% [mpos:sidebar] % [linecolor=red, % linewidth=2pt, % distance=5pt] -\setupsidebars +\setupsidebar [\c!rulethickness=2pt, \c!rulecolor=red, \c!distance=.5\bodyfontsize] -\unexpanded\def\definesidebar - {\dodoubleempty\dodefinesidebar} - -\def\dodefinesidebar[#1][#2]% - {\copyparameters - [\??br#1][\??br] - [\c!rulethickness,\c!rulecolor,\c!distance]% - \getparameters - [\??br#1][#2]} +\let\setupsidebars\setupsidebar \unexpanded\def\startsidebar - {\dosingleempty\dostartsidebar} + {\dosingleempty\anch_sidebars_start} -\def\dostartsidebar[#1]% +\def\anch_sidebars_start[#1]% {\bgroup + \def\currentsidebar{#1}% \dontleavehmode - \checktextbackgrounds - \global\advance\currentsidebar\plusone - \doifelsenothing{#1} - {\advance\sidebardistance\@@brdistance} - {\doifelsevaluenothing{\??br#1\c!distance} - {\advance\sidebardistance\@@brdistance} - {\sidebardistance\getvalue{\??br#1\c!distance}}}% + \global\advance\c_anch_sidebars_n\plusone + \advance\c_anch_sidebars_distance\sidebarparameter\c!distance \startpositionoverlay{text-1}% - \expanded{\setMPpositiongraphicrange - {b:side:\the\currentsidebar}% - {e:side:\the\currentsidebar}% - {mpos:bar}% - {self=side:\the\currentsidebar, - linewidth=\getvalue{\??br#1\c!rulethickness}, - linecolor=\getvalue{\??br#1\c!rulecolor}, - distance=\the\sidebardistance}}% + \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition + {b:sidebar:\the\c_anch_sidebars_n}% + {e:sidebar:\the\c_anch_sidebars_n}% + {mpos:sidebar}% + {self=sidebar:\the\c_anch_sidebars_n, + linewidth=\sidebarparameter\c!rulethickness, + linecolor=\sidebarparameter\c!rulecolor, + distance=\the\c_anch_sidebars_distance}}% \stoppositionoverlay - \bpos{side:\the\currentsidebar}} + \bpos{sidebar:\the\c_anch_sidebars_n}} \unexpanded\def\stopsidebar - {\removelastspace\epos{side:\the\currentsidebar}\carryoverpar\egroup} - -\startMPpositionmethod{mpos:bar} - \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}% - position_anchor_bar ( - \MPp\MPbself, \MPp\MPeself, - \MPy\MPbself, \MPy\MPeself, - \MPh\MPbself, \MPd\MPeself, - \MPvar{distance}, \MPvar{linewidth}, \MPvar{linecolor} + {\removelastspace + \epos{sidebar:\the\c_anch_sidebars_n} + \carryoverpar\egroup} + +%D Let's keep this nice and simple (okay, we could pass the 6 variables in +%D one lua call). + +\startMPpositionmethod{mpos:sidebar} + \startMPpositiongraphic{mpos:sidebar}{linecolor,linewidth,distance}% + if unknown context_apos : input mp-apos.mpiv ; fi ; + anch_sidebars_draw ( + \MPp\MPbself,\MPp\MPeself,\MPy\MPbself,\MPy\MPeself,\MPh\MPbself,\MPd\MPeself, + \MPvar{distance},\MPvar{linewidth},\MPvar{linecolor} ) ; \stopMPpositiongraphic - \MPpositiongraphic{mpos:bar}{}% + \MPpositiongraphic{mpos:sidebar}{}% \stopMPpositionmethod %D We now reimplement the margin rules handler defined in @@ -166,7 +152,7 @@ \else \def\@@kadefaultwidth{#1}% \let\stopmarginrule\dostopmarginrule - \@EA\startsidebar\@EA[\@EA\v!margin\@EA]% + \normalexpanded{\startsidebar[\v!margin]}% why expanded \fi} \def\dostopmarginrule diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index 677d5e2ea..a44b10d3d 100644 --- a/tex/context/base/anch-bck.mkvi +++ b/tex/context/base/anch-bck.mkvi @@ -20,6 +20,10 @@ \unprotect +% we can flush 5 in one call (saved 4 lua calls) .. brrr wself .. will change + +\def\MPposset#1{\ctxcommand{MPposset("#1")}} % will go + % This might be overloaded later on: % \defineoverlay[\v!text-2][\positionoverlay{\v!text-2}] @@ -39,18 +43,6 @@ {\global\advance\c_anch_backgrounds_text_n\plusone \edef\v_anch_backgrounds_text_current{tbg:\number\c_anch_backgrounds_text_n}} -% \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) - % 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. @@ -108,12 +100,12 @@ \setuevalue{\currenttextbackground}{\groupedcommand{\starttextbackground[\currenttextbackground]}{\stoptextbackground}}% \setuevalue{\e!start\currenttextbackground}{\starttextbackground[\currenttextbackground]}% \setuevalue{\e!stop \currenttextbackground}{\stoptextbackground}% - \doif{\textbackgroundparameter\c!state}\v!start\checktextbackgrounds +% \doif{\textbackgroundparameter\c!state}\v!start\checkpositionoverlays \to \everydefinetextbackground -\appendtoks - \doif{\textbackgroundparameter\c!state}\v!start\checktextbackgrounds -\to \everysetuptextbackground +% \appendtoks +% \doif{\textbackgroundparameter\c!state}\v!start\checkpositionoverlays +% \to \everysetuptextbackground \unexpanded\def\starttextbackground {\begingroup @@ -121,7 +113,7 @@ \dodoubleempty\anch_backgrounds_text_start} \def\anch_backgrounds_text_start[#tag][#settings]% - {\checktextbackgrounds + {%\checkpositionoverlays \def\currenttextbackground{#tag}% \anch_backgrounds_text_initialize_next \ifsecondargument @@ -304,15 +296,16 @@ \endgraf % new \textbackgroundparameter\c!after} -\def\checktextbackgrounds +\unexpanded\def\checkpositionoverlays {\ifproductionrun \enabletextarearegistration \enablehiddenbackground + \global\let\checkpositionoverlays\relax \fi} \setuptextbackground - [\c!mp=mpos:par:columnset, % buggy: mpos:par:shape - \c!method=mpos:par:columnset, % + [\c!mp=mpos:region:draw, + \c!method=mpos:region, \c!state=\v!start, \c!location=\v!text, \c!leftoffset=\!!zeropoint, % 1em, @@ -331,59 +324,21 @@ \c!voffset=\!!zeropoint, \c!frame=\v!on, \c!framecolor=blue, + \c!frameoffset=\!!zeropoint, \c!rulethickness=\linewidth] %D The \METAPOST\ connection: -%D Some of these macros are pretty clever but too complicated -%D to be nice. When things are kind of stable I'll clean up -%D this mess. - -\setupMPvariables - [mpos:box] - [linecolor=blue, - linewidth=\linewidth, - fillcolor=lightgray, - filloffset=\!!zeropoint] - -\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} - initialize_box(\MPpos{\MPvar{self}}) ; - def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; - def boxlineoptions = withcolor \MPvar{linecolor} enddef ; - boxlinewidth := \MPvar{linewidth} ; - boxfilloffset := \MPvar{filloffset} ; - draw_box ; - anchor_box(\MPanchor{\MPvar{self}}) ; -\stopMPpositiongraphic - -\setupMPvariables - [mpos:area] - [linecolor=blue, - linewidth=\linewidth, - fillcolor=lightgray, - filloffset=\!!zeropoint] - -\startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth} - initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ; - def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; - def boxlineoptions = withcolor \MPvar{linecolor} enddef ; - boxlinewidth := \MPvar{linewidth} ; - boxfilloffset := \MPvar{filloffset} ; - draw_area ; - anchor_area(\MPanchor{b:\MPvar{self}}) ; -\stopMPpositiongraphic - % gridtype = 1 => baseline % gridtype = 2 => betweenline \setupMPvariables - [mpos:par] - [mp=mpos:par:shape, + [mpos:region] + [mp=mpos:region:unset, gridtype=0, linetype=1, filltype=1, dashtype=0, % 1 = dashed, 2 = dashed with background - %snaptops=true, % not that nice: true/false gridcolor=red, linecolor=blue, fillcolor=lightgray, @@ -392,143 +347,73 @@ gridwidth=\linewidth, gridshift=\!!zeropoint, lineradius=.5\bodyfontsize, + lineoffset=\!!zeropoint, dashtype=1] -\startuseMPgraphic{mpos:par:shape} - \iftracepositions show_par \else draw_par \fi ; -\stopuseMPgraphic - -\startuseMPgraphic{mpos:par:setup} +\startuseMPgraphic{mpos:region:setup} + if unknown context_abck : input mp-abck.mpiv ; fi ; boxgridtype := \MPvar{gridtype} ; boxlinetype := \MPvar{linetype} ; boxfilltype := \MPvar{filltype} ; boxdashtype := \MPvar{dashtype} ; - def boxgridoptions = withcolor \MPvar{gridcolor} enddef ; - def boxlineoptions = withcolor \MPvar{linecolor} enddef ; - def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; boxfilloffset := \MPvar{filloffset} ; boxlinewidth := \MPvar{linewidth} ; boxgridwidth := \MPvar{gridwidth} ; boxgridshift := \MPvar{gridshift} ; boxlineradius := \MPvar{lineradius} ; - %snap_multi_par_tops := \MPvar{snaptops} ; -\stopuseMPgraphic - -\startuseMPgraphic{mpos:par:extra} - % user stuff, like: - % snap_multi_par_tops := false ; + boxlineoffset := \MPvar{lineoffset} ; + % + def boxgridoptions = withcolor \MPvar{gridcolor} enddef ; + def boxlineoptions = withcolor \MPvar{linecolor} enddef ; + def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; \stopuseMPgraphic -\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete - \MPparcounter\MPn\MPbself\relax - \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} - initialize_par(\MPposset{\MPvar{self}}) ; - \includeMPgraphic{mpos:par:setup} ; - \includeMPgraphic{mpos:par:extra} ; - \includeMPgraphic{\MPvar{mp}} ; - anchor_par(\MPanchor\MPbself) ; - \stopMPpositiongraphic - \MPpositiongraphic{mpos:par}{}% -\stopMPpositionmethod - -%D The next alternative works in columnsets : - -\startuseMPgraphic{mpos:par:columnset} - \iftracepositions show_multi_pars \else draw_multi_pars \fi ; +\startuseMPgraphic{mpos:region:extra} + % user stuff \stopuseMPgraphic -\startuseMPgraphic{mpos:par:sideline}{linecolor,lineoffset,linewidth} - begingroup ; save p ; picture p ; - for i=1 upto nofmultipars : - p := image ( fill leftboundary multipars[i] - shifted (-\MPvar{lineoffset},0) - rightenlarged \MPvar{linewidth} withcolor \MPvar{linecolor} ; - ) ; - setbounds p to multipars[i] ; - draw p ; - endfor ; - endgroup ; +\startuseMPgraphic{mpos:region:anchor} + setbounds currentpicture to multibox ; \stopuseMPgraphic -% we can flush 5 in one call (saved 4 lua calls) .. brrr wself .. will change - -\def\MPposset#1{\ctxcommand{MPposset("#1")}} - -\startMPpositionmethod{mpos:par:columnset} - \MPparcounter\MPn\MPbself\relax -\edef\regionanchor{\MPr\MPbself}% -\ifx\regionanchor\empty - \regionpositioningfalse -\else - \regionpositioningtrue -\fi - \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} - \includeMPgraphic{mpos:par:setup} ; - \includeMPgraphic{mpos:par:extra} ; - prepare_multi_pars(\MPposset{\MPvar{self}}) ; - relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos - \includeMPgraphic{\MPvar{mp}} ; - \stopMPpositiongraphic - \MPpositiongraphic{mpos:par}{}% -\regionpositioningfalse -\stopMPpositionmethod +% \startMPpositionmethod{mpos:region} +% \startMPpositiongraphic{mpos:region}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset} +% \includeMPgraphic{mpos:region:setup} ; +% \includeMPgraphic{mpos:region:extra} ; +% \MPgetmultipars{\MPvar{self}}{\MPanchorid} ; +% \includeMPgraphic{\MPvar{mp}} ; +% \includeMPgraphic{mpos:region:anchor} ; +% \stopMPpositiongraphic +% \MPpositiongraphic{mpos:region}{}% +% \stopMPpositionmethod + +\startMPpositiongraphic{mpos:region}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset} + \includeMPgraphic{mpos:region:setup} ; + \includeMPgraphic{mpos:region:extra} ; + \MPgetmultipars{\MPvar{self}}{\MPanchorid} ; + \includeMPgraphic{\MPvar{mp}} ; + \includeMPgraphic{mpos:region:anchor} ; +\stopMPpositiongraphic -% new: - -% \setuptextbackground -% [\c!mp=mpos:par:region, -% \c!method=mpos:par:region] - -\startMPpositionmethod{mpos:par:region} - \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} - \includeMPgraphic{mpos:par:setup} ; - \includeMPgraphic{mpos:par:extra} ; - \ctxcommand{fetchmultipar("\MPvar{self}",\the\realpageno,"\MPanchorid")} - \includeMPgraphic{\MPvar{mp}} ; - setbounds currentpicture to multibox ; - \stopMPpositiongraphic - \MPpositiongraphic{mpos:par}{}% +\startMPpositionmethod{mpos:region} + \MPpositiongraphic{mpos:region}{}% \stopMPpositionmethod -\startuseMPgraphic{mpos:par:region} - \iftracepositions - show_multi_pars - \else - draw_multi_pars - \fi ; +\startuseMPgraphic{mpos:region:draw} + draw_multi_pars \stopuseMPgraphic -\startuseMPgraphic{mpos:par:region:kind} - for i=1 upto nofmultipars : - fill multipars[i] %^ shifted (0,2mm) - withcolor - if multikind[i] = "single" : yellow - elseif multikind[i] = "first" : red - elseif multikind[i] = "middle" : green - elseif multikind[i] = "last" : blue - fi - withtransparency (1,.5) - ; - endfor ; +\startuseMPgraphic{mpos:region:show} + show_multi_pars \stopuseMPgraphic -\setuptextbackground - [\c!mp=mpos:par:region, - \c!method=mpos:par:region] - -%D \starttyping -%D \setupbackground -%D [test] -%D [mp=mpos:par:columnset, -%D method=mpos:par:columnset] -%D \stoptyping - -%D We need to treat floats in a special way. +\startuseMPgraphic{mpos:region:kind} + show_multi_kind +\stopuseMPgraphic -\startMPinitializations - local_multi_par_area:=\iflocalpositioning true\else false\fi; - use_multi_par_region:=\ifregionpositioning true\else false\fi; -\stopMPinitializations +\startuseMPgraphic{mpos:region:sideline} + draw_multi_side +\stopuseMPgraphic %D As an example we define a grid background: @@ -543,54 +428,39 @@ \ifx\basegrid\undefined \else \letvalue\v!grid=\basegrid \fi -%D Whatever - -\setupMPvariables - [mpos:connect] - [linecolor=red, - linewidth=1pt] +%D Some examples (that might become modules anch-imp-whatever): \setupMPvariables [mpos:encircle] [fillcolor=lightgray, filloffset=\!!zeropoint, linecolor=blue, + lineoffset=5pt, linewidth=1pt] -% these might become macros in mp-page - -\startuseMPgraphic{mpos:common:ec} - path pa ; pair ca ; numeric lw ; - lw := \MPvar{linewidth} ; - initialize_box(\MPpos{\MPvar{self}}) ; - pa := pxy ; ca := cxy ; pa := boundingbox pa enlarged 2lw ; - pa := llcorner pa ... lrcorner pa ... urcorner pa ... ulcorner pa ... cycle ; - drawoptions (withpen pencircle scaled lw withcolor \MPvar{linecolor}) ; -\stopuseMPgraphic - -\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth} - \includeMPgraphic{mpos:common:ec} - fill pa withcolor \MPvar{fillcolor} ; draw pa ; - anchor_box(\MPanchor{\MPvar{self}}) ; +\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset} + if unknown context_apos : input mp-apos.mpiv ; fi ; + \MPgetposboxes{\MPvar{self}}{\MPanchorid} + if nofposboxes = 1 : + posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ; + fill posboxes[1] withcolor \MPvar{fillcolor} ; + draw posboxes[1] withpen pencircle scaled \MPvar{linewidth} withcolor \MPvar{linecolor} ; + fi ; \stopMPpositiongraphic -\startMPpositiongraphic{mpos:connect}{linecolor,linewidth} - path pb, pc ; pair cb, cc ; - \includeMPgraphic{mpos:common:ec} - initialize_box(\MPpos{\MPvar{to}}) ; - pb := pxy ; cb := cxy ; pb := boundingbox pb enlarged 2lw ; - pb := llcorner pb...lrcorner pb...urcorner pb...ulcorner pb...cycle ; - pc := ca {up} .. {down} cb ; - cc := (pc intersection_point pa) ; - if intersection_found : - pc := pc cutbefore cc ; - cc := (pc intersection_point pb) ; - if intersection_found : - pc := pc cutafter cc ; - drawarrow pc ; drawarrow reverse pc ; - fi ; - fi ; - anchor_box(\MPanchor{\MPvar{self}}) ; +\setupMPvariables + [mpos:connect] + [linecolor=red, + lineoffset=.25ex, + linewidth=1pt] + +\startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth} + if unknown context_apos : input mp-apos.mpiv ; fi ; + boxlinewidth := \MPvar{linewidth} ; + boxlineoffset := \MPvar{lineoffset} ; + def boxlineoptions = withcolor \MPvar{linecolor} enddef ; + \MPgetposboxes{\MPvar{from},\MPvar{to}}{\MPanchorid} + connect_positions ; \stopMPpositiongraphic \protect \endinput @@ -621,7 +491,7 @@ \definetextbackground [sideline] - [mp=mpos:par:sideline, + [mp=mpos:region:sideline, location=paragraph, framecolor=red, frameoffset=5mm] @@ -631,9 +501,28 @@ after=\stoptextbackground] \starttext + \startunderline \input tufte \stopunderline \blank \startoverstrike \input tufte \stopoverstrike \blank \startexlines \input tufte \stopexlines \blank \startstrikethrough \input tufte \stopstrikethrough \blank \startsideline \input tufte \stopsideline \blank + + \page + + \startpositionoverlay{text-1} + \setMPpositiongraphic{connect-1-b}{mpos:connect}{from=connect-1-b,to=connect-1-e} + \setMPpositiongraphic{connect-1-e}{mpos:connect}{from=connect-1-b,to=connect-1-e} + \stoppositionoverlay + + \startpositionoverlay{text-1} + \setMPpositiongraphic{encircle-1}{mpos:encircle}{self=encircle-1} + \stoppositionoverlay + + test \hpos{connect-1-b}{START} + \dorecurse{10}{\input ward} + \hpos{encircle-1}{\strut HERE} + \dorecurse{10}{\input ward} + \hpos{connect-1-e}{STOP} test + \stoptext diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index 7ab341b63..6dffd9bf8 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -357,7 +357,7 @@ local backgrounds = { } graphics.backgrounds = backgrounds -local function calculate(tag) +local function calculatemultipar(tag) local collected = jobpositions.collected local b = collected[format("b:%s",tag)] local e = collected[format("e:%s",tag)] @@ -467,7 +467,7 @@ end -- end -- end -- --- function graphics.backgrounds.registered(anchor,page) +-- function backgrounds.registered(anchor,page) -- local pa = pending[anchor] -- if pa then -- concat(pa,",") @@ -478,9 +478,9 @@ end local pbg = { } -- will move to pending -function graphics.backgrounds.calculate(n) +function backgrounds.calculatemultipar(n) if not pbg[n] then - pbg[n] = calculate("pbg",n) or { } + pbg[n] = calculatemultipar("pbg",n) or { } end end @@ -491,6 +491,8 @@ local multilocs = { last = 3, } +-- if unknown context_abck : input mp-abck.mpiv ; fi ; + local template_a = [[ path multiregs[], multipars[], multibox ; string multikind[] ; @@ -517,10 +519,10 @@ local template_d = [[ setbounds currentpicture to multibox ; ]] -function graphics.backgrounds.fetch(n,page,anchor) +function backgrounds.fetchmultipar(n,anchor,page) local data = pbg[n] if not data then - data = calculate(n) + data = calculatemultipar(n) pbg[n] = data -- can be replaced by register -- register(data.list,n,anchor) end @@ -559,8 +561,62 @@ function graphics.backgrounds.fetch(n,page,anchor) return format(template_a,0,"origin") end -function commands.fetchmultipar(n,page,anchor) - context(graphics.backgrounds.fetch(n,page,anchor)) +backgrounds.point = point +backgrounds.pair = pair +backgrounds.path = path + +function commands.fetchmultipar(n,anchor,page) + context(backgrounds.fetchmultipar(n,anchor,page)) +end + +local template_a = [[ +path posboxes[], posregions[] ; +numeric pospages[] ; +numeric nofposboxes ; +nofposboxes := %s ; +%s ; +]] + +local template_b = [[ +pospages[%s] := %s ; +posboxes[%s] := %s--%s--%s--%s--cycle ; +posregions[%s] := %s--%s--%s--%s--cycle ; +]] + +function commands.fetchposboxes(tags,anchor,page) -- no caching (yet) / todo: anchor, page + local collected = jobpositions.collected + if type(tags) == "string" then + tags = utilities.parsers.settings_to_array(tags) + end + local list, nofboxes = { }, 0 + for i=1,#tags do + local tag= tags[i] + local c = collected[tag] + if c then + local r = c.r + if r then + r = collected[r] + if r then + local rx, ry, rw, rh, rd = r.x, r.y, r.w, r.h, r.d + local cx = c.x - rx + local cy = c.y - ry + local cw = cx + c.w + local ch = cy + c.h + local cd = cy - c.d + nofboxes = nofboxes + 1 + list[nofboxes] = format(template_b, + nofboxes,c.p, + nofboxes,pair(cx,ch),pair(cw,ch),pair(cw,cd),pair(cx,cd), + nofboxes,pair(0,rh),pair(rw,rh),pair(rw,rd),pair(0,rd) + ) + end + end + else + print("\n missing",tag) + end + end + -- print(format(template_a,nofboxes,concat(list))) + context(template_a,nofboxes,concat(list)) end local doifelse = commands.doifelse @@ -568,7 +624,7 @@ local doifelse = commands.doifelse function commands.doifelsemultipar(n,page) local data = pbg[n] if not data then - data = calculate(n) + data = calculatemultipar(n) pbg[n] = data end if page then diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 5f6157268..8caa09c69 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -62,12 +62,12 @@ \anch_positions_action_indeed_nop} \def\anch_positions_action_indeed_nop - {\traceposstring\clap\cyan{<\currentpositionaction>}} + {\anch_positions_trace_action_nop} \def\anch_positions_action_indeed_yes % we need a way to figure out if we have actions {\begingroup \setbox\scratchbox\hbox - {\traceposstring\clap\red{<\currentpositionaction>}% + {\anch_positions_trace_action_yes \the\everyinsertpositionaction \the\everypositionaction \csname\??positionaction\currentpositionaction\endcsname @@ -75,6 +75,20 @@ \smashedbox\scratchbox % smashing is really needed else we get problems with too big overlays \endgroup} +\unexpanded\def\anch_positions_trace_action_nop_indeed + {\anch_positions_trace\clap\darkred{<\currentpositionaction>}} + +\unexpanded\def\anch_positions_trace_action_yes_indeed + {\anch_positions_trace\clap\darkgreen{<\currentpositionaction>}} + +\let\anch_positions_trace_action_nop\relax +\let\anch_positions_trace_action_yes\relax + +\appendtoks + \let\anch_positions_trace_action_nop\anch_positions_trace_action_nop_indeed + \let\anch_positions_trace_action_yes\anch_positions_trace_action_yes_indeed +\to \t_anch_positions_tracers + %D Here the complication has to do with collecting actions %D for later execution. This collection is especially handy %D when we want to move actions to a specific layer. Such @@ -84,13 +98,13 @@ \def\anch_positions_cleanup_action % not in trialtypesetting {\ifcsname\??positioncleanup\currentpositionaction\endcsname \the\everycleanpositionaction - \iflocalpositioning - % erase - \expandafter\let\csname\??positioncleanup\currentpositionaction\endcsname\empty - \else + % \iflocalpositioning + % % erase + % \expandafter\let\csname\??positioncleanup\currentpositionaction\endcsname\empty + % \else % globalize expansion cleans up \setxvalue{\??positioncleanup\currentpositionaction}{\csname\??positioncleanup\currentpositionaction\endcsname}% - \fi + % \fi \fi} \def\handlepositionaction#1\with#2\on#3% ugly @@ -204,7 +218,7 @@ %D \typebuffer[graphic] \def\MPanchoridentifier{mpa} % {mp-anchor} -\def\MPoverlayposprefix{MO::} % not used +%def\MPoverlayposprefix{MO::} % not used %D The rest of the definitions concerning such overlays may %D look complicated, @@ -214,10 +228,14 @@ %D Position actions are automatically executed when a position %D is set. -\newcount\localpositionnumber % incremented elsewhere +% \newcount\localpositionnumber % incremented elsewhere +% \newif\iflocalpositioning +% +% \def\textbackgroundoverlay#1{\iflocalpositioning\v!local\else\v!text\fi#1} +% \def\MPanchornumber {\the\iflocalpositioning\localpositionnumber\else\realpageno\fi} -\def\textbackgroundoverlay#1{\iflocalpositioning\v!local\else\v!text\fi#1} -\def\MPanchornumber {\the\iflocalpositioning\localpositionnumber\else\realpageno\fi} +\def\textbackgroundoverlay#1{\v!text#1} +\def\MPanchornumber {\the\realpageno} \def\positionoverlay % the test prevents too many redundant positions {\ifpositioning % in (not used) text* position layers @@ -247,7 +265,7 @@ \setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% \ht\scratchbox\overlayheight \dp\scratchbox\zeropoint -\ctxcommand{markregionbox(\number\scratchbox,"\MPanchorid")}% needs an hbox + \ctxcommand{markregionbox(\number\scratchbox,"\MPanchorid")}% needs an hbox \box\scratchbox \vfill}} @@ -294,7 +312,8 @@ {} \def\anch_positions_overlay_start_yes#1% - {\def\currentpositionoverlay{#1}} + {\checkpositionoverlays + \edef\currentpositionoverlay{#1}} \unexpanded\def\stoppositionoverlay {\let\currentpositionoverlay\empty} @@ -302,17 +321,17 @@ % \def\resetpositionoverlay#1% % {\dosetpositionaction{#1::\MPanchoridentifier::}{}} -\def\handlepositionboxes#1#2#3% - {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}} - -\def\doinsertpositionboxes#1#2#3% pos tag setups - {\ifnum\MPp{#1}=\realpageno\relax % can be sped up - \executeifdefined{\MPoverlayposprefix#1}\gobblethreearguments{#1}{#2}{#3}% not used - \fi} - -\appendtoks - \let\dohandlepositionboxes\doinsertpositionboxes % was handle ? -\to \everyinsertpositionaction +% \def\handlepositionboxes#1#2#3% +% {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}} +% +% \def\doinsertpositionboxes#1#2#3% pos tag setups +% {\ifnum\MPp{#1}=\realpageno\relax % can be sped up +% \executeifdefined{\MPoverlayposprefix#1}\gobblethreearguments{#1}{#2}{#3}% not used +% \fi} +% +% \appendtoks +% \let\dohandlepositionboxes\doinsertpositionboxes % was handle ? +% \to \everyinsertpositionaction \def\docleanpositionboxes#1#2#3% pos tag setups {\ifnum\MPp{#1}<\realpageno \else @@ -469,34 +488,9 @@ \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange \to \everycleanpositionaction -%D \macros -%D {stackposdown, stackposup, stackposleft,stackposright} -%D -%D This is sort of obsolete as we have now stacking in the -%D margin in a different way. - -\def\stackposdistance{.5em} - -\newcount\currentautopos -\newcount\previousautopos - -\def\POSstackprefix{stack:} - -\unexpanded\def\dostackposbox#1#2% - {\dowithnextbox - {#2% - \bgroup - \previousautopos\currentautopos - \global\advance\currentautopos\plusone - \edef\currentposition {\POSstackprefix\number\currentautopos}% - \edef\previousposition{\POSstackprefix\number\previousautopos}% - \hpos\currentposition{\doifoverlappingelse\currentposition\previousposition{#1}{\flushnextbox}% - \egroup}}% - \hbox} - -\unexpanded\def\stackposup {\dostackposbox{\raise\lineheight\flushnextbox}} -\unexpanded\def\stackposdown {\dostackposbox{\lower\lineheight\flushnextbox}} -\unexpanded\def\stackposleft {\dostackposbox{\copy\nextbox\hskip\nextboxwd\hskip\stackposdistance}} -\unexpanded\def\stackposright{\dostackposbox{\hskip\stackposdistance\hskip\nextboxwd\flushnextbox}} +% Helpers: + +\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}} +\def\MPgetmultipars#1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}} \protect \endinput diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index bc062161d..19c35a5a6 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -27,21 +27,21 @@ local allocate, mark = utilities.storage.allocate, utilities.storage.mark local texsp, texcount, texbox, texdimen, texsetcount = tex.sp, tex.count, tex.box, tex.dimen, tex.setcount ----- texsp = string.todimen -- because we cache this is much faster but no rounding -local setmetatableindex = table.setmetatableindex - -local variables = interfaces.variables +local pdf = pdf -- h and v are variables -local v_text = variables.text -local v_column = variables.column +local setmetatableindex = table.setmetatableindex +local new_latelua = nodes.pool.latelua +local find_tail = node.slide -local new_latelua = nodes.pool.latelua -local find_tail = node.slide +local variables = interfaces.variables +local v_text = variables.text +local v_column = variables.column -local pt = number.dimenfactors.pt -local pts = number.pts +local pt = number.dimenfactors.pt +local pts = number.pts -local collected = allocate() -local tobesaved = allocate() +local collected = allocate() +local tobesaved = allocate() local jobpositions = { collected = collected, @@ -50,7 +50,7 @@ local jobpositions = { job.positions = jobpositions -_plib_ = jobpositions +_plib_ = jobpositions -- might go local default = { -- not r and paragraphs etc __index = { @@ -350,7 +350,7 @@ local nofparagraphs = 0 function commands.parpos() -- todo: relate to localpar (so this is an intermediate variant) nofparagraphs = nofparagraphs + 1 - texsetcount("global","parposcounter",nofparagraphs) + texsetcount("global","c_anch_positions_paragraph",nofparagraphs) local strutbox = texbox.strutbox local t = { p = true, @@ -705,7 +705,7 @@ function commands.MPx(id) local jpi = collected[id] if jpi then local x = jpi.x - if x and p ~= true then + if x and x ~= true and x ~= 0 then context("%.5fpt",x*pt) return end @@ -717,7 +717,7 @@ function commands.MPy(id) local jpi = collected[id] if jpi then local y = jpi.y - if y and p ~= true then + if y and y ~= true and y ~= 0 then context("%.5fpt",y*pt) return end @@ -729,7 +729,7 @@ function commands.MPw(id) local jpi = collected[id] if jpi then local w = jpi.w - if w then + if w and w ~= 0 then context("%.5fpt",w*pt) return end @@ -741,7 +741,7 @@ function commands.MPh(id) local jpi = collected[id] if jpi then local h = jpi.h - if h then + if h and h ~= 0 then context("%.5fpt",h*pt) return end @@ -750,10 +750,11 @@ function commands.MPh(id) end function commands.MPd(id) + local jpi = collected[id] if jpi then local d = jpi.d - if d then - context("%spt",d*pt) + if d and d ~= 0 then + context("%.5fpt",d*pt) return end end @@ -969,7 +970,7 @@ function commands.doifpositionelse(name) commands.doifelse(collected[name]) end -function commands.doifpositionelse(name) +function commands.doifposition(name) commands.doif(collected[name]) end diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 3341d40c4..a583d8165 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -42,36 +42,14 @@ \def\dosetpositionbox #1#2{\ctxcommand{poswhd("#1",\number\wd#2,\number\ht#2,\number\dp#2)}} \def\dosetpositionstrut #1{\ctxcommand{posstrut("#1")}} -\newbox\positionbox -\newif \ifpositioning +\newbox\b_anch_position +\newif \ifpositioning % sort of public %D Sometimes we want to trick the position handler a bit: -\def\replacepospxywhd#1#2#3#4#5#6#7% +\def\replacepospxywhd#1#2#3#4#5#6#7% when used we can better make a helper {\ctxcommand{replacepospxywhd('#1',\number#2,\number\dimexpr#3,\number\dimexpr#4,\number\dimexpr#5,\number\dimexpr#6,\number\dimexpr#7)}} -%D The next switch can be used to communicate a special situation. Positioning and -%D associated actions can be executed any time. However, in for instance backgrounds -%D they can be collected in a layer, for instance the text layer (especially the -%D hidden text layer). In the case of floats, we run into problems, since the page -%D information is not applicable when the content floats indeed. In such situations -%D one can treat positions and graphics local. - -\newif\iflocalpositioning % todo: conditional -\newif\ifregionpositioning % todo: conditional - -%D Watch out: sometimes a pagebreak occurs inside a float placement, so there we need -%D to disable local mode. - -\appendtoks - \localpositioningtrue -\to \everyinsidefloat - -\appendtoks - \regionpositioningfalse - \localpositioningfalse -\to \everybeforepagebody - %D \macros %D {MPp, MPx, MPy, MPw, MPh, MPd, MPxy, MPll, MPlr, MPur, MPul, MPpos, MPanchor} %D @@ -156,7 +134,7 @@ {\anch_positions_initialize \edef\currentposition{#1}% \dosetposition\currentposition - \traceposstring\llap\green{\currentposition>}% + \anch_positions_trace_left \dopositionaction\currentposition} \unexpanded\def\setpositiondata @@ -171,7 +149,7 @@ \hbox {\edef\currentposition{#1}% \dosetpositionwhd\currentposition{#2}{#3}{#4}% already \the\dimexpr - \traceposstring\llap\green{\currentposition>}% + \anch_positions_trace_left \dopositionaction\currentposition \hss}} @@ -193,10 +171,10 @@ \hbox to \wd\nextbox {\edef\currentposition{#1}% \dosetpositionbox\currentposition\nextbox - \traceposstring\llap\green{\currentposition>}% - \setbox\positionbox\box\nextbox + \anch_positions_trace_left + \setbox\b_anch_position\box\nextbox \dopositionaction\currentposition - \box\positionbox + \box\b_anch_position \hss}} \unexpanded\def\setpositionstrut @@ -214,7 +192,7 @@ \hbox to \zeropoint {\edef\currentposition{#1}% \dosetpositionstrut\currentposition - \traceposstring\llap\green{\currentposition>}% + \anch_positions_trace_left \dopositionaction\currentposition \strut \hss}} @@ -231,7 +209,7 @@ \hbox % just package {\edef\currentposition{#1}% \dosetpositionplus\currentposition{#2}{#3}{#4}{#5}% already \the\dimexpr - \traceposstring\rlap\magenta{<\currentposition}% + \anch_positions_trace_right \dopositionaction\currentposition \hss}} @@ -253,10 +231,10 @@ \hbox to \nextboxwd {\edef\currentposition{#1}% \dosetpositionplus\currentposition{\wd\nextbox}{\ht\nextbox}{\dp\nextbox}{#2}% - \traceposstring\rlap\magenta{<\currentposition}% - \setbox\positionbox\flushnextbox + \anch_positions_trace_right + \setbox\b_anch_position\flushnextbox \dopositionaction\currentposition - \box\positionbox + \box\b_anch_position \hss}} \let\currentposition\s!unknown @@ -348,17 +326,17 @@ %D can keep track of them. This mechanism is activated automatically based on %D information collected in the previous pass. -\newcount\parposcounter -\newif \ifpositioningpar -\newif \iftracepositions +\newtoks \t_anch_positions_tracers +\newcount\c_anch_positions_paragraph + +\unexpanded\def\tracepositions + {\the\t_anch_positions_tracers} \unexpanded\def\enableparpositions % global {\global\let\registerparoptions\doregisterparoptions - \global\positioningtrue - \global\positioningpartrue} + \global\positioningtrue} -\unexpanded\def\disableparpositions % local - {\positioningparfalse} +\let\disableparpositions\relax \let\registerparoptions\relax @@ -369,31 +347,47 @@ \fi \fi \fi \fi} -\def\anch_positions_register_par_options - {\dontleavehmode\ctxcommand{parpos()}% - \iftracepositions\registerparsymbol\fi} +\def\anch_positions_register_par_options_normal + {\dontleavehmode\ctxcommand{parpos()}} + +\def\anch_positions_register_par_options_traced + {\anch_positions_register_par_options_normal + \smashedhbox to \zeropoint + {\hss + \startcolor[blue]% + \llap{\infofont\number\c_anch_positions_paragraph}% + \vrule + \!!width 4\onepoint + \!!height2\onepoint + \!!depth 2\onepoint + \stopcolor + \hss}} + +\let\anch_positions_register_par_options\anch_positions_register_par_options_normal -\unexpanded\def\traceposstring#1#2#3% - {\iftracepositions - \smashedhbox - {#1{\infofont#2#3}% - \kern-\onepoint - \vrule\!!width2\onepoint\!!height\halfapoint\!!depth\halfapoint}% - \fi} +\appendtoks + \let\anch_positions_register_par_options\anch_positions_register_par_options_traced +\to \t_anch_positions_tracers -\unexpanded\def\registerparsymbol - {\iftracepositions - \smashedhbox to \zeropoint - {\hss - \startcolor[blue]% - \llap{\infofont\number\parposcounter}% - \vrule - \!!width 4\onepoint - \!!height2\onepoint - \!!depth 2\onepoint - \stopcolor - \hss}% - \fi} +\unexpanded\def\anch_positions_trace#1#2#3% + {\smashedhbox + {#1{\infofont#2#3}% + \kern-\onepoint + \vrule\!!width2\onepoint\!!height\halfapoint\!!depth\halfapoint}} + +\unexpanded\def\anch_positions_trace_left_indeed + {\anch_positions_trace\llap\darkmagenta{\currentposition>}} + +\unexpanded\def\anch_positions_trace_right_indeed + {\anch_positions_trace\rlap\darkcyan{<\currentposition}} + +\let\anch_positions_trace_left \relax +\let\anch_positions_trace_right\relax + +\appendtoks + \let\anch_positions_trace_left \anch_positions_trace_left_indeed + \let\anch_positions_trace_right \anch_positions_trace_right_indeed +\to \t_anch_positions_tracers % \appendtoks \registerparoptions \to \everypar diff --git a/tex/context/base/anch-snc.mkiv b/tex/context/base/anch-snc.mkiv index c7448f3a1..5f2c17ac9 100644 --- a/tex/context/base/anch-snc.mkiv +++ b/tex/context/base/anch-snc.mkiv @@ -56,10 +56,7 @@ \pluscounter{\s!num:\s!syncpos:#1}% \setsyncpositions{#1}% % option: geen w/h, alleen p 0 0 0 data - \setpositionplus - {\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}% - {#2}% - \hbox{\strut\traceposstring\llap\green{#3/\countervalue{\s!num:\s!syncpos:#1}/#1/#2>>}}% + \setpositionplus{\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}{#2}\hbox{\strut}% \else \strut \fi} @@ -167,6 +164,7 @@ \definesyncpositions[1] \startuseMPgraphic{sync} + if unknown context_abck : input mp-abck.mpiv ; fi ; StartPage ; \getsyncpositions{1} ; SyncThreshold := 2LineHeight ; @@ -190,13 +188,13 @@ \setupbackgrounds[page][background=tempoverlay] -\dorecurse {100} { +\dorecurse {10} { \startchapter[title={Test #1}] \syncposition[1][1] \dorecurse{10}{\input ward \endgraf} - \syncposition[1][2] \dorecurse{4}{\input ward \endgraf} - \syncposition[1][3] \dorecurse{7}{\input ward \endgraf} - \syncposition[1][4] \dorecurse{3}{\input ward \endgraf} + \syncposition[1][2] \dorecurse {4}{\input ward \endgraf} + \syncposition[1][3] \dorecurse {7}{\input ward \endgraf} + \syncposition[1][4] \dorecurse {3}{\input ward \endgraf} \stopchapter } diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index c045890b2..7836fb9ec 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.18 10:50} +\newcontextversion{2012.02.21 00:51} %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 dc19402c2..882aad72b 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.18 10:50} +\newcontextversion{2012.02.21 00:51} %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 b5e4d1d07..4f4878b29 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 7db14f01e..fcb7b8d83 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 9bd21ba7a..ecdb224c5 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.18 10:50} +\edef\contextversion{2012.02.21 00:51} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 5bfa6e61e..803d6e7be 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.18 10:50} +\edef\contextversion{2012.02.21 00:51} %D For those who want to use this: @@ -391,7 +391,7 @@ \loadmkvifile{anch-bck} \loadmarkfile{anch-tab} % overloads tabl-tbl \loadmarkfile{anch-bar} -\loadmarkfile{anch-snc} +%loadmarkfile{anch-snc} % when needed this one will be redone \loadmarkfile{math-ini} \loadmarkfile{math-pln} diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv index 75a0ed5d9..de37bf08f 100644 --- a/tex/context/base/core-ini.mkiv +++ b/tex/context/base/core-ini.mkiv @@ -34,7 +34,7 @@ \OTRSETshowstatus \flushpostponedbookmark \registerparoptions - \flushsyncpositions + %\flushsyncpositions \flushpostponednodedata \typo_delimited_repeat \insertparagraphintro @@ -56,13 +56,13 @@ \adjustsidefloatdisplaylines \to \everydisplay -\appendtoks - \flushsyncpositions -\to \everyheadstart +% \appendtoks +% \flushsyncpositions +% \to \everyheadstart -\appendtoks - \flushsyncresets -\to \everyendoftextbody +% \appendtoks +% \flushsyncresets +% \to \everyendoftextbody \appendtoks \ignorespaces @@ -71,7 +71,7 @@ \appendtoks \removeunwantedspaces %strut % option ? - \flushsyncresets + % \flushsyncresets %setlastlinewidth % gone, will be done in lua \endgraf \to \everyendofpar diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index edef853de..2fd910eb9 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -27,6 +27,7 @@ if not modules then modules = { } end modules ['font-otn'] = { -- default features (per language, script) -- handle positions (we need example fonts) -- handle gpos_single (we might want an extra width field in glyph nodes because adding kerns might interfere) +-- mark (to mark) code is still not what it should be (too messy but we need some more extreem husayni tests) --[[ldx--

This module is a bit more split up that I'd like but since we also want to test @@ -192,14 +193,21 @@ local ligature_code = glyphcodes.ligature local privateattribute = attributes.private +-- Something is messed up: we have two mark / ligature indices, one at the injection +-- end and one here ... this is bases in KE's patches but there is something fishy +-- there as I'm pretty sure that for husayni we need some connection (as it's much +-- more complex than an average font) but I need proper examples of all cases, not +-- of only some. + local state = privateattribute('state') local markbase = privateattribute('markbase') local markmark = privateattribute('markmark') -local markdone = privateattribute('markdone') +local markdone = privateattribute('markdone') -- assigned at the injection end local cursbase = privateattribute('cursbase') local curscurs = privateattribute('curscurs') local cursdone = privateattribute('cursdone') local kernpair = privateattribute('kernpair') +local ligacomp = privateattribute('ligacomp') -- assigned here (ideally it should be combined) local injections = nodes.injections local setmark = injections.setmark @@ -352,7 +360,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,48 +375,38 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- current.subtype = ligature_code current.components = start local head = current - -- 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 - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - head, current = insert_node_after(head,current,copy_node(start)) - else - i = i + 1 + -- this is messy ... we should get rid of the components eventually + local i = 0 -- is index of base + while start do + if not marks[start.char] then + i = i + 1 + elseif not deletemarks then -- quite fishy + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) end - start = start.next + head, current = insert_node_after(head,current,copy_node(start)) end - start = current.next - while start and start.id == glyph_code do - if marks[start.char] then - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - else - break + start = start.next + end + start = current.next + while start and start.id == glyph_code do + if marks[start.char] then + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) end - start = start.next + else + break 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 - -- - -- flush_node_list(head.components) + start = start.next + 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 + -- + -- flush_node_list(head.components) return head end end @@ -660,18 +658,14 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -682,9 +676,7 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) end end end --- local i = has_attribute(start,markdone) --- if i then index = i end -- needed -local index = has_attribute(start,markdone) + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar] if baseanchors then baseanchors = baseanchors.anchors @@ -698,7 +690,7 @@ local index = has_attribute(start,markdone) 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) @@ -730,11 +722,20 @@ function handlers.gpos_mark2mark(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [basemark] [start=mark] - -- new - 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 + -- while base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end 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] @@ -1294,18 +1295,14 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end if markanchors then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -1317,8 +1314,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end end -- todo: like marks a ligatures hash - local i = has_attribute(start,markdone) - if i then index = i end + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar].anchors if baseanchors then local baseanchors = baseanchors['baselig'] @@ -1330,7 +1326,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, 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, bound %s: anchoring mark %s to baselig %s at index %s => (%s,%s)", cref(kind,chainname,chainlookupname,lookupname),anchor,a or bound,gref(markchar),gref(basechar),index,dx,dy) @@ -1371,6 +1367,20 @@ function chainprocs.gpos_mark2mark(start,stop,kind,chainname,currentcontext,look end if markanchors then local base = start.prev -- [glyph] [basemark] [start=mark] + -- while (base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp)) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end + 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].anchors diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index f117b6b3d..6cea270e3 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -114,75 +114,4 @@ \calculatereducedvsizes % this is really needed \to \everyMPgraphic -%D The next feature provides information about for instance -%D column positions. This is an experimental feature, -%D introduced when we needed backgrounds in columns (fill||in -%D questions as implemented in a private module). -%D -%D See \type {mp-page.mp} for the definition of the macros: -%D -%D \starttabulate[|tl|l|p|] -%D \NC ResetTextAreas \NC no arguments \NC -%D reset areas on page \NC \NR -%D \NC RegisterTextArea \NC x, y, w, h \NC -%D adds area to the list \NC \NR -%D \NC TextAreaX,Y,W,H,XY,WH \NC x and/or y \NC -%D reports offsets and dimensions \NC \NR -%D \stoptabulate -%D -%D The \type {TextArea*} macros can be used to determine -%D overlap. - -\newcount\currentMPtextareadata - -\newtoks\MPsavedtextareadata -\newtoks\MPtextareadata -\newtoks\MPlocaltextareadata -\newtoks\MPregionareadata - -% optimaliseren voor herhaling - -\newif\iftracetextareas - -\unexpanded\def\globalregisterMPtextarea{\normalexpanded{\global\MPtextareadata{\the\MPtextareadata - RegisterTextArea(\MPxywhd\currentMPtextarea);}}} - -\unexpanded\def\localregisterMPtextarea{\normalexpanded{\global\MPlocaltextareadata{% - RegisterLocalTextArea(\MPxywhd\currentMPtextarea);}}} - -\unexpanded\def\registerMPtextareaindeed#1#2% - {\ifpositioning - \begingroup - \global\advance\currentMPtextareadata\plusone - \edef\currentMPtextarea{gbd:\the\currentMPtextareadata}% - \hpos\currentMPtextarea{\iftracetextareas\boxrulewidth1.5pt\ruledhbox\fi{#2}}% - #1% - \endgroup - \else - \hbox{#2}% - \fi} - -\unexpanded\def\registerMPtextarea {\registerMPtextareaindeed\globalregisterMPtextarea} -\unexpanded\def\registerMPlocaltextarea{\registerMPtextareaindeed\localregisterMPtextarea } - -\unexpanded\def\resetMPlocaltextarea - {\global\MPlocaltextareadata\emptytoks} - -\startMPinitializations - ResetTextAreas; - \the\MPsavedtextareadata; - SaveTextAreas; - ResetTextAreas; - \the\MPtextareadata; - \the\MPlocaltextareadata; - RegisterPlainTextArea(\MPxywhd\textanchor); - RegisterRegionTextArea(\MPxywhd\regionanchor); -\stopMPinitializations - -\appendtoks - \global\MPsavedtextareadata\MPtextareadata - \global\MPtextareadata \emptytoks - \global\MPlocaltextareadata\emptytoks -\to \everyshipout - \protect \endinput diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index f8c0456a1..dd172f884 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -58,7 +58,7 @@ function metapost.resetlastlog() metapost.lastlog = "" end -local function finder(name, mode, ftype) -- we can use the finder to intercept btex/etex +local function finder(name, mode, ftype) if mode == "w" then return name elseif file.is_qualified_path(name) then @@ -68,7 +68,7 @@ local function finder(name, mode, ftype) -- we can use the finder to intercept b end end -local function finder(name, mode, ftype) -- we use the finder to intercept btex/etex +local function finder(name, mode, ftype) if mode ~= "w" then name = file.is_qualified_path(name) and name or resolvers.findfile(name,ftype) if not (find(name,"/metapost/context/base/") or find(name,"/metapost/context/") or find(name,"/metapost/base/")) then diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index beb069a23..112a6c3d5 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -457,7 +457,6 @@ \definesystemvariable {bg} % BleedinG \definesystemvariable {bm} % BookMark \definesystemvariable {bp} % BreakPoint -\definesystemvariable {br} % sideBaR \definesystemvariable {bx} % BackendExport \definesystemvariable {cb} % CollectBox \definesystemvariable {cm} % CheMical diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua index 34f839c6c..246aaade2 100644 --- a/tex/context/base/node-inj.lua +++ b/tex/context/base/node-inj.lua @@ -45,6 +45,7 @@ local cursbase = attributes.private('cursbase') local curscurs = attributes.private('curscurs') local cursdone = attributes.private('cursdone') local kernpair = attributes.private('kernpair') +local ligacomp = attributes.private('ligacomp') local fontkern = attributes.private('fontkern') if context then @@ -63,20 +64,19 @@ end -- 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). +-- (arabic, hebrew and thai) and myself (whatever font I come across). I'm pretty sure +-- that this code is not 100% okay but examples are needed to figure things out. -local cursives = { } -local marks = { } -local kerns = { } -local markcount = { } +local cursives = { } +local marks = { } +local kerns = { } --- 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 +-- 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 .. idris: this needs --- checking with husayni (volt and fontforge) +-- 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]) @@ -120,12 +120,14 @@ function injections.setkern(current,factor,rlmode,x,tfmchr) 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]) -- index argument no longer used - local bound = has_attribute(base,markbase) + local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- the index argument is no longer used but when this + local bound = has_attribute(base,markbase) -- fails again we should pass it +local index = 1 if bound then local mb = marks[bound] if mb then - if not index then index = #mb + 1 end + -- if not index then index = #mb + 1 end +index = #mb + 1 mb[index] = { dx, dy, rlmode } set_attribute(start,markmark,bound) set_attribute(start,markdone,index) @@ -134,6 +136,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanch report_injections("possible problem, U+%05X is base mark without data (id: %s)",base.char,bound) end end +-- index = index or 1 index = index or 1 bound = #marks + 1 set_attribute(base,markbase,bound) @@ -198,8 +201,8 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -- 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 +-- 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) @@ -337,6 +340,7 @@ function injections.handler(head,where,keep) local p_markbase = has_attribute(p,markbase) if p_markbase then local mrks = marks[p_markbase] + local nofmarks = #mrks for n in traverse_id(glyph_code,p.next) do local n_markmark = has_attribute(n,markmark) if p_markbase == n_markmark then @@ -373,20 +377,20 @@ 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 + if nofmarks == 1 then + break + else + nofmarks = nofmarks - 1 + end end - -- else - -- break -- KE: there can be sequences in ligatures + else + -- KE: there can be sequences in ligatures end end end end if not keep then marks = { } --- markcount = { } end end -- todo : combine diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi index ab9d8a5c4..978cc120c 100644 --- a/tex/context/base/pack-mis.mkvi +++ b/tex/context/base/pack-mis.mkvi @@ -64,9 +64,9 @@ {\placementparameter\c!left \flushnextbox \placementparameter\c!right}% - \ifinsidefloat \else - \page_backgrounds_add_local_to_box\nextbox - \fi + %\ifinsidefloat \else + % \page_backgrounds_add_local_to_box\nextbox + %\fi \ifgridsnapping \pack_placement_flush_grid_yes \else diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index 18f0db163..71e621b30 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -2460,13 +2460,13 @@ \hsize\localhsize % \insidefloattrue % ? better \normalexpanded{\switchtobodyfont[\framedtextparameter\c!bodyfont]}% - \startcolor[\framedtextparameter\c!color]% +% \startcolor[\framedtextparameter\c!color]% \letframedtextparameter\c!strut\v!no \inheritedframedtextframed\bgroup \let\\=\endgraf \framedtextparameter\c!inner % oud spul \doif{\framedtextparameter\c!depthcorrection}\v!on\pack_framed_text_start_depth_correction - \doinhibitblank % \blank[\v!disable]% plaatst signal + \doinhibitblank \setupindenting[\framedtextparameter\c!indenting]% \useframedtextstyleandcolor\c!style\c!color} @@ -2481,7 +2481,7 @@ \removelastskip \doif{\framedtextparameter\c!depthcorrection}\v!on\pack_framed_text_stop_depth_correction \stopboxedcontent - \stopcolor +% \stopcolor \ifconditional\c_framed_text_location_none \egroup \box\b_framed_normal diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv index 18e0a9f4d..100c186dd 100644 --- a/tex/context/base/page-bck.mkiv +++ b/tex/context/base/page-bck.mkiv @@ -328,88 +328,6 @@ \newconditional\swapbackgroundmargins \settrue\swapbackgroundmargins -% \def\page_backgrounds_set_box#1% #2% -% {\global\setbox#1\vbox -% {\dontcomplain -% \swapmargins -% \ifconditional\swapbackgroundmargins -% \doifmarginswapelse \donothing -% {\swapmacros\v!rightmargin\v!leftmargin -% \swapmacros\v!rightedge \v!leftedge}% -% \fi -% \calculatereducedvsizes -% \offinterlineskip -% % \ifconditional#2\relax -% % \doswapmargins % hm, this one gets nilled in \swapmargins anyway -% % \fi -% \vskip\dimexpr-\topheight-\topdistance\relax -% \ifdim\topheight>\zeropoint -% \page_backgrounds_set_box_row\v!top\topheight -% \fi -% \vskip\topdistance -% \ifdim\headerheight>\zeropoint -% \page_backgrounds_set_box_row\v!header\headerheight -% \fi -% \vskip\headerdistance -% \ifdim\textheight>\zeropoint -% \page_backgrounds_set_box_row\v!text\textheight -% \fi -% \vskip\footerdistance -% \ifdim\footerheight>\zeropoint -% \page_backgrounds_set_box_row\v!footer\footerheight -% \fi -% \vskip\bottomdistance -% \ifdim\bottomheight>\zeropoint -% \page_backgrounds_set_box_row\v!bottom\bottomheight -% \fi -% \vfilll}% -% \smashbox#1} - -% \def\page_backgrounds_set_box_row#1#2% maybe helper -% {\setbox\scratchbox\vbox to #2 -% \bgroup\hbox\bgroup -% \goleftonpage -% \ifdim\leftedgewidth>\zeropoint -% \ifcsname\??ma#1\v!leftedge\endcsname -% \page_backgrounds_set_box_cell#1\v!leftedge\leftedgewidth#2% -% \else -% \hskip\leftedgewidth -% \fi -% \fi -% \hskip\leftedgedistance -% \ifdim\leftmarginwidth>\zeropoint -% \ifcsname\??ma#1\v!leftmargin\endcsname -% \page_backgrounds_set_box_cell#1\v!leftmargin\leftmarginwidth#2% -% \else -% \hskip\leftmarginwidth -% \fi -% \fi -% \hskip\leftmargindistance -% \ifcsname\??ma#1\v!text\endcsname -% \page_backgrounds_set_box_cell#1\v!text\makeupwidth#2% -% \else -% \hskip\makeupwidth -% \fi -% \hskip\rightmargindistance -% \ifdim\rightmarginwidth>\zeropoint -% \ifcsname\??ma#1\v!rightmargin\endcsname -% \page_backgrounds_set_box_cell#1\v!rightmargin\rightmarginwidth#2% -% \else -% \hskip\rightmarginwidth -% \fi -% \fi -% \hskip\rightedgedistance -% \ifdim\rightedgewidth>\zeropoint -% \ifcsname\??ma#1\v!rightedge\endcsname -% \page_backgrounds_set_box_cell#1\v!rightedge\rightedgewidth#2% -% \else -% \hskip\rightedgewidth -% \fi -% \fi -% \egroup\egroup -% \wd\scratchbox\zeropoint -% \box\scratchbox\relax} - \def\page_backgrounds_set_box#1% #2% {\global\setbox#1\vbox {\dontcomplain @@ -492,15 +410,6 @@ \wd\scratchbox\zeropoint \box\scratchbox\relax} -% \def\page_backgrounds_set_box_cell#1#2#3#4% width height pos pos % maybe helper -% {\ifcsname\??ma#1#2\c!setups\endcsname % to be done -% \doprocesslocalsetups{\csname\??ma#1#2\c!setups\endcsname}% should not produce funny spaces ! -% \fi -% \fastlocalframed % can we avoid boxes here? -% [\??ma#1#2]% -% [\c!component=#1:#2]% -% {\vbox to #4{\vss\hbox to#3{\hss\csname\??ma#1#2\c!command\endcsname\hss}\vss}}} - % these are fake framed .. maybe it's nicer to honor foreground here as well % but it's probably a slow downer @@ -686,32 +595,33 @@ % The next series is used in local (for instance floating) % backgrounds. -\installsomebackground \v!local \empty % not really a background, invisible for users - -\getparameters - [\??ma\v!local] - [\c!component=local, - \c!background=\localbackgroundlist] - -\def\localbackgroundlist - {\v!local-2,\v!local-1,\v!foreground,\v!local+1,\v!local+2} - -\defineoverlay[\v!local-2][\positionoverlay{\v!local-2}] % todo share -\defineoverlay[\v!local-1][\positionoverlay{\v!local-1}] -\defineoverlay[\v!local+1][\positionoverlay{\v!local+1}] -\defineoverlay[\v!local+2][\positionoverlay{\v!local+2}] - -\def\page_backgrounds_add_local_to_box - {\ifconditional\c_page_backgrounds_hidden_enabled - \expandafter\page_backgrounds_add_local_to_box_indeed - \else - \expandafter\gobbleoneargument - \fi} - -\def\page_backgrounds_add_local_to_box_indeed#1% - {%\setbox#1\hbox{\registerMPlocaltextarea{\box#1}}% - \setbox#1\hbox{\localbackgroundframed{\??ma\v!local}\v!local#1}% - \global\advance\localpositionnumber\plusone} % afterwards ! +% \installsomebackground \v!local \empty % not really a background, invisible for users +% +% \getparameters +% [\??ma\v!local] +% [\c!component=local, +% \c!background=\localbackgroundlist] +% +% \def\localbackgroundlist +% {\v!local-2,\v!local-1,\v!foreground,\v!local+1,\v!local+2} +% +% \defineoverlay[\v!local-2][\positionoverlay{\v!local-2}] % todo share +% \defineoverlay[\v!local-1][\positionoverlay{\v!local-1}] +% \defineoverlay[\v!local+1][\positionoverlay{\v!local+1}] +% \defineoverlay[\v!local+2][\positionoverlay{\v!local+2}] +% +% \def\page_backgrounds_add_local_to_box +% {\ifconditional\c_page_backgrounds_hidden_enabled +% \expandafter\page_backgrounds_add_local_to_box_indeed +% \else +% \expandafter\gobbleoneargument +% \fi} +% +% \def\page_backgrounds_add_local_to_box_indeed#1% +% {\setbox#1\hbox{\localbackgroundframed{\??ma\v!local}\v!local#1}% +% \global\advance\localpositionnumber\plusone} % afterwards ! +% +% \let\page_backgrounds_add_local_to_box\gobbleoneargument % Test how previous macro behaves with depth: % diff --git a/tex/context/base/page-box.mkvi b/tex/context/base/page-box.mkvi index a13f794f1..7d034105c 100644 --- a/tex/context/base/page-box.mkvi +++ b/tex/context/base/page-box.mkvi @@ -275,29 +275,6 @@ \def\page_areas_registered_box_forget#1#2#3% #1=lower-dp #2=correct-ht #3=box {\box#3} -% \def\page_areas_registered_box_indeed#1#2#3% #1=lower-dp #2=correct-ht #3=box -% {\hbox\bgroup -% \ifx\registerMPtextarea\undefined \else -% \setbox\b_page_areas_registered\emptyhbox -% \wd\b_page_areas_registered\wd#3% -% \ht\b_page_areas_registered\ht#3% -% \dp\b_page_areas_registered\dp#3% -% \ifcase#1\or % 1 -% \setbox\b_page_areas_registered\hbox{\lower\strutdp\box\b_page_areas_registered}% -% \fi -% \ifcase#2\or % 1 -% \setbox\b_page_areas_registered\hbox{\raise\topskip\hbox{\lower\strutht\box\b_page_areas_registered}}% -% \dp\b_page_areas_registered\strutdp -% \fi -% \dp\b_page_areas_registered\strutdp % needed -% \setbox\b_page_areas_registered\hbox -% {\registerMPtextarea{\box\b_page_areas_registered}}% -% \smashbox\b_page_areas_registered -% \box\b_page_areas_registered -% \fi -% \box#3% -% \egroup} - \def\page_areas_registered_box_indeed#1#2#3% #1=lower-dp #2=correct-ht #3=box {\anch_mark_flow_box{#3}} diff --git a/tex/context/base/page-mrk.mkiv b/tex/context/base/page-mrk.mkiv index aabef6154..5f8d332c5 100644 --- a/tex/context/base/page-mrk.mkiv +++ b/tex/context/base/page-mrk.mkiv @@ -35,18 +35,22 @@ \newcount\c_page_marks_ny \startuniqueMPgraphic{print:color}{w,h,l,o} + if unknown context_crop : input mp-crop.mpiv ; fi ; page_marks_add_color(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ; \stopuniqueMPgraphic \startuniqueMPgraphic{print:marking}{w,h,l,o} + if unknown context_crop : input mp-crop.mpiv ; fi ; page_marks_add_marking(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ; \stopuniqueMPgraphic \startuniqueMPgraphic{print:lines}{w,h,l,o,x,y} + if unknown context_crop : input mp-crop.mpiv ; fi ; page_marks_add_lines(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar x,\MPvar y) ; \stopuniqueMPgraphic \startuseMPgraphic{print:number}{w,h,l,o,n} + if unknown context_crop : input mp-crop.mpiv ; fi ; page_marks_add_number(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar n) ; \stopuseMPgraphic diff --git a/tex/context/base/page-plg.mkiv b/tex/context/base/page-plg.mkiv index 798014f19..004b9204d 100644 --- a/tex/context/base/page-plg.mkiv +++ b/tex/context/base/page-plg.mkiv @@ -108,17 +108,13 @@ %D \stoptext %D \stoptyping -% will become an outputroutine - \unprotect \def\page_boxes_construct_content_makeup#1#2#3% targetbox flusher box {\setbox#1\hbox {\vbox to \textheight {\offinterlineskip - % optie - \vskip\dimexpr-1\topskip+\strutheight\relax - % + \vskip\dimexpr-1\topskip+\strutheight\relax % could be an option \textwidth\makeupwidth \hsize\textwidth \boxmaxdepth\maxdepth @@ -138,7 +134,7 @@ \newbox\pageareabox -\def\pagearea +\unexpanded\def\pagearea {\dotripleempty\page_area} \def\page_area[#1][#2][#3]% @@ -156,9 +152,10 @@ \else \doif{#1}\v!text % copy due to trial runs in TABLE {\iftrialtypesetting - \copy\pagebox +% \copy\pagebox + \fakebox\pagebox \else - \localpositioningfalse +% \localpositioningfalse \page_backgrounds_add_to_text\pagebox \page_grids_add_to_box\pagebox \box\pagebox @@ -169,7 +166,8 @@ {\setbox\pageareabox\vbox{\getspecificlayouttext{#1}{#2}{#3}}% \ifsomebackgroundfound{#1#2}% \iftrialtypesetting - \box\pageareabox +% \box\pageareabox + \fakebox\pageareabox \else \localframed [\??ma#1#2] diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index c63f697e1..f16ab70d7 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -673,10 +673,10 @@ \page_otr_insert_dummy_page} \installpagebreakmethod \v!header - {\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\c!state=\v!empty]}} + {\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}} \installpagebreakmethod \v!footer - {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\c!state=\v!empty]}} + {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}} %D While the header and footer lines are moved away from the %D main text, the top and bottom lines are centered. diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index b38fb6ea6..614852d92 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -764,7 +764,8 @@ \unexpanded\def\startshowpardata {\begingroup - \showstruts\tracepositionstrue \tracingparagraphs\maxdimen + \showstruts + \tracingparagraphs\maxdimen \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} \unexpanded\def\stopshowpardata diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index ed4110d93..19a033e53 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 e886b982d..a7dd888ae 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/strc-con.mkvi b/tex/context/base/strc-con.mkvi index a4df0dc36..0e9b458d9 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -715,12 +715,12 @@ \let\placeclosesymbol\strc_constructions_close_symbol_place \let\qed \strc_constructions_close_symbol_place} -\def\strc_constructions_close_symbol_place +\unexpanded\def\strc_constructions_close_symbol_place {\ifconditional\csname\??constructionclosesymbol\currentconstruction\endcsname \global\expandafter\setfalse\csname\??constructionclosesymbol\currentconstruction\endcsname \edef\p_closesymbol{\constructionparameter\c!closesymbol}% \ifx\p_closesymbol\empty \else - \constructionparameter\c!closecommand\p_closesymbol + \constructionparameter\c!closecommand{\p_closesymbol}% hm why {} maybe because box expected \fi \fi} diff --git a/tex/context/base/strc-des.mkvi b/tex/context/base/strc-des.mkvi index 845fb648c..1b29c864f 100644 --- a/tex/context/base/strc-des.mkvi +++ b/tex/context/base/strc-des.mkvi @@ -108,7 +108,7 @@ \csname\??constructionstarthandler\currentconstructionhandler\endcsname} \unexpanded\def\strc_descriptions_start_yes_reference - {\ifconditional\c_strc_descriptions_title_state + {\ifconditional\c_strc_constructions_title_state \expandafter\strc_descriptions_start_yes_titled \else \expandafter\strc_descriptions_start_yes_normal diff --git a/tex/context/base/strc-enu.mkvi b/tex/context/base/strc-enu.mkvi index 9cacbd556..625dc6a21 100644 --- a/tex/context/base/strc-enu.mkvi +++ b/tex/context/base/strc-enu.mkvi @@ -277,8 +277,8 @@ \unexpanded\def\strc_enumerations_inject_extra_text {\ifconditional\c_strc_constructions_title_state \ctxcommand{doiflisthastitleelse("\currentconstructionmain",\currentconstructionlistentry)} - \strc_enumerations_inject_extra_text_indeed \donothing + \strc_enumerations_inject_extra_text_indeed \fi} \unexpanded\def\strc_enumerations_inject_text diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi index fa0a9d960..002afa3da 100644 --- a/tex/context/base/strc-flt.mkvi +++ b/tex/context/base/strc-flt.mkvi @@ -1217,15 +1217,15 @@ \or % automatic \ifnofloatcaption \strc_floats_prepare_no_caption - \page_backgrounds_add_local_to_box\floatbox % was \doglobal but not needed + %\page_backgrounds_add_local_to_box\floatbox % was \doglobal but not needed \else % todo: installable maken, variant/method=auto vs macro \strc_floats_prepare_page_caption - \page_backgrounds_add_local_to_box\b_strc_floats_content + %\page_backgrounds_add_local_to_box\b_strc_floats_content \setbox\b_strc_floats_caption\hbox {\floatcaptionparameter\c!command{\box\b_strc_floats_caption}}% \moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height - \page_backgrounds_add_local_to_box\b_strc_floats_caption + %\page_backgrounds_add_local_to_box\b_strc_floats_caption \strc_floats_build_box \fi \or % semi automatic @@ -1795,7 +1795,7 @@ \dontcomplain %\showcomposition \setbox\b_strc_floats_content\vbox{\borderedfloatbox}% - \page_backgrounds_add_local_to_box\b_strc_floats_content + %\page_backgrounds_add_local_to_box\b_strc_floats_content \ifnofloatcaption \global\setbox\floatbox\vbox{\box\b_strc_floats_content}% \else @@ -1803,7 +1803,7 @@ \strc_floats_prepare_side_caption \setbox\b_strc_floats_caption\hbox{\floatcaptionparameter\c!command{\box\b_strc_floats_caption}}% \moveboxontogrid\b_strc_floats_caption{\floatcaptionparameter\c!grid}\d_strc_floats_caption_height - \page_backgrounds_add_local_to_box\b_strc_floats_caption + %\page_backgrounds_add_local_to_box\b_strc_floats_caption \strc_floats_build_side_box \fi \egroup} diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index d7172a141..a8e62542b 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -516,7 +516,7 @@ %\blank[\v!line] % packed mode (we could do \startunpacked ...) \godown[.75\lineheight] \switchtobodyfont[\v!small] - \ignorespaces\xmlfilter{#1}{/arguments/text()}\endgraf + \ignorespaces\xmlfilter{#1}{/arguments/text()}\endgraf \egroup } \getvalue{\e!stop setuptext} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index d85a0f4a3..09cff0c18 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 02/18/12 10:50:58 +-- merge date : 02/21/12 00:51:07 do -- begin closure to overcome local limits and interference @@ -8111,6 +8111,7 @@ local cursbase = attributes.private('cursbase') local curscurs = attributes.private('curscurs') local cursdone = attributes.private('cursdone') local kernpair = attributes.private('kernpair') +local ligacomp = attributes.private('ligacomp') local fontkern = attributes.private('fontkern') if context then @@ -8129,20 +8130,19 @@ end -- 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). +-- (arabic, hebrew and thai) and myself (whatever font I come across). I'm pretty sure +-- that this code is not 100% okay but examples are needed to figure things out. -local cursives = { } -local marks = { } -local kerns = { } -local markcount = { } +local cursives = { } +local marks = { } +local kerns = { } --- 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 +-- 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 .. idris: this needs --- checking with husayni (volt and fontforge) +-- 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]) @@ -8186,12 +8186,14 @@ function injections.setkern(current,factor,rlmode,x,tfmchr) 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]) -- index argument no longer used - local bound = has_attribute(base,markbase) + local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- the index argument is no longer used but when this + local bound = has_attribute(base,markbase) -- fails again we should pass it +local index = 1 if bound then local mb = marks[bound] if mb then - if not index then index = #mb + 1 end + -- if not index then index = #mb + 1 end +index = #mb + 1 mb[index] = { dx, dy, rlmode } set_attribute(start,markmark,bound) set_attribute(start,markdone,index) @@ -8200,6 +8202,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanch report_injections("possible problem, U+%05X is base mark without data (id: %s)",base.char,bound) end end +-- index = index or 1 index = index or 1 bound = #marks + 1 set_attribute(base,markbase,bound) @@ -8264,8 +8267,8 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -- 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 +-- 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) @@ -8403,6 +8406,7 @@ function injections.handler(head,where,keep) local p_markbase = has_attribute(p,markbase) if p_markbase then local mrks = marks[p_markbase] + local nofmarks = #mrks for n in traverse_id(glyph_code,p.next) do local n_markmark = has_attribute(n,markmark) if p_markbase == n_markmark then @@ -8439,20 +8443,20 @@ 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 + if nofmarks == 1 then + break + else + nofmarks = nofmarks - 1 + end end - -- else - -- break -- KE: there can be sequences in ligatures + else + -- KE: there can be sequences in ligatures end end end end if not keep then marks = { } --- markcount = { } end end -- todo : combine @@ -8592,6 +8596,7 @@ if not modules then modules = { } end modules ['font-otn'] = { -- default features (per language, script) -- handle positions (we need example fonts) -- handle gpos_single (we might want an extra width field in glyph nodes because adding kerns might interfere) +-- mark (to mark) code is still not what it should be (too messy but we need some more extreem husayni tests) --[[ldx--

This module is a bit more split up that I'd like but since we also want to test @@ -8757,14 +8762,21 @@ local ligature_code = glyphcodes.ligature local privateattribute = attributes.private +-- Something is messed up: we have two mark / ligature indices, one at the injection +-- end and one here ... this is bases in KE's patches but there is something fishy +-- there as I'm pretty sure that for husayni we need some connection (as it's much +-- more complex than an average font) but I need proper examples of all cases, not +-- of only some. + local state = privateattribute('state') local markbase = privateattribute('markbase') local markmark = privateattribute('markmark') -local markdone = privateattribute('markdone') +local markdone = privateattribute('markdone') -- assigned at the injection end local cursbase = privateattribute('cursbase') local curscurs = privateattribute('curscurs') local cursdone = privateattribute('cursdone') local kernpair = privateattribute('kernpair') +local ligacomp = privateattribute('ligacomp') -- assigned here (ideally it should be combined) local injections = nodes.injections local setmark = injections.setmark @@ -8917,7 +8929,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) @@ -8932,48 +8944,38 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- current.subtype = ligature_code current.components = start local head = current - -- 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 - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - head, current = insert_node_after(head,current,copy_node(start)) - else - i = i + 1 - end - start = start.next - end - start = current.next - while start and start.id == glyph_code do - if marks[start.char] then - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - else - break + -- this is messy ... we should get rid of the components eventually + local i = 0 -- is index of base + while start do + if not marks[start.char] then + i = i + 1 + elseif not deletemarks then -- quite fishy + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) + end + head, current = insert_node_after(head,current,copy_node(start)) + end + start = start.next + end + start = current.next + while start and start.id == glyph_code do + if marks[start.char] then + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) end - start = start.next + else + break 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 - -- - -- flush_node_list(head.components) + start = start.next + 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 + -- + -- flush_node_list(head.components) return head end end @@ -9225,18 +9227,14 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -9247,9 +9245,7 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) end end end --- local i = has_attribute(start,markdone) --- if i then index = i end -- needed -local index = has_attribute(start,markdone) + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar] if baseanchors then baseanchors = baseanchors.anchors @@ -9263,7 +9259,7 @@ local index = has_attribute(start,markdone) 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) @@ -9295,11 +9291,20 @@ function handlers.gpos_mark2mark(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [basemark] [start=mark] - -- new - 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 + -- while base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end 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] @@ -9859,18 +9864,14 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end if markanchors then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -9882,8 +9883,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end end -- todo: like marks a ligatures hash - local i = has_attribute(start,markdone) - if i then index = i end + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar].anchors if baseanchors then local baseanchors = baseanchors['baselig'] @@ -9895,7 +9895,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, 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, bound %s: anchoring mark %s to baselig %s at index %s => (%s,%s)", cref(kind,chainname,chainlookupname,lookupname),anchor,a or bound,gref(markchar),gref(basechar),index,dx,dy) @@ -9936,6 +9936,20 @@ function chainprocs.gpos_mark2mark(start,stop,kind,chainname,currentcontext,look end if markanchors then local base = start.prev -- [glyph] [basemark] [start=mark] + -- while (base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp)) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end + 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].anchors -- cgit v1.2.3