summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-02-21 02:20:25 +0200
committerMarius <mariausol@gmail.com>2012-02-21 02:20:25 +0200
commit183dc1310ce5237533807ce07b2d3cd2d40962a1 (patch)
treeb6607e33b02a8ff22cd64b2b647625354e6a1849
parent804ec91e98cd955dc41da3ea7f2a438f485d9b40 (diff)
downloadcontext-183dc1310ce5237533807ce07b2d3cd2d40962a1.tar.gz
beta 2012.02.21 00:51
-rw-r--r--metapost/context/base/metafun.mpiv3
-rw-r--r--metapost/context/base/mp-abck.mpiv254
-rw-r--r--metapost/context/base/mp-apos.mpiv91
-rw-r--r--metapost/context/base/mp-asnc.mpiv177
-rw-r--r--metapost/context/base/mp-core.mpiv194
-rw-r--r--metapost/context/base/mp-crop.mpiv194
-rw-r--r--metapost/context/base/mp-page.mpiv397
-rw-r--r--metapost/context/base/mp-tool.mpiv2
-rw-r--r--tex/context/base/anch-bar.mkiv86
-rw-r--r--tex/context/base/anch-bck.mkvi313
-rw-r--r--tex/context/base/anch-pgr.lua74
-rw-r--r--tex/context/base/anch-pgr.mkiv100
-rw-r--r--tex/context/base/anch-pos.lua41
-rw-r--r--tex/context/base/anch-pos.mkiv124
-rw-r--r--tex/context/base/anch-snc.mkiv14
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4075 -> 4066 bytes
-rw-r--r--tex/context/base/context-version.pngbin105299 -> 105621 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv4
-rw-r--r--tex/context/base/core-ini.mkiv16
-rw-r--r--tex/context/base/font-otn.lua132
-rw-r--r--tex/context/base/meta-pag.mkiv71
-rw-r--r--tex/context/base/mlib-run.lua4
-rw-r--r--tex/context/base/mult-sys.mkiv1
-rw-r--r--tex/context/base/node-inj.lua50
-rw-r--r--tex/context/base/pack-mis.mkvi6
-rw-r--r--tex/context/base/pack-rul.mkiv6
-rw-r--r--tex/context/base/page-bck.mkiv144
-rw-r--r--tex/context/base/page-box.mkvi23
-rw-r--r--tex/context/base/page-mrk.mkiv4
-rw-r--r--tex/context/base/page-plg.mkiv16
-rw-r--r--tex/context/base/page-txt.mkvi4
-rw-r--r--tex/context/base/spac-ali.mkiv3
-rw-r--r--tex/context/base/status-files.pdfbin24275 -> 24246 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin172321 -> 172402 bytes
-rw-r--r--tex/context/base/strc-con.mkvi4
-rw-r--r--tex/context/base/strc-des.mkvi2
-rw-r--r--tex/context/base/strc-enu.mkvi2
-rw-r--r--tex/context/base/strc-flt.mkvi10
-rw-r--r--tex/context/base/x-set-11.mkiv2
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua188
43 files changed, 1519 insertions, 1243 deletions
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index f801717f1..d600764a3 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -19,7 +19,7 @@
input "mp-base.mpiv" ;
input "mp-tool.mpiv" ;
input "mp-mlib.mpiv" ;
-input "mp-core.mpiv" ; % todo: namespace and cleanup
+% "mp-core.mpiv" ; % todo: namespace and cleanup
input "mp-page.mpiv" ; % todo: namespace and cleanup
input "mp-butt.mpiv" ; % todo: namespace and cleanup
input "mp-shap.mpiv" ; % will be improved
@@ -28,7 +28,6 @@ input "mp-grid.mpiv" ; % todo: namespace and cleanup
input "mp-form.mpiv" ; % under (re)construction
input "mp-figs.mpiv" ; % obsolete, needs checking
input "mp-func.mpiv" ; % under construction
-
% "mp-text.mpiv" ; % loaded on demand
% "mp-char.mpiv" ; % loaded on demand
% "mp-step.mpiv" ; % loaded on demand
diff --git a/metapost/context/base/mp-abck.mpiv b/metapost/context/base/mp-abck.mpiv
new file mode 100644
index 000000000..3d5afb903
--- /dev/null
+++ b/metapost/context/base/mp-abck.mpiv
@@ -0,0 +1,254 @@
+%D \module
+%D [ file=mp-abck.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_abck : endinput ; fi ;
+
+boolean context_abck ; context_abck := true ;
+
+path multiregs[], % region used for multipar (tracing only)
+ multipars[], % effective area (shape)
+ multibox ; % main boundingbox (of main region)
+
+string multikind[] ; % region state: single | first | middle | last (new method)
+
+numeric multilocs[], % 1=begin 2=between 3=end (old method)
+ nofmultipars ; % number of calculated areas
+
+numeric par_strut_height,
+ par_strut_depth,
+ par_line_height ;
+
+nofmultipars := 0 ;
+par_strut_height := 0 ;
+par_strut_depth := 0 ;
+par_line_height := 0 ;
+
+def boxgridoptions = withcolor .8red enddef ;
+def boxlineoptions = withcolor .8blue enddef ;
+def boxfilloptions = withcolor .8white enddef ;
+
+numeric boxgridtype ; boxgridtype := 0 ;
+numeric boxlinetype ; boxlinetype := 1 ;
+numeric boxfilltype ; boxfilltype := 1 ;
+numeric boxdashtype ; boxdashtype := 0 ;
+pair boxgriddirection ; boxgriddirection := up ;
+numeric boxgridwidth ; boxgridwidth := 1pt ;
+numeric boxlinewidth ; boxlinewidth := 1pt ;
+numeric boxlineradius ; boxlineradius := 0 ;
+numeric boxlineoffset ; boxlineoffset := 0 ;
+numeric boxfilloffset ; boxfilloffset := 0 ;
+numeric boxgriddistance ; boxgriddistance := .5cm ;
+numeric boxgridshift ; boxgridshift := 0 ;
+
+def abck_show_path(expr p, r, c) =
+ draw p withpen pencircle scaled .5pt withcolor c ;
+ if length(p) > 2 :
+ begingroup ; save _c_ ; path _c_ ; _c_ := fullcircle scaled r ;
+ for i=0 upto length(p) if cycle p : -1 fi :
+ fill _c_ shifted point i of p withcolor white ;
+ draw _c_ shifted point i of p withpen pencircle scaled .5pt withcolor c ;
+ endfor ;
+ fi ;
+enddef ;
+
+vardef abck_draw_path(expr p) =
+ if (length p > 2) and (bbwidth(p) > 1) and (bbheight(p) > 1) :
+ save pp ; path pp ;
+ pp := p if (boxlineradius>0) and (boxlinetype=2) : cornered boxlineradius fi ;
+ if boxfilltype > 0 :
+ if boxfilloffset > 0 :
+ interim linejoin := mitered ;
+ filldraw pp boxfilloptions withpen pencircle scaled (2*boxfilloffset) ;
+ else :
+ fill pp boxfilloptions ;
+ fi ;
+ fi ;
+ if boxlinetype > 0 :
+ draw pp boxlineoptions withpen pencircle scaled boxlinewidth ;
+ fi ;
+ fi ;
+enddef ;
+
+def abck_grid_line(expr start, width) =
+ % 1 = normal, 2 = with background (i.e. no shine-through)
+ if boxdashtype = 2 :
+ draw start -- start shifted (width,0)
+ withpen pencircle scaled boxgridwidth
+ boxfilloptions ;
+ fi ;
+ draw start -- start shifted (width,0)
+ if boxdashtype > 0 :
+ dashed evenly
+ fi
+ withpen pencircle scaled boxgridwidth
+ boxgridoptions ;
+enddef ;
+
+vardef abck_baseline_grid(expr pxy, pdir, at_baseline) =
+ save width ; width := bbwidth(pxy) ;
+ save height ; height := bbheight(pxy) ;
+ if (par_line_height > 0) and (height > 1) and (width > 1) and (boxgridwidth > 0) :
+ save i, grid, bb ; picture grid ; pair start ; path bb ;
+ grid := image ( % fails with inlinespace
+ if pdir = up :
+ for i = if at_baseline : par_strut_depth else : 0 fi step par_line_height until max(height,par_line_height) :
+ abck_grid_line(llcorner pxy shifted (0,+i),width) ;
+ endfor ;
+ else :
+ for i = if at_baseline : par_strut_height else : 0 fi step par_line_height until height :
+ abck_grid_line(ulcorner pxy shifted (0,-i),width) ;
+ endfor ;
+ fi ;
+ ) ;
+ clip grid to pxy ;
+ bb := boundingbox grid ;
+ grid := grid shifted (0,boxgridshift) ;
+ setbounds grid to bb ;
+ grid
+ else :
+ nullpicture
+ fi
+enddef ;
+
+vardef abck_graphic_grid(expr pxy, dx, dy, x, y) =
+ if (bbheight(pxy) > dy) and (bbwidth(pxy) > dx) and (boxgridwidth > 0) :
+ save grid ; picture grid ;
+ grid := image (
+ for i = xpart llcorner pxy step dx until xpart lrcorner pxy :
+ draw (i,ypart llcorner pxy) -- (i,ypart ulcorner pxy) withpen pencircle scaled boxgridwidth ;
+ endfor ;
+ for i = ypart llcorner pxy step dy until ypart ulcorner pxy :
+ draw (xpart llcorner pxy,i) -- (xpart lrcorner pxy,i) withpen pencircle scaled boxgridwidth ;
+ endfor
+ ) shifted (x,y) ;
+ clip grid to pxy ;
+ grid
+ else :
+ nullpicture
+ fi
+enddef ;
+
+def draw_multi_pars =
+ for i=1 upto nofmultipars :
+ abck_draw_path(multipars[i]) ;
+ if boxgridtype = 1 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) ;
+ elseif boxgridtype = 2 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,false) ;
+ elseif boxgridtype = 3 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) ;
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight) ;
+ elseif boxgridtype = 4 :
+ draw abck_baseline_grid(multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight/2) ;
+ elseif boxgridtype = 11 :
+ draw abck_graphic_grid(multipars[i],boxgriddistance,boxgriddistance,boxgriddistance/2,boxgriddistance/2) ;
+ elseif boxgridtype = 12 :
+ draw abck_graphic_grid(multipars[i],boxgriddistance,boxgriddistance,0,0) ;
+ fi ;
+ endfor ;
+enddef ;
+
+def show_multi_pars =
+ for i=1 upto nofmultipars :
+ abck_show_path(multipars[i], 6pt, .5blue) ;
+ endfor ;
+enddef ;
+
+def show_multi_kind =
+ for i=1 upto nofmultipars :
+ fill multipars[i]
+ 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 ;
+enddef ;
+
+def draw_multi_side =
+ begingroup ; save p ; picture p ;
+ for i=1 upto nofmultipars :
+ p := image ( fill leftboundary multipars[i]
+ shifted (-boxlineoffset,0)
+ rightenlarged boxlinewidth boxlineoptions ;
+ ) ;
+ setbounds p to multipars[i] ;
+ draw p ;
+ endfor ;
+ endgroup ;
+enddef ;
+
+% some extras
+
+path posboxes[],
+ posregions[] ;
+
+numeric multipages[],
+ nofposboxes ;
+
+nofposboxes := 0 ;
+
+% For the moment we keep these as they can be in use but they will
+% disappear.
+
+pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ;
+path pxy[] ;
+numeric hxy[], wxy[], dxy[], nxy[] ;
+
+def box_found (expr n,x,y,w,h,d) =
+ not ((x=0) and (y=0) and (w=0) and (h=0) and (d=0))
+enddef ;
+
+def initialize_box_pos (expr pos,n,x,y,w,h,d) =
+ pair lxy, rxy, cxy, llxy, lrxy, ulxy, urxy ;
+ path pxy ; numeric hxy, wxy, dxy, nxy;
+ lxy := (x,y) ;
+ llxy := (x,y-d) ;
+ lrxy := (x+w,y-d) ;
+ urxy := (x+w,y+h) ;
+ ulxy := (x,y+h) ;
+ wxy := w ;
+ hxy := h ;
+ dxy := d ;
+ rxy := lxy shifted (wxy,0) ;
+ pxy := llxy--lrxy--urxy--ulxy--cycle ;
+ cxy := center pxy ;
+ nxy := n ;
+ freeze_box(pos) ;
+enddef ;
+
+def freeze_box (expr pos) =
+ lxy[pos] := lxy ;
+ llxy[pos] := llxy ;
+ lrxy[pos] := lrxy ;
+ urxy[pos] := urxy ;
+ ulxy[pos] := ulxy ;
+ wxy[pos] := wxy ;
+ hxy[pos] := hxy ;
+ dxy[pos] := dxy ;
+ rxy[pos] := rxy ;
+ pxy[pos] := pxy ;
+ cxy[pos] := cxy ;
+ nxy[pos] := nxy ;
+enddef ;
+
+def initialize_box (expr n,x,y,w,h,d) =
+ numeric bpos ; bpos := 0 ; initialize_box_pos(bpos,n,x,y,w,h,d) ;
+enddef ;
+
+def anchor_box (expr n,x,y,w,h,d) =
+ currentpicture := currentpicture shifted (-x,-y) ;
+enddef ;
diff --git a/metapost/context/base/mp-apos.mpiv b/metapost/context/base/mp-apos.mpiv
new file mode 100644
index 000000000..072c958f3
--- /dev/null
+++ b/metapost/context/base/mp-apos.mpiv
@@ -0,0 +1,91 @@
+%D \module
+%D [ file=mp-apos.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_apos : endinput ; fi ;
+
+boolean context_apos ; context_apos := true ;
+
+path posboxes[],
+ posregions[] ;
+
+numeric multipages[],
+ nofposboxes ;
+
+nofposboxes := 0 ;
+
+def boxlineoptions = withcolor .8blue enddef ;
+def boxfilloptions = withcolor .8white enddef ;
+
+def connect_positions =
+ if nofposboxes = 2 :
+ pickup pencircle scaled boxlinewidth ;
+ path pa ; pa := posboxes[1] enlarged boxlineoffset ;
+ path pb ; pb := posboxes[2] enlarged boxlineoffset ;
+ if pospages[1] = pospages[2] :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} .. {down} center pb ;
+ pair cc ; 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 boxlineoptions ;
+ drawarrow reverse pc boxlineoptions ;
+ fi ;
+ fi ;
+ elseif pospages[1] == RealPageNumber :
+ draw posboxes[1] boxlineoptions ;
+ path pc ; pc := center pa {up} ... {right} urcorner (posregions[1] enlarged (20pt,20pt)) ;
+ pair cc ; cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ elseif pospages[2] == RealPageNumber :
+ draw posboxes[2] boxlineoptions ;
+ path pc ; pc := ulcorner (posregions[2] enlarged (20pt,20pt)) {right} ... {down} center pb ;
+ pair cc ; cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc boxlineoptions ;
+ fi ;
+ fi ;
+ fi ;
+enddef ;
+
+% anch-bar:
+
+def anch_sidebars_draw(expr p_b_self, p_e_self, y_b_self, y_e_self, h_b_self, d_e_self, distance, linewidth, linecolor) =
+ StartPage ;
+ path p ; p :=
+ if p_b_self=p_e_self :
+ (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
+ (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
+ elseif RealPageNumber=p_b_self :
+ (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
+ (llcorner Field[Text][Text]) ;
+ elseif RealPageNumber=p_e_self :
+ (ulcorner Field[Text][Text]) --
+ (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
+ else :
+ (ulcorner Field[Text][Text]) --
+ (llcorner Field[Text][Text]) ;
+ fi ;
+ p := p shifted (-llcorner Field[Text][Text]-(distance,0)) ;
+ interim linecap := butt ;
+ draw p
+ withpen pencircle scaled linewidth
+ withcolor linecolor ;
+ StopPage ;
+enddef ;
diff --git a/metapost/context/base/mp-asnc.mpiv b/metapost/context/base/mp-asnc.mpiv
new file mode 100644
index 000000000..cfee782e7
--- /dev/null
+++ b/metapost/context/base/mp-asnc.mpiv
@@ -0,0 +1,177 @@
+%D \module
+%D [ file=mp-asnc.mp,
+%D version=2012.02.19, % was mp-core: 1999.08.01, anchoring
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=anchored background macros,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_asnc : endinput ; fi ;
+
+boolean context_av ; context_asnc := true ;
+
+% will be replaced
+
+numeric sync_n[], sync_p[][], sync_w[][], sync_h[][], sync_d[][], sync_t[][] ;
+pair sync_xy[][] ; color sync_c[][] ;
+
+def ResetSyncTasks =
+ path SyncPaths[] ; numeric SyncTasks[], NOfSyncPaths, CurrentSyncClass ;
+ NOfSyncPaths := CurrentSyncClass := 0 ;
+ if unknown SyncLeftOffset : numeric SyncLeftOffset ; SyncLeftOffset := 0 ; fi ;
+ if unknown SyncWidth : numeric SyncWidth ; SyncWidth := 0 ; fi ;
+ if unknown SyncThreshold : numeric SyncThreshold ; SyncThreshold := LineHeight ; fi ;
+ if unknown SyncColor : color SyncColor ; SyncColor := .5white ; fi ;
+ if (SyncLeftOffset = 0) and (SyncWidth = 0) :
+ SyncWidth := if known TextWidth : TextWidth else : -1cm fi ;
+ fi ;
+enddef ;
+
+ResetSyncTasks ;
+
+vardef SyncBox(expr n, i, leftoffset, width, topoffset, bottomoffset) =
+ save o ; pair o ; o := (xpart llcorner PlainTextArea,ypart sync_xy[n][i]) ;
+ o shifted (leftoffset,sync_h[n][i]+topoffset) --
+ o shifted (width+leftoffset,sync_h[n][i]+topoffset) --
+ o shifted (width+leftoffset,bottomoffset) --
+ o shifted (leftoffset,bottomoffset) -- cycle
+enddef ;
+
+def SetSyncColor(expr n, i, c) =
+ sync_c[n][i] := c ;
+enddef ;
+
+def SetSyncThreshold(expr n, i, th) =
+ sync_th[n][i] := th ;
+enddef ;
+
+vardef TheSyncColor(expr n, i) =
+ if known sync_c[n][i] : sync_c[n][i] else : SyncColor fi
+enddef ;
+
+vardef TheSyncThreshold(expr n, i) =
+ if known sync_th[n][i] : sync_th[n][i] else : SyncThreshold fi
+enddef ;
+
+vardef PrepareSyncTasks(expr n, collapse, extendtop, prestartnext) =
+ ResetSyncTasks ;
+ if known sync_n[n] :
+ CurrentSyncClass := n ;
+ save ok, l, d ; boolean ok ; ok := false ; NOfSyncPaths := l := 0 ;
+ for i=1 upto sync_n[n] :
+ if RealPageNumber > sync_p[n][i] :
+ l := i ;
+ elseif RealPageNumber = sync_p[n][i] :
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ if not ok :
+ if i>1 :
+ if sync_t[n][i-1] = sync_t[n][i] :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i-1, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i-1 ;
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ else :
+ SyncPaths[NOfSyncPaths] := SyncBox(n, i, SyncLeftOffset, SyncWidth, 0, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := i ;
+ fi ;
+ ok := true ;
+ fi ;
+ endfor ;
+ if (NOfSyncPaths = 0) and (l > 0) :
+ NOfSyncPaths := 1 ;
+ SyncPaths[NOfSyncPaths] := SyncBox(n, l, SyncLeftOffset, SyncWidth, PaperHeight, -PaperHeight) ;
+ SyncTasks[NOfSyncPaths] := l ;
+ fi ;
+ if NOfSyncPaths > 0 :
+ for i = 1 upto NOfSyncPaths-1 :
+ SyncPaths[i] := topboundary SyncPaths[i] -- reverse topboundary SyncPaths[i+1] -- cycle ;
+ endfor ;
+ if unknown SyncThresholdMethod :
+ numeric SyncThresholdMethod ; SyncThresholdMethod := 2 ;
+ fi ;
+ if extendtop :
+ if SyncThresholdMethod = 1 :
+ if NOfSyncPaths>1 :
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[2]]) ;
+ if (SyncTasks[2]>1) and (d > 0pt) and (d <= TheSyncThreshold(n,sync_t[n][SyncTasks[2]])) and (sync_p[n][SyncTasks[2]] = RealPageNumber) :
+ SyncPaths[2] := SyncPaths[2] topenlarged PaperHeight ;
+ fi ;
+ fi ;
+ else :
+ for i = 1 upto NOfSyncPaths :
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[i]]) ;
+ if (d > 0) and (d <= TheSyncThreshold(n,sync_t[n][SyncTasks[i]])) and (sync_p[n][SyncTasks[i]] = RealPageNumber) :
+ SyncPaths[i] := SyncPaths[i] topenlarged PaperHeight ;
+ fi ;
+ endfor ;
+ fi ;
+ fi ;
+ if prestartnext :
+ if NOfSyncPaths>1 :
+ if SyncTasks[NOfSyncPaths] < sync_n[n] : % there is a next one
+ d := ypart (ulcorner PlainTextArea - sync_xy[n][SyncTasks[NOfSyncPaths]+1]) ;
+ if (d > 0) and (d <= TheSyncThreshold(n, sync_t[n][SyncTasks[i]])) and (sync_p[n][SyncTasks[NOfSyncPaths]+1] = RealPageNumber+1) :
+ SyncPaths[NOfSyncPaths+1] :=
+ (xpart ulcorner SyncPaths[NOfSyncPaths],ypart llcorner PlainTextArea) --
+ (xpart urcorner SyncPaths[NOfSyncPaths],ypart llcorner PlainTextArea) --
+ lrcorner SyncPaths[NOfSyncPaths] --
+ llcorner SyncPaths[NOfSyncPaths] -- cycle ;
+ SyncTasks[NOfSyncPaths+1] := SyncTasks[NOfSyncPaths]+1 ;
+ NOfSyncPaths := NOfSyncPaths + 1 ;
+ fi ;
+ fi ;
+ fi ;
+ else :
+ if NOfSyncPaths>1 :
+ d := ypart (sync_xy[n][SyncTasks[NOfSyncPaths]] - llcorner PlainTextArea) ;
+ if (d < TheSyncThreshold(n, SyncTasks[NOfSyncPaths])) :
+ NOfSyncPaths := NOfSyncPaths - 1 ;
+ SyncPaths[NOfSyncPaths] := SyncPaths[NOfSyncPaths] bottomenlarged PaperHeight ;
+ fi ;
+ fi ;
+ fi ;
+ if (NOfSyncPaths>1) and collapse :
+ save j ; numeric j ; j := 1 ;
+ for i = 2 upto NOfSyncPaths :
+ if sync_t[n][SyncTasks[i]] = sync_t[n][SyncTasks[j]] :
+ SyncPaths[j] := boundingbox image (draw SyncPaths[i] ; draw SyncPaths[j] ; ) ;
+ SyncTasks[j] := SyncTasks[i] ;
+ else :
+ j := j + 1 ;
+ SyncPaths[j] := SyncPaths[i] ;
+ SyncTasks[j] := SyncTasks[i] ;
+ fi ;
+ endfor ;
+ NOfSyncPaths := j ;
+ fi ;
+ fi ;
+ fi ;
+enddef ;
+
+def SyncTask(expr n) =
+ if known SyncTasks[n] : SyncTasks[n] else : 0 fi
+enddef ;
+
+def FlushSyncTasks =
+ for i = 1 upto NOfSyncPaths :
+ ProcessSyncTask(SyncPaths[i], TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]])) ;
+ endfor ;
+enddef ;
+
+def ProcessSyncTask(expr p, c) =
+ fill p withcolor c ;
+enddef ;
diff --git a/metapost/context/base/mp-core.mpiv b/metapost/context/base/mp-core.mpiv
index c0718397d..fd0b8bb9c 100644
--- a/metapost/context/base/mp-core.mpiv
+++ b/metapost/context/base/mp-core.mpiv
@@ -15,6 +15,200 @@ if known context_core : endinput ; fi ;
boolean context_core ; context_core := true ;
+%D Copied to here .. not used any more.
+
+def SaveTextAreas =
+ path SavedTextAreas [] ;
+ path SavedTextColumns[] ;
+ numeric NOfSavedTextAreas ;
+ numeric NOfSavedTextColumns ;
+ for i=1 upto NOfTextAreas :
+ SavedTextAreas[i] := TextAreas[i] ;
+ endfor ;
+ for i=1 upto NOfTextColumns :
+ SavedTextColumns[i] := TextColumns[i] ;
+ endfor ;
+ NOfSavedTextAreas := NOfTextAreas ;
+ NOfSavedTextColumns := NOfTextColumns ;
+enddef ;
+
+def ResetTextAreas =
+ path TextAreas[], TextColumns[], PlainTextArea, RegionTextArea ;
+ numeric NOfTextAreas ; NOfTextAreas := 0 ;
+ numeric NOfTextColumns ; NOfTextColumns := 0 ;
+ numeric nofmultipars ; nofmultipars := 0 ;
+ TextAreas[0] := TextColumns[0] := origin -- cycle ;
+enddef ;
+
+ResetTextAreas ; SaveTextAreas ; ;
+
+def RegisterTextArea (expr x, y, w, h, d) =
+ begingroup ;
+ save p ; path p ;
+ p := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+ if NOfTextAreas>0 :
+ % if needed, concatenate areas
+ if (round(llcorner TextAreas[NOfTextAreas]) = round(ulcorner p)) and
+ (round(lrcorner TextAreas[NOfTextAreas]) = round(urcorner p)) :
+ p :=
+ ulcorner TextAreas[NOfTextAreas] --
+ urcorner TextAreas[NOfTextAreas] --
+ lrcorner p --
+ llcorner p -- cycle ;
+ else :
+ NOfTextAreas := NOfTextAreas + 1 ;
+ fi ;
+ else :
+ NOfTextAreas := NOfTextAreas + 1 ;
+ fi ;
+ TextAreas[NOfTextAreas] := p ;
+ if NOfTextColumns>0 :
+ if (round(xpart llcorner TextColumns[NOfTextColumns]) = round(xpart ulcorner p)) and
+ (round(xpart lrcorner TextColumns[NOfTextColumns]) = round(xpart urcorner p)) :
+ p :=
+ ulcorner TextColumns[NOfTextColumns] --
+ urcorner TextColumns[NOfTextColumns] --
+ lrcorner p --
+ llcorner p -- cycle ;
+ else :
+ NOfTextColumns := NOfTextColumns + 1 ;
+ fi ;
+ else :
+ NOfTextColumns := NOfTextColumns + 1 ;
+ fi ;
+ TextColumns[NOfTextColumns] := p ;
+ endgroup ;
+enddef ;
+
+%D We store a local area in slot zero.
+
+def RegisterPlainTextArea(expr x,y,w,h,d) =
+ PlainTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+enddef ;
+
+def RegisterRegionTextArea(expr x,y,w,h,d) =
+ RegionTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+ % RegionTextArea := RegionTextArea enlarged 2mm ;
+enddef ;
+
+def RegisterLocalTextArea (expr x, y, w, h, d) =
+ TextAreas[0] := TextColumns[0] := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
+enddef ;
+
+def ResetLocalTextArea =
+ TextAreas[0] := TextColumns[0] := origin -- cycle ;
+enddef ;
+
+ResetLocalTextArea ;
+
+vardef InsideTextArea (expr _i_, _xy_) =
+ (round(xpart _xy_) >= round(xpart llcorner TextAreas[_i_])) and
+ (round(xpart _xy_) <= round(xpart lrcorner TextAreas[_i_])) and
+ (round(ypart _xy_) >= round(ypart llcorner TextAreas[_i_])) and
+ (round(ypart _xy_) <= round(ypart urcorner TextAreas[_i_]))
+enddef ;
+
+vardef InsideSavedTextArea (expr _i_, _xy_) =
+ (round(xpart _xy_) >= round(xpart llcorner SavedTextAreas[_i_])) and
+ (round(xpart _xy_) <= round(xpart lrcorner SavedTextAreas[_i_])) and
+ (round(ypart _xy_) >= round(ypart llcorner SavedTextAreas[_i_])) and
+ (round(ypart _xy_) <= round(ypart urcorner SavedTextAreas[_i_]))
+enddef ;
+
+vardef InsideSomeTextArea (expr _xy_) =
+ save ok ; boolean ok ; ok := false ;
+ for i := 1 upto NOfTextAreas :
+ if InsideTextArea(i,_xy_) :
+ ok := true ; % we can move the exit here
+ fi ;
+ exitif ok ;
+ endfor ;
+ ok
+enddef ;
+
+vardef InsideSomeSavedTextArea (expr _xy_) =
+ save ok ; boolean ok ; ok := false ;
+ for i := 1 upto NOfSavedTextAreas :
+ if InsideSavedTextArea(i,_xy_) :
+ ok := true ;
+ fi ;
+ exitif ok ;
+ endfor ;
+ ok
+enddef ;
+
+vardef TextAreaX (expr x) =
+ numeric _TextAreaX_ ; _TextAreaX_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) :
+ _TextAreaX_ := xpart llcorner TextAreas[i] ;
+ fi ;
+ endfor ;
+ _TextAreaX_
+enddef ;
+
+vardef TextAreaY (expr y) =
+ numeric _TextAreaY_ ; _TextAreaY_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(y) >= round(ypart llcorner TextAreas[NOfTextAreas])) and
+ (round(y) <= round(ypart ulcorner TextAreas[NOfTextAreas])) :
+ _TextAreaY_ := ypart llcorner TextAreas[NOfTextAreas] ;
+ fi ;
+ endfor ;
+ _TextAreaY_
+enddef ;
+
+vardef TextAreaXY (expr x, y) =
+ pair _TextAreaXY_ ; _TextAreaXY_ := origin ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) and
+ (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaXY_ := llconer TextAreas[i] ;
+ fi ;
+ endfor ;
+ _TextAreaXY_
+enddef ;
+
+vardef TextAreaW (expr x) =
+ numeric _TextAreaW_ ; _TextAreaW_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) :
+ _TextAreaW_ := bbwidth(TextAreas[i]) ;
+ fi ;
+ endfor ;
+ _TextAreaW_
+enddef ;
+
+vardef TextAreaH (expr y) =
+ numeric _TextAreaH_ ; _TextAreaH_ := 0 ;
+ for i := 1 upto NOfTextAreas :
+ if (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaH_ := bbheight(TextAreas[i]) ;
+ fi ;
+ endfor ;
+ _TextAreaH_
+enddef ;
+
+vardef TextAreaWH (expr x, y) =
+ pair _TextAreaWH_ ; _TextAreaWH_ := origin ;
+ for i := 1 upto NOfTextAreas :
+ if (round(x) >= round(xpart llcorner TextAreas[i])) and
+ (round(x) <= round(xpart lrcorner TextAreas[i])) and
+ (round(y) >= round(ypart llcorner TextAreas[i])) and
+ (round(y) <= round(ypart ulcorner TextAreas[i])) :
+ _TextAreaWH_ := (bbwidth(TextAreas[i]),bbheight(TextAreas[i])) ;
+ fi ;
+ endfor ;
+ _TextAreaWH_
+enddef ;
+
+%D Till here.
+
pair lxy[], rxy[], cxy[], llxy[], lrxy[], ulxy[], urxy[] ;
path pxy[] ;
numeric hxy[], wxy[], dxy[], nxy[] ;
diff --git a/metapost/context/base/mp-crop.mpiv b/metapost/context/base/mp-crop.mpiv
new file mode 100644
index 000000000..260823e68
--- /dev/null
+++ b/metapost/context/base/mp-crop.mpiv
@@ -0,0 +1,194 @@
+%D \module
+%D [ file=mp-crop.mp,
+%D version=2011.06.23,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=Cropmarks,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+if known context_crop : endinput ; fi ;
+
+boolean context_crop ; context_crop := true ;
+
+vardef crop_marks_lines (expr box, length, offset, nx, ny) =
+ save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ;
+ p := image (
+ x := if nx = 0 : 1 else : nx - 1 fi ;
+ y := if ny = 0 : 1 else : ny - 1 fi ;
+ w := bbwidth (box) / x ;
+ h := bbheight(box) / y ;
+ for i=0 upto y :
+ draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ;
+ draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ;
+ endfor ;
+ for i=0 upto x :
+ draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ;
+ draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ;
+ endfor ;
+ ) ;
+ setbounds p to box ;
+ p
+enddef ;
+
+vardef crop_marks_cmyk =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 12.5 withcolor (1,0,0,0) ;
+ fill urcircle scaled 12.5 withcolor (0,1,0,0) ;
+ fill lrcircle scaled 12.5 withcolor (0,0,1,0) ;
+ fill llcircle scaled 12.5 withcolor (0,0,0,1) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw fullcircle scaled 12.5 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_marks_gray =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 12.5 withcolor (0.00) ;
+ fill urcircle scaled 12.5 withcolor (0.25) ;
+ fill lrcircle scaled 12.5 withcolor (0.50) ;
+ fill llcircle scaled 12.5 withcolor (0.75) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw (-6,0) -- (6,0) withcolor white ;
+ draw (0,-6) -- (0,6) withcolor white ;
+ draw fullcircle scaled 12.5 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_marks_cmykrgb =
+ save p ; picture p ; p := image (
+ fill ulcircle scaled 15 withcolor (1,0,0) ;
+ fill urcircle scaled 15 withcolor (0,1,0) ;
+ fill lrcircle scaled 15 withcolor (0,0,1) ;
+ fill llcircle scaled 15 withcolor (.5,.5,.5) ;
+ fill ulcircle scaled 10 withcolor (1,0,0,0) ;
+ fill urcircle scaled 10 withcolor (0,1,0,0) ;
+ fill lrcircle scaled 10 withcolor (0,0,1,0) ;
+ fill llcircle scaled 10 withcolor (0,0,0,1) ;
+ draw (-10,0) -- (10,0) ;
+ draw (0,-10) -- (0,10) ;
+ draw fullcircle scaled 10 ;
+ draw fullcircle scaled 15 ;
+ ) ;
+ setbounds p to fullsquare scaled 20 ;
+ p
+enddef ;
+
+vardef crop_color(expr c, h, w, dx, dy, ts) =
+ image (
+ save p ; path p ;
+ for i=1 upto 6 :
+ p := fullsquare
+ xscaled w
+ yscaled h
+ shifted (dx,dy-i*h) ;
+ fill p
+ withcolor (crop_colors[i]*c) ;
+ draw textext("\format{'@0.2f'," & decimal crop_colors[i] & "}")
+ scaled ts
+ shifted center p withcolor white ;
+ endfor ;
+ )
+enddef ;
+
+vardef crop_gray(expr c, h, w, dx, dy, ts) =
+ image (
+ save p ; path p ;
+ for i=.05 step .05 until 1 :
+ p := fullsquare
+ xscaled w
+ yscaled h
+ shifted (20*(i-1)*w+dx,dy) ;
+ fill p
+ withcolor (i*c) ;
+ draw textext("\format{'@0.2f'," & decimal i & "}")
+ scaled ts
+ shifted center p withcolor white ;
+ endfor ;
+ )
+enddef ;
+
+% draw crop_marks_cmyk shifted llcorner more ;
+% draw crop_marks_cmyk shifted lrcorner more ;
+% draw crop_marks_cmyk shifted ulcorner more ;
+% draw crop_marks_cmyk shifted urcorner more ;
+
+def page_marks_add_color(expr width, height, length, offset) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ numeric crop_colors[] ;
+ crop_colors[1] := 1 ;
+ crop_colors[2] := 0.95 ;
+ crop_colors[3] := 0.75 ;
+ crop_colors[4] := 0.50 ;
+ crop_colors[5] := 0.25 ;
+ crop_colors[6] := 0.05 ;
+
+ numeric h ; h := height / 20 ;
+ numeric w ; w := width / 20 ;
+ numeric d ; d := offset + length/2 ;
+
+ draw crop_color((1,0,0,0),h,length,xpart ulcorner page - d, 10h,length/20) ;
+ draw crop_color((0,1,0,0),h,length,xpart ulcorner page - d,3.5h,length/20) ;
+ draw crop_color((0,0,1,0),h,length,xpart ulcorner page - d, -3h,length/20) ;
+
+ draw crop_color((0,1,1,0),h,length,xpart urcorner page + d, 10h,length/20) ;
+ draw crop_color((1,0,1,0),h,length,xpart urcorner page + d,3.5h,length/20) ;
+ draw crop_color((1,1,0,0),h,length,xpart urcorner page + d, -3h,length/20) ;
+
+ draw crop_gray((0,0,0,1),length, w,-xpart llcorner page,-ypart llcorner page + d ,w/20) ;
+ draw crop_gray((1,0,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d + 1length/3,w/20) ;
+ draw crop_gray((0,1,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 0length/3,w/20) ;
+ draw crop_gray((0,0,1,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 1length/3,w/20) ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_marking(expr width, height, length, offset) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ draw crop_marks_gray shifted center(topboundary more) shifted (0, offset+length);
+ draw crop_marks_cmyk shifted center(bottomboundary more) shifted (0,-offset-length);
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_lines(expr width, height, length, offset, nx, ny) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ draw crop_marks_lines(page,length,offset,nx,ny) ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
+
+def page_marks_add_number(expr width, height, length, offset, n) = % todo: namespace
+
+ path page ; page := fullsquare xscaled width yscaled height ;
+ path more ; more := page enlarged (offset+length/2,offset+length/2) ;
+
+ for s=llcorner more, lrcorner more, ulcorner more, urcorner more :
+ draw textext(decimal n) shifted s ;
+ endfor ;
+
+ setbounds currentpicture to page ;
+
+enddef ;
diff --git a/metapost/context/base/mp-page.mpiv b/metapost/context/base/mp-page.mpiv
index ba6dcd6a5..bb8218be5 100644
--- a/metapost/context/base/mp-page.mpiv
+++ b/metapost/context/base/mp-page.mpiv
@@ -38,196 +38,6 @@ if unknown InPageBody :
InPageBody := false ;
fi ;
-def SaveTextAreas =
- path SavedTextAreas [] ;
- path SavedTextColumns[] ;
- numeric NOfSavedTextAreas ;
- numeric NOfSavedTextColumns ;
- for i=1 upto NOfTextAreas :
- SavedTextAreas[i] := TextAreas[i] ;
- endfor ;
- for i=1 upto NOfTextColumns :
- SavedTextColumns[i] := TextColumns[i] ;
- endfor ;
- NOfSavedTextAreas := NOfTextAreas ;
- NOfSavedTextColumns := NOfTextColumns ;
-enddef ;
-
-def ResetTextAreas =
- path TextAreas[], TextColumns[], PlainTextArea, RegionTextArea ;
- numeric NOfTextAreas ; NOfTextAreas := 0 ;
- numeric NOfTextColumns ; NOfTextColumns := 0 ;
- numeric nofmultipars ; nofmultipars := 0 ;
- TextAreas[0] := TextColumns[0] := origin -- cycle ;
-enddef ;
-
-ResetTextAreas ; SaveTextAreas ; ;
-
-def RegisterTextArea (expr x, y, w, h, d) =
- begingroup ;
- save p ; path p ;
- p := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
- if NOfTextAreas>0 :
- % if needed, concatenate areas
- if (round(llcorner TextAreas[NOfTextAreas]) = round(ulcorner p)) and
- (round(lrcorner TextAreas[NOfTextAreas]) = round(urcorner p)) :
- p :=
- ulcorner TextAreas[NOfTextAreas] --
- urcorner TextAreas[NOfTextAreas] --
- lrcorner p --
- llcorner p -- cycle ;
- else :
- NOfTextAreas := NOfTextAreas + 1 ;
- fi ;
- else :
- NOfTextAreas := NOfTextAreas + 1 ;
- fi ;
- TextAreas[NOfTextAreas] := p ;
- if NOfTextColumns>0 :
- if (round(xpart llcorner TextColumns[NOfTextColumns]) = round(xpart ulcorner p)) and
- (round(xpart lrcorner TextColumns[NOfTextColumns]) = round(xpart urcorner p)) :
- p :=
- ulcorner TextColumns[NOfTextColumns] --
- urcorner TextColumns[NOfTextColumns] --
- lrcorner p --
- llcorner p -- cycle ;
- else :
- NOfTextColumns := NOfTextColumns + 1 ;
- fi ;
- else :
- NOfTextColumns := NOfTextColumns + 1 ;
- fi ;
- TextColumns[NOfTextColumns] := p ;
- endgroup ;
-enddef ;
-
-%D We store a local area in slot zero.
-
-def RegisterPlainTextArea(expr x,y,w,h,d) =
- PlainTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-enddef ;
-
-def RegisterRegionTextArea(expr x,y,w,h,d) =
- RegionTextArea := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-% RegionTextArea := RegionTextArea enlarged 2mm ;
-enddef ;
-
-def RegisterLocalTextArea (expr x, y, w, h, d) =
- TextAreas[0] := TextColumns[0] := unitsquare xyscaled(w,h+d) shifted (x,y-d) ;
-enddef ;
-
-def ResetLocalTextArea =
- TextAreas[0] := TextColumns[0] := origin -- cycle ;
-enddef ;
-
-ResetLocalTextArea ;
-
-vardef InsideTextArea (expr _i_, _xy_) =
- (round(xpart _xy_) >= round(xpart llcorner TextAreas[_i_])) and
- (round(xpart _xy_) <= round(xpart lrcorner TextAreas[_i_])) and
- (round(ypart _xy_) >= round(ypart llcorner TextAreas[_i_])) and
- (round(ypart _xy_) <= round(ypart urcorner TextAreas[_i_]))
-enddef ;
-
-vardef InsideSavedTextArea (expr _i_, _xy_) =
- (round(xpart _xy_) >= round(xpart llcorner SavedTextAreas[_i_])) and
- (round(xpart _xy_) <= round(xpart lrcorner SavedTextAreas[_i_])) and
- (round(ypart _xy_) >= round(ypart llcorner SavedTextAreas[_i_])) and
- (round(ypart _xy_) <= round(ypart urcorner SavedTextAreas[_i_]))
-enddef ;
-
-vardef InsideSomeTextArea (expr _xy_) =
- save ok ; boolean ok ; ok := false ;
- for i := 1 upto NOfTextAreas :
- if InsideTextArea(i,_xy_) :
- ok := true ; % we can move the exit here
- fi ;
- exitif ok ;
- endfor ;
- ok
-enddef ;
-
-vardef InsideSomeSavedTextArea (expr _xy_) =
- save ok ; boolean ok ; ok := false ;
- for i := 1 upto NOfSavedTextAreas :
- if InsideSavedTextArea(i,_xy_) :
- ok := true ;
- fi ;
- exitif ok ;
- endfor ;
- ok
-enddef ;
-
-vardef TextAreaX (expr x) =
- numeric _TextAreaX_ ; _TextAreaX_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) :
- _TextAreaX_ := xpart llcorner TextAreas[i] ;
- fi ;
- endfor ;
- _TextAreaX_
-enddef ;
-
-vardef TextAreaY (expr y) =
- numeric _TextAreaY_ ; _TextAreaY_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(y) >= round(ypart llcorner TextAreas[NOfTextAreas])) and
- (round(y) <= round(ypart ulcorner TextAreas[NOfTextAreas])) :
- _TextAreaY_ := ypart llcorner TextAreas[NOfTextAreas] ;
- fi ;
- endfor ;
- _TextAreaY_
-enddef ;
-
-vardef TextAreaXY (expr x, y) =
- pair _TextAreaXY_ ; _TextAreaXY_ := origin ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) and
- (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaXY_ := llconer TextAreas[i] ;
- fi ;
- endfor ;
- _TextAreaXY_
-enddef ;
-
-vardef TextAreaW (expr x) =
- numeric _TextAreaW_ ; _TextAreaW_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) :
- _TextAreaW_ := bbwidth(TextAreas[i]) ;
- fi ;
- endfor ;
- _TextAreaW_
-enddef ;
-
-vardef TextAreaH (expr y) =
- numeric _TextAreaH_ ; _TextAreaH_ := 0 ;
- for i := 1 upto NOfTextAreas :
- if (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaH_ := bbheight(TextAreas[i]) ;
- fi ;
- endfor ;
- _TextAreaH_
-enddef ;
-
-vardef TextAreaWH (expr x, y) =
- pair _TextAreaWH_ ; _TextAreaWH_ := origin ;
- for i := 1 upto NOfTextAreas :
- if (round(x) >= round(xpart llcorner TextAreas[i])) and
- (round(x) <= round(xpart lrcorner TextAreas[i])) and
- (round(y) >= round(ypart llcorner TextAreas[i])) and
- (round(y) <= round(ypart ulcorner TextAreas[i])) :
- _TextAreaWH_ := (bbwidth(TextAreas[i]),bbheight(TextAreas[i])) ;
- fi ;
- endfor ;
- _TextAreaWH_
-enddef ;
-
string CurrentLayout ;
CurrentLayout := "default" ;
@@ -510,210 +320,3 @@ def Enlarged (expr p, d) =
urEnlarged (p,d) --
ulEnlarged (p,d) -- cycle)
enddef ;
-
-% New:
-
-def position_anchor_bar(expr p_b_self, p_e_self, y_b_self, y_e_self, h_b_self, d_e_self,
- distance, linewidth, linecolor) =
- StartPage ;
- path p ; p :=
- if p_b_self=p_e_self :
- (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
- (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
- elseif RealPageNumber=p_b_self :
- (xpart ulcorner Field[Text][Text],y_b_self+h_b_self) --
- (llcorner Field[Text][Text]) ;
- elseif RealPageNumber=p_e_self :
- (ulcorner Field[Text][Text]) --
- (xpart llcorner Field[Text][Text],y_e_self-d_e_self) ;
- else :
- (ulcorner Field[Text][Text]) --
- (llcorner Field[Text][Text]) ;
- fi ;
- p := p shifted (-llcorner Field[Text][Text]-(distance,0)) ;
- interim linecap := butt ;
- draw p
- withpen pencircle scaled linewidth
- withcolor linecolor ;
- StopPage ;
-enddef ;
-
-% Crop stuff
-
-vardef crop_marks_lines (expr box, length, offset, nx, ny) =
- save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ;
- p := image (
- x := if nx = 0 : 1 else : nx - 1 fi ;
- y := if ny = 0 : 1 else : ny - 1 fi ;
- w := bbwidth (box) / x ;
- h := bbheight(box) / y ;
- for i=0 upto y :
- draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ;
- draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ;
- endfor ;
- for i=0 upto x :
- draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ;
- draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ;
- endfor ;
- ) ;
- setbounds p to box ;
- p
-enddef ;
-
-vardef crop_marks_cmyk =
- save p ; picture p ; p := image (
- fill ulcircle scaled 12.5 withcolor (1,0,0,0) ;
- fill urcircle scaled 12.5 withcolor (0,1,0,0) ;
- fill lrcircle scaled 12.5 withcolor (0,0,1,0) ;
- fill llcircle scaled 12.5 withcolor (0,0,0,1) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw fullcircle scaled 12.5 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_marks_gray =
- save p ; picture p ; p := image (
- fill ulcircle scaled 12.5 withcolor (0.00) ;
- fill urcircle scaled 12.5 withcolor (0.25) ;
- fill lrcircle scaled 12.5 withcolor (0.50) ;
- fill llcircle scaled 12.5 withcolor (0.75) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw (-6,0) -- (6,0) withcolor white ;
- draw (0,-6) -- (0,6) withcolor white ;
- draw fullcircle scaled 12.5 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_marks_cmykrgb =
- save p ; picture p ; p := image (
- fill ulcircle scaled 15 withcolor (1,0,0) ;
- fill urcircle scaled 15 withcolor (0,1,0) ;
- fill lrcircle scaled 15 withcolor (0,0,1) ;
- fill llcircle scaled 15 withcolor (.5,.5,.5) ;
- fill ulcircle scaled 10 withcolor (1,0,0,0) ;
- fill urcircle scaled 10 withcolor (0,1,0,0) ;
- fill lrcircle scaled 10 withcolor (0,0,1,0) ;
- fill llcircle scaled 10 withcolor (0,0,0,1) ;
- draw (-10,0) -- (10,0) ;
- draw (0,-10) -- (0,10) ;
- draw fullcircle scaled 10 ;
- draw fullcircle scaled 15 ;
- ) ;
- setbounds p to fullsquare scaled 20 ;
- p
-enddef ;
-
-vardef crop_color(expr c, h, w, dx, dy, ts) =
- image (
- save p ; path p ;
- for i=1 upto 6 :
- p := fullsquare
- xscaled w
- yscaled h
- shifted (dx,dy-i*h) ;
- fill p
- withcolor (crop_colors[i]*c) ;
- draw textext("\format{'@0.2f'," & decimal crop_colors[i] & "}")
- scaled ts
- shifted center p withcolor white ;
- endfor ;
- )
-enddef ;
-
-vardef crop_gray(expr c, h, w, dx, dy, ts) =
- image (
- save p ; path p ;
- for i=.05 step .05 until 1 :
- p := fullsquare
- xscaled w
- yscaled h
- shifted (20*(i-1)*w+dx,dy) ;
- fill p
- withcolor (i*c) ;
- draw textext("\format{'@0.2f'," & decimal i & "}")
- scaled ts
- shifted center p withcolor white ;
- endfor ;
- )
-enddef ;
-
-% draw crop_marks_cmyk shifted llcorner more ;
-% draw crop_marks_cmyk shifted lrcorner more ;
-% draw crop_marks_cmyk shifted ulcorner more ;
-% draw crop_marks_cmyk shifted urcorner more ;
-
-def page_marks_add_color(expr width, height, length, offset) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- numeric crop_colors[] ;
- crop_colors[1] := 1 ;
- crop_colors[2] := 0.95 ;
- crop_colors[3] := 0.75 ;
- crop_colors[4] := 0.50 ;
- crop_colors[5] := 0.25 ;
- crop_colors[6] := 0.05 ;
-
- numeric h ; h := height / 20 ;
- numeric w ; w := width / 20 ;
- numeric d ; d := offset + length/2 ;
-
- draw crop_color((1,0,0,0),h,length,xpart ulcorner page - d, 10h,length/20) ;
- draw crop_color((0,1,0,0),h,length,xpart ulcorner page - d,3.5h,length/20) ;
- draw crop_color((0,0,1,0),h,length,xpart ulcorner page - d, -3h,length/20) ;
-
- draw crop_color((0,1,1,0),h,length,xpart urcorner page + d, 10h,length/20) ;
- draw crop_color((1,0,1,0),h,length,xpart urcorner page + d,3.5h,length/20) ;
- draw crop_color((1,1,0,0),h,length,xpart urcorner page + d, -3h,length/20) ;
-
- draw crop_gray((0,0,0,1),length, w,-xpart llcorner page,-ypart llcorner page + d ,w/20) ;
- draw crop_gray((1,0,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d + 1length/3,w/20) ;
- draw crop_gray((0,1,0,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 0length/3,w/20) ;
- draw crop_gray((0,0,1,0),length/3,w,-xpart llcorner page, ypart llcorner page - d - 1length/3,w/20) ;
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_marking(expr width, height, length, offset) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- draw crop_marks_gray shifted center(topboundary more) shifted (0, offset+length);
- draw crop_marks_cmyk shifted center(bottomboundary more) shifted (0,-offset-length);
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_lines(expr width, height, length, offset, nx, ny) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- draw crop_marks_lines(page,length,offset,nx,ny) ;
-
- setbounds currentpicture to page ;
-
-enddef ;
-
-def page_marks_add_number(expr width, height, length, offset, n) = % todo: namespace
-
- path page ; page := fullsquare xscaled width yscaled height ;
- path more ; more := page enlarged (offset+length/2,offset+length/2) ;
-
- for s=llcorner more, lrcorner more, ulcorner more, urcorner more :
- draw textext(decimal n) shifted s ;
- endfor ;
-
- setbounds currentpicture to page ;
-
-enddef ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index 30c8f1cd6..c66a78a2c 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -1233,7 +1233,7 @@ vardef freelabel (expr str, loc, ori) =
enddef ;
vardef freedotlabel (expr str, loc, ori) =
- interim linecap:=rounded ;
+ interim linecap := rounded ;
draw loc withpen pencircle scaled freedotlabelsize ;
draw thefreelabel(str,loc,ori) ;
enddef ;
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
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 7db14f01e..fcb7b8d83 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files 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--
<p>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 <mark> <mkmk> <mark> sequences in ligatures
+ else
+ -- KE: there can be <mark> <mkmk> <mark> 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
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index e886b982d..a7dd888ae 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files 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 <mark> <mkmk> <mark> sequences in ligatures
+ else
+ -- KE: there can be <mark> <mkmk> <mark> 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--
<p>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