diff options
26 files changed, 1553 insertions, 693 deletions
diff --git a/metapost/context/base/metafun.mp b/metapost/context/base/metafun.mp index 00011c8be..3c72356cf 100644 --- a/metapost/context/base/metafun.mp +++ b/metapost/context/base/metafun.mp @@ -1,75 +1,5 @@ -%D \module -%D [ file=metafun.mp, -%D version=2000.07.15, -%D title=\CONTEXT\ \METAPOST\ graphics, -%D subtitle=format generation file, -%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. - -%D When generating many graphics at runtime, it can save run -%D time to use a format file. We could have named this file -%D \type {context}, but this is error prone, because it forces -%D to use the progname \type {mpost} or \type {context} -%D explicitly, depending on the needs. When using the format, -%D a mismatch in the memory specification of \type {mpost} or -%D \type {context} (the \TEX\ one) could lead to lost strings -%D (and as a result in buggy boundingbox and special -%D handling). By using the name \type {metatex} we make sure -%D that we use (unless overloaded) the settings of \type -%D {mpost}. - -%D First we input John Hobby's metapost plain file. However, -%D because we want to prevent dependency problems and in the -%D end even may use a patched version, we prefer to use a -%D copy, - -if unknown ahangle : - input mp-base.mp ; % input plain.mp ; +if known mplib : + input metafun.mpiv ; else : - let dump = relax ; + input metafun.mpii ; fi ; - -input mp-tool.mp ; -input mp-spec.mp ; % will be skipped in mkiv, some day -input mp-core.mp ; -input mp-page.mp ; -input mp-text.mp ; -input mp-txts.mp ; -input mp-shap.mp ; -input mp-butt.mp ; -input mp-char.mp ; -input mp-step.mp ; -input mp-grph.mp ; -input mp-figs.mp ; - -input mp-mlib.mp ; - -if known context_mlib : input mp-chem.mp ; fi ; % only when mkiv - -% mp-form.mp ; -input mp-grid.mp ; -input mp-func.mp ; - -string metafunversion ; - -metafunversion = "metafun" & " " & - decimal year & "-" & - decimal month & "-" & - decimal day & " " & - if ((time div 60) < 10) : "0" & fi - decimal (time div 60) & ":" & - if ((time-(time div 60)*60) < 10) : "0" & fi - decimal (time-(time div 60)*60) ; - -let normalend = end ; - -def end = - ; message "" ; message metafunversion ; message "" ; normalend ; -enddef ; - -dump ; endinput . diff --git a/metapost/context/base/metafun.mpii b/metapost/context/base/metafun.mpii new file mode 100644 index 000000000..4d8dc2537 --- /dev/null +++ b/metapost/context/base/metafun.mpii @@ -0,0 +1,64 @@ +%D \module +%D [ file=metafun.mp, +%D version=2000.07.15, +%D title=\CONTEXT\ \METAPOST\ graphics, +%D subtitle=format generation file, +%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. + +%D When generating many graphics at runtime, it can save run +%D time to use a format file. We could have named this file +%D \type {context}, but this is error prone, because it forces +%D to use the progname \type {mpost} or \type {context} +%D explicitly, depending on the needs. When using the format, +%D a mismatch in the memory specification of \type {mpost} or +%D \type {context} (the \TEX\ one) could lead to lost strings +%D (and as a result in buggy boundingbox and special +%D handling). By using the name \type {metatex} we make sure +%D that we use (unless overloaded) the settings of \type +%D {mpost}. + +%D First we input John Hobby's metapost plain file. However, +%D because we want to prevent dependency problems and in the +%D end even may use a patched version, we prefer to use a +%D copy. + +input mp-base.mp ; +input mp-tool.mp ; +input mp-spec.mpii ; +input mp-core.mpii ; +input mp-page.mp ; +input mp-text.mp ; +input mp-txts.mp ; +input mp-shap.mp ; +input mp-butt.mp ; +input mp-char.mp ; +input mp-step.mp ; +input mp-grph.mp ; +input mp-figs.mp ; +input mp-grid.mp ; +input mp-func.mp ; + +string metafunversion ; + +metafunversion = "metafun ii" & " " & + decimal year & "-" & + decimal month & "-" & + decimal day & " " & + if ((time div 60) < 10) : "0" & fi + decimal (time div 60) & ":" & + if ((time-(time div 60)*60) < 10) : "0" & fi + decimal (time-(time div 60)*60) ; + +let normalend = end ; + +def end = + ; message "" ; message metafunversion ; message "" ; normalend ; +enddef ; + +dump ; endinput . diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv new file mode 100644 index 000000000..59ca2c4bd --- /dev/null +++ b/metapost/context/base/metafun.mpiv @@ -0,0 +1,53 @@ +%D \module +%D [ file=metafun.mp, +%D version=2000.07.15, +%D title=\CONTEXT\ \METAPOST\ graphics, +%D subtitle=format generation file, +%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. + +%D First we input John Hobby's metapost plain file. However, +%D because we want to prevent dependency problems and in the +%D end even may use a patched version, we prefer to use a +%D copy. + +input mp-base.mp ; +input mp-tool.mp ; +input mp-core.mpiv ; +input mp-page.mp ; +input mp-text.mp ; +input mp-txts.mp ; +input mp-shap.mp ; +input mp-butt.mp ; +input mp-char.mp ; +input mp-step.mp ; +input mp-grph.mp ; +input mp-figs.mp ; +input mp-mlib.mpiv ; +input mp-chem.mpiv ; +input mp-grid.mp ; +input mp-func.mp ; + +string metafunversion ; + +metafunversion = "metafun iv" & " " & + decimal year & "-" & + decimal month & "-" & + decimal day & " " & + if ((time div 60) < 10) : "0" & fi + decimal (time div 60) & ":" & + if ((time-(time div 60)*60) < 10) : "0" & fi + decimal (time-(time div 60)*60) ; + +let normalend = end ; + +def end = + ; message "" ; message metafunversion ; message "" ; normalend ; +enddef ; + +dump ; endinput . diff --git a/metapost/context/base/mp-chem.mp b/metapost/context/base/mp-chem.mpiv index c70dafd85..c70dafd85 100644 --- a/metapost/context/base/mp-chem.mp +++ b/metapost/context/base/mp-chem.mpiv diff --git a/metapost/context/base/mp-core.mp b/metapost/context/base/mp-core.mpii index 2ccdad22c..2ccdad22c 100644 --- a/metapost/context/base/mp-core.mp +++ b/metapost/context/base/mp-core.mpii diff --git a/metapost/context/base/mp-core.mpiv b/metapost/context/base/mp-core.mpiv new file mode 100644 index 000000000..8fc32c420 --- /dev/null +++ b/metapost/context/base/mp-core.mpiv @@ -0,0 +1,1353 @@ +if unknown context_tool : input mp-tool ; fi ; +if known context_core : endinput ; fi ; + +boolean context_core ; context_core := true ; + +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 initialize_area (expr fn,fx,fy,fw,fh,fd, + tn,tx,ty,tw,th,td) = + + numeric fpos ; fpos := 1 ; initialize_box_pos(fpos,fn,fx,fy,fw,fh,fd) ; + numeric tpos ; tpos := 2 ; initialize_box_pos(tpos,tn,tx,ty,tw,th,td) ; + + do_initialize_area (fpos, tpos) ; + +enddef ; + +def do_initialize_area (expr fpos, tpos) = + lxy := lxy[fpos] ; + llxy := (xpart llxy[fpos], ypart llxy[tpos]) ; + lrxy := lrxy[tpos] ; + urxy := (xpart urxy[tpos], ypart urxy[fpos]) ; + ulxy := ulxy[fpos] ; + wxy := xpart lrxy - xpart llxy ; + hxy := hxy[fpos] ; + dxy := dxy[tpos] ; + rxy := lxy shifted (wxy,0) ; + pxy := llxy--lrxy--urxy--ulxy--cycle ; + cxy := center pxy ; +enddef ; + +def set_par_line_height (expr ph, pd) = + par_strut_height := if ph>0 : ph elseif StrutHeight>0 : StrutHeight else : 8pt fi ; + par_strut_depth := if pd>0 : pd elseif StrutDepth >0 : StrutDepth else : 3pt fi ; + par_line_height := par_strut_height + par_strut_depth ; +enddef ; + +def initialize_par (expr fn,fx,fy,fw,fh,fd, + tn,tx,ty,tw,th,td, + mn,mx,my,mw,mh,md, + pn,px,py,pw,ph,pd, + rw,rl,rr,rh,ra,ri) = + + numeric fpos ; fpos := 1 ; initialize_box_pos(fpos,fn,fx,fy,fw,fh,fd) ; + numeric tpos ; tpos := 2 ; initialize_box_pos(tpos,tn,tx,ty,tw,th,td) ; + numeric mpos ; mpos := 3 ; initialize_box_pos(mpos,mn,mx,my,mw,mh,md) ; + numeric ppos ; ppos := 4 ; initialize_box_pos(ppos,pn,px,py,pw,ph,pd) ; + + numeric par_strut_height, par_strut_depth, par_line_height ; + + set_par_line_height (ph, pd) ; + + do_initialize_area (fpos, tpos) ; + do_initialize_par (fpos, tpos, mpos, ppos, rw,rl,rr,rh,ra,ri) ; + +enddef ; + +def initialize_area_par (expr fn,fx,fy,fw,fh,fd, + tn,tx,ty,tw,th,td, + wn,wx,wy,ww,wh,wd) = + + numeric fpos ; fpos := 1 ; initialize_box_pos(fpos,fn,fx,fy,fw,fh,fd) ; + numeric tpos ; tpos := 2 ; initialize_box_pos(tpos,tn,tx,ty,tw,th,td) ; + numeric wpos ; wpos := 3 ; initialize_box_pos(wpos,wn,wx,wy,ww,wh,wd) ; + + numeric par_strut_height, par_strut_depth, par_line_height ; + + set_par_line_height (wh, wd) ; + + numeric ffpos ; ffpos := 4 ; initialize_box_pos(ffpos,wn,wx,fy,0,wh,wd) ; + numeric ttpos ; ttpos := 5 ; initialize_box_pos(ttpos,wn,wx+ww,ty,0,wh,wd) ; + + do_initialize_area (ffpos, ttpos) ; + + numeric mpos ; mpos := 6 ; freeze_box(mpos) ; + + do_initialize_par (fpos, tpos, mpos, ffpos, 0,0,0,0,0,0) ; + +enddef ; + +def do_initialize_par (expr fpos, tpos, mpos, ppos, rw,rl,rr,rh,ra,ri) = + + pair lref, rref, pref, lhref, rhref ; + + % clip the page area to the left and right skips + + llxy[mpos] := llxy[mpos] shifted (+rl,0) ; + lrxy[mpos] := lrxy[mpos] shifted (-rr,0) ; + urxy[mpos] := urxy[mpos] shifted (-rr,0) ; + ulxy[mpos] := ulxy[mpos] shifted (+rl,0) ; + + % fixate the leftskip, rightskip and hanging indentation + + lref := (xpart llxy[mpos],ypart ulxy[ppos]) ; lhref := lref shifted (rh,0) ; + rref := (xpart lrxy[mpos],ypart urxy[ppos]) ; rhref := rref shifted (rh,0) ; + + pref := lxy[ppos] ; + + if nxy[tpos] > nxy[fpos] : + if nxy[fpos] = nxy[mpos] : + % first of multiple pages + llxy[tpos] := llxy[mpos] ; + lrxy[tpos] := lrxy[mpos] ; + urxy[tpos] := lrxy[mpos] shifted (0,par_line_height) ; + ulxy[tpos] := llxy[mpos] shifted (0,par_line_height) ; + boxgriddirection := down ; + elseif nxy[tpos] = nxy[mpos] : + % last of multiple pages + llxy[fpos] := ulxy[mpos] shifted (0,-par_line_height) ; + lrxy[fpos] := urxy[mpos] shifted (0,-par_line_height) ; + urxy[fpos] := urxy[mpos] ; + ulxy[fpos] := ulxy[mpos] ; + boxgriddirection := up ; + else : + % middle of multiple pages + llxy[fpos] := ulxy[mpos] shifted (0,-par_line_height) ; + lrxy[fpos] := urxy[mpos] shifted (0,-par_line_height) ; + urxy[fpos] := urxy[mpos] ; + ulxy[fpos] := ulxy[mpos] ; + llxy[tpos] := llxy[mpos] ; + lrxy[tpos] := lrxy[mpos] ; + urxy[tpos] := lrxy[mpos] shifted (0,par_line_height) ; + ulxy[tpos] := llxy[mpos] shifted (0,par_line_height) ; + boxgriddirection := up ; + fi ; + else : + % just one page + boxgriddirection := up ; + fi ; + + path txy, bxy, pxy, mxy ; + + txy := originpath ; % top + bxy := originpath ; % bottom + pxy := originpath ; % composed + + boolean lefthang, righthang, somehang ; + + % we only hang on the first of a multiple page background + + if nxy[mpos] > nxy[fpos] : + lefthang := righthang := somehang := false ; + else : + lefthang := (rh>0) ; righthang := (rh<0) ; somehang := false ; + fi ; + + if lefthang : + mxy := boundingbox (lref -- lref shifted (rh,ra*par_line_height)) ; + elseif righthang : + mxy := boundingbox (rref -- rref shifted (rh,ra*par_line_height)) ; + else : + mxy := originpath ; + fi ; + + if round(ypart llxy[fpos]) = round(ypart llxy[tpos]) : + + % We have a one-liner. Watch how er use the bottom pos for + % determining the height. + + llxy[fpos] := (xpart llxy[fpos], ypart llxy[tpos]) ; + ulxy[fpos] := (xpart ulxy[fpos], ypart ulxy[tpos]) ; + + else : + + % We have a multi-liner. For convenience we now correct the + % begin and end points for indentation. + + if lefthang and (round(ypart llxy[tpos]) >= round(ypart lrcorner mxy)) : + llxy[tpos] := (xpart lhref, ypart llxy[tpos]) ; + ulxy[tpos] := (xpart lhref, ypart ulxy[tpos]) ; + else : + llxy[tpos] := (xpart lref, ypart llxy[tpos]) ; + ulxy[tpos] := (xpart lref, ypart ulxy[tpos]) ; + fi ; + + if righthang and (round(ypart lrxy[fpos]) >= round(ypart llcorner mxy)) : + lrxy[fpos] := (xpart rhref, ypart lrxy[fpos]) ; + urxy[fpos] := (xpart rhref, ypart urxy[fpos]) ; + else : + lrxy[fpos] := (xpart rref, ypart lrxy[fpos]) ; + urxy[fpos] := (xpart rref, ypart urxy[fpos]) ; + fi ; + + fi ; + + somehang := (ypart ulxy[fpos]>ypart llcorner mxy) and + (ypart llxy[tpos]<ypart llcorner mxy) ; + + if round(ypart llxy[fpos]) = round(ypart llxy[tpos]) : + + % A (short) one-liner goes into the top box. + + txy := llxy[fpos] -- lrxy[tpos] -- urxy[tpos] -- ulxy[fpos] -- cycle ; + + elseif (round(ypart llxy[fpos]) = round(ypart ulxy[tpos])) and + (round(xpart lrxy[tpos]) < round(xpart llxy[fpos])) : + + % We have a sentence that spans two lines but with only end + % of line and begin of line segments. We need to take care of + % indentation. + + txy := llxy[fpos] -- lrxy[fpos] -- urxy[fpos] -- ulxy[fpos] -- cycle ; + bxy := llxy[tpos] -- lrxy[tpos] -- urxy[tpos] -- ulxy[tpos] -- cycle ; + + elseif (round(ypart llxy[fpos]) = round(ypart ulxy[tpos])) : + + % We have a sentence that spans two lines but with overlap. + + pxy := llxy[tpos] -- lrxy[tpos] -- urxy[tpos] -- lrxy[fpos] -- + urxy[fpos] -- ulxy[fpos] -- llxy[fpos] -- ulxy[tpos] -- cycle ; + + elseif lefthang and somehang : + + % We have a sentence that spans more than two lines with + % left hanging indentation. + + pxy := llxy[tpos] -- lrxy[tpos] -- urxy[tpos] -- + (xpart urxy[fpos],ypart urxy[tpos]) -- + urxy[fpos] -- ulxy[fpos] -- llxy[fpos] -- + if round(ypart urxy[tpos]) < round(ypart llcorner mxy) : + (xpart lrcorner mxy,ypart llxy[fpos]) -- + lrcorner mxy -- + (xpart llxy[tpos],ypart llcorner mxy) -- + else : + (xpart llxy[tpos],ypart llxy[fpos]) -- + fi + cycle ; + + elseif righthang and somehang : + + % We have a sentence that spans more than two lines with + % right hanging indentation. + + pxy := llxy[tpos] -- lrxy[tpos] -- urxy[tpos] -- + if round(ypart urxy[tpos]) < round(ypart llcorner mxy) : + (xpart lrcorner mxy,ypart urxy[tpos]) -- + lrcorner mxy -- llcorner mxy -- + else : + (xpart urxy[fpos],ypart urxy[tpos]) -- + fi + urxy[fpos] -- ulxy[fpos] -- llxy[fpos] -- + (xpart llxy[tpos],ypart llxy[fpos]) -- + cycle ; + + else : + + % We have a sentence that spans more than two lines with + % no hanging indentation. + + pxy := llxy[tpos] -- lrxy[tpos] -- urxy[tpos] -- + (xpart urxy[fpos],ypart urxy[tpos]) -- + urxy[fpos] -- ulxy[fpos] -- llxy[fpos] -- + (xpart llxy[tpos],ypart llxy[fpos]) -- cycle ; + + fi ; + + pxy := simplified pxy ; + pxy := unspiked pxy ; + +enddef ; + +TopSkip := 0 ; % will move +StrutHeight := 0 ; % will move + +pair last_multi_par_shift ; last_multi_par_shift := origin ; + +def relocate_multipars (expr xy) = + last_multi_par_shift := xy ; + for i=1 upto nofmultipars : + multipars[i] := multipars[i] shifted last_multi_par_shift ; + endfor ; +enddef ; + +boolean compensate_multi_par_topskip ; +boolean span_multi_column_pars ; +boolean auto_multi_par_hsize ; +boolean enable_multi_par_fallback ; + +compensate_multi_par_topskip := true ; +span_multi_column_pars := false ; +auto_multi_par_hsize := false ; % true ; +enable_multi_par_fallback := true ; + +vardef multi_par_at_top (expr i) = + (round (ypart ulcorner multipars[i]) = round (ypart ulcorner + (TextAreas[multirefs[i]] shifted last_multi_par_shift))) +enddef ; + +numeric nofmultipars ; nofmultipars := 0 ; + +boolean obey_multi_par_hang ; obey_multi_par_hang := true ; +boolean obey_multi_par_more ; obey_multi_par_more := true ; +boolean snap_multi_par_tops ; snap_multi_par_tops := true ; +boolean local_multi_par_area ; local_multi_par_area := false ; +boolean ignore_multi_par_page ; ignore_multi_par_page := false ; +boolean force_multi_par_chain ; force_multi_par_chain := true ; +boolean one_piece_multi_par ; one_piece_multi_par := false ; +boolean check_multi_par_chain ; check_multi_par_chain := true ; % extra page check + +boolean multi_column_first_page_hack; multi_column_first_page_hack := true ; % seems to work ok + +def simplify_multi_pars = % boundingbox ipv shape als optie + for i := 1 upto nofmultipars : + multipars[i] := boundingbox multipars[i] ; + endfor ; +enddef ; + +def save_multipar (expr i, l, p) = + nofmultipars := nofmultipars + 1 ; + multirefs[nofmultipars] := i ; + multilocs[nofmultipars] := l ; + multipars[nofmultipars] := unspiked (simplified p) ; +enddef ; + +def prepare_multi_pars (expr fn,fx,fy,fw,fh,fd, + tn,tx,ty,tw,th,td, + wn,wx,wy,ww,wh,wd, + pn,px,py,pw,ph,pd, + rw,rl,rr,rh,ra,ri) = + + if span_multi_column_pars : + begingroup ; + save TextAreas ; path TextAreas[] ; + save NOfTextAreas ; numeric NOfTextAreas ; + for i=1 upto NOfTextColumns : + TextAreas[i] := TextColumns[i] ; + endfor ; + NOfTextAreas := NOfTextColumns ; + fi ; + + last_multi_par_shift := origin ; + + numeric fpos ; fpos := 1 ; initialize_box_pos(fpos,fn,fx,fy,fw,fh,fd) ; + numeric tpos ; tpos := 2 ; initialize_box_pos(tpos,tn,tx,ty,tw,th,td) ; + numeric wpos ; wpos := 3 ; initialize_box_pos(wpos,wn,wx,wy,ww,wh,wd) ; + numeric ppos ; ppos := 4 ; initialize_box_pos(ppos,pn,px,py,pw,ph,pd) ; + + if local_multi_par_area : + RealPageNumber := fn ; + NOfTextAreas := 1 ; + NOfSavedTextAreas := 0 ; + TextAreas[1] := TextAreas[0] ; + TextColumns[1] := TextColumns[0] ; + nxy[fpos] := nxy[tpos] := nxy[wpos] := nxy[ppos] := RealPageNumber ; + elseif ignore_multi_par_page : + RealPageNumber := fn ; + nxy[fpos] := nxy[tpos] := nxy[wpos] := nxy[ppos] := RealPageNumber ; + fi ; + + numeric par_strut_height, par_strut_depth, par_line_height ; + + set_par_line_height (ph, pd) ; + + numeric par_hang_indent, par_hang_after, par_indent, par_left_skip, par_right_skip ; + + par_hang_indent := rh ; + par_hang_after := ra ; + par_indent := ri ; + par_left_skip := rl ; + par_right_skip := rr ; + + pair par_start_pos ; + pair par_stop_pos ; + + par_start_pos := llxy[fpos] + if par_indent <0: shifted (-par_indent, 0) fi + if par_left_skip<0: shifted (-par_left_skip,0) fi ; + par_stop_pos := lrxy[tpos] + if par_right_skip<0: shifted (par_right_skip,0) fi ; % nasty as the endpos can be shifted by rightskip + + if wxy[wpos]>0 : + left_skip := rl + xpart llxy[wpos] - xpart llxy[ppos] ; + right_skip := rw - left_skip - ww ; + else : + left_skip := rl ; + right_skip := rr ; + fi ; + + path multipar, multipars[] ; + numeric multiref, multirefs[] ; + numeric multiloc, multilocs[] ; % 1=begin 2=between 3=end + + numeric multi_par_pages ; multi_par_pages := nxy[tpos]-nxy[fpos]+1 ; + + % locals .. why can't i move these outside? + +vardef _pmp_set_multipar_ (expr i) = + ( (TextAreas[i] leftenlarged -left_skip) rightenlarged (-right_skip + if auto_multi_par_hsize : + rw - bbwidth(TextAreas[i]) fi) ) +enddef ; + +vardef _pmp_snapped_multi_pos_ (expr p) = + if snap_multi_par_tops : + if abs(ypart p - ypart ulcorner multipar) < par_line_height : + (xpart p,ypart ulcorner multipar) + else : + p + fi + else : + p + fi +enddef ; + +vardef _pmp_estimated_par_lines_ (expr h) = + round(h/par_line_height) +enddef ; + +vardef _pmp_top_multi_par_(expr p) = + (round(_pmp_estimated_par_lines_(bbheight(p)*par_line_height))=round(bbheight(p))) +enddef ; + +vardef _pmp_multi_par_tsc_(expr p) = + if _pmp_top_multi_par_(p) : TopSkipCorrection else : 0 fi +enddef ; + +vardef _pmp_estimated_multi_par_height_ (expr n, t) = + if round(par_line_height)=0 : + 0 + else : + save ok, h ; boolean ok ; + numeric h ; h := 0 ; + ok := false ; + if (nxy[fpos]=RealPageNumber-1) : + for i := 1 upto NOfSavedTextAreas : + if (InsideSavedTextArea(i,par_start_pos)) : + ok := true ; + h := h + _pmp_estimated_par_lines_(ypart ulxy[fpos] - + ypart llcorner SavedTextAreas[i]) ; + elseif ok : + h := h + _pmp_estimated_par_lines_(bbheight(SavedTextAreas[i])) ; + fi ; + endfor ; + fi ; + if ok : + for i := 1 upto n-1 : + h := h + _pmp_estimated_par_lines_(bbheight(TextAreas[i])) ; + endfor ; + else : + % already: ok := false ; + for i := 1 upto n-1 : + if (InsideTextArea(i,par_start_pos)) : + ok := true ; + h := h + _pmp_estimated_par_lines_(ypart ulxy[fpos] - ypart llcorner TextAreas[i]) ; + elseif ok : + h := h + _pmp_estimated_par_lines_(bbheight(TextAreas[i])) ; + fi ; + endfor ; + fi ; + h + fi +enddef ; + +vardef _pmp_left_top_hang_ (expr same_area) = + + par_hang_after := ra + _pmp_estimated_par_lines_(py-fy) ; + + if (par_hang_indent>0) and (par_hang_after<0) and obey_multi_par_hang : + pair _ul_ ; _ul_ := (xpart ulcorner multipar, ypart _pmp_snapped_multi_pos_(ulxy[fpos])); + pair _pa_ ; _pa_ := _ul_ shifted (0,par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart llcorner multipar)) ; + if same_area : + _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart llxy[tpos])) ; + fi ; + if obey_multi_par_more and (round(par_line_height)>0) : + par_hang_after := min(0,round(par_hang_after + + (ypart urxy[fpos]-ypart _pa_)/par_line_height)) ; + fi ; + (xpart _ul_ + par_hang_indent, ypart lrxy[fpos]) -- + (xpart _ul_ + par_hang_indent, ypart _pa_) -- + (xpart ulcorner multipar, ypart _pa_) + else : + (xpart ulcorner multipar, ypart lrxy[fpos]) + fi +enddef ; + +vardef _pmp_right_top_hang_ (expr same_area) = + + par_hang_after := ra + _pmp_estimated_par_lines_(py-fy) ; + + if (par_hang_indent<0) and (par_hang_after<0) and obey_multi_par_hang : + pair _ur_ ; _ur_ := (xpart urcorner multipar, ypart _pmp_snapped_multi_pos_(urxy[fpos])) ; + pair _pa_ ; _pa_ := _ur_ shifted (0,par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart llcorner multipar)) ; + if same_area : + _pa_ := (xpart _pa_,max(ypart _pa_ -TopSkipCorrection,ypart _pmp_snapped_multi_pos_(ulxy[tpos]))) ; + fi ; + if obey_multi_par_more and (round(par_line_height)>0) : + par_hang_after := min(0,round(par_hang_after + + (ypart urxy[fpos]-ypart _pa_)/par_line_height)) ; + fi ; + (xpart urcorner multipar, ypart _pa_) -- + (xpart _ur_ + par_hang_indent, ypart _pa_) -- + (xpart _ur_ + par_hang_indent, ypart _pmp_snapped_multi_pos_(urxy[fpos])) + else : + (xpart urcorner multipar, ypart _pmp_snapped_multi_pos_(urxy[fpos])) + fi +enddef ; + +vardef _pmp_x_left_top_hang_ (expr i, t) = + par_hang_after := min(0,ra + _pmp_estimated_multi_par_height_(i,t)) ; + if (par_hang_indent>0) and (par_hang_after<0) : + pair _ul_ ; _ul_ := ulcorner multipar ; + pair _pa_ ; _pa_ := _ul_ shifted (0,par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart llcorner multipar)) ; + if t : + _pa_ := (xpart _pa_,max(ypart _pa_,ypart llxy[tpos])); + fi ; + if abs(ypart _pa_-ypart llxy[tpos])<par_line_height : + _pa_ := (xpart _pa_,ypart llxy[tpos]); + fi ; + if abs(ypart _pa_-ypart llcorner multipar)<par_line_height : + _pa_ := (xpart _pa_,ypart llcorner multipar); + fi ; + (xpart _ul_, ypart _pa_) -- + (xpart _ul_ + par_hang_indent, ypart _pa_) -- + (xpart _ul_ + par_hang_indent, ypart _ul_) + else : + ulcorner multipar + fi +enddef ; + +vardef _pmp_x_right_top_hang_ (expr i, t) = + par_hang_after := min(0,ra + _pmp_estimated_multi_par_height_(i,t)) ; + if (par_hang_indent<0) and (par_hang_after<0) : + pair _ur_ ; _ur_ := urcorner multipar ; + pair _pa_ ; _pa_ := _ur_ shifted (0,par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart lrcorner multipar)) ; + if t : + _pa_ := (xpart _pa_,max(ypart _pa_,ypart _pmp_snapped_multi_pos_(urxy[tpos]))) ; + fi ; + (xpart _ur_ + par_hang_indent, ypart _ur_) -- + (xpart _ur_ + par_hang_indent, ypart _pa_) -- + (xpart _ur_, ypart _pa_) + else : + urcorner multipar + fi +enddef ; + +vardef _pmp_left_bottom_hang_ (expr same_area) = + pair _ll_, _sa_, _pa_ ; + _sa_ := if same_area : llxy[tpos] else : lrcorner multipar fi ; + if (par_hang_indent>0) and (par_hang_after>0) and obey_multi_par_hang : + _ll_ := (xpart ulcorner multipar, ypart _pmp_snapped_multi_pos_(ulxy[fpos])) ; + _pa_ := _ll_ shifted (0,-par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart llcorner multipar)) ; + if same_area : + _pa_ := (xpart _pa_,max(ypart _pa_,ypart _sa_)) ; + fi ; + if obey_multi_par_more and (round(par_line_height)>0) : + par_hang_after := max(0,round(par_hang_after - + (ypart urxy[fpos]-ypart _pa_)/par_line_height)) ; + fi ; + _pa_ -- + (xpart _pa_ + par_hang_indent,ypart _pa_) -- + (xpart _pa_ + par_hang_indent,ypart _sa_) + else : + (xpart llcorner multipar, ypart _sa_) + fi +enddef ; + +vardef _pmp_right_bottom_hang_ (expr same_area) = + pair _lr_, _sa_, _pa_ ; + _sa_ := if same_area : _pmp_snapped_multi_pos_(ulxy[tpos]) else : lrcorner multipar fi ; + if (par_hang_indent<0) and (par_hang_after>0) and obey_multi_par_hang : + _lr_ := (xpart urcorner multipar, ypart _pmp_snapped_multi_pos_(urxy[fpos])) ; + _pa_ := _lr_ shifted (0,-par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart lrcorner multipar)) ; + if same_area : + _pa_ := (xpart _pa_,max(ypart _pa_,ypart _pmp_snapped_multi_pos_(ulxy[tpos]))) ; + fi ; + if obey_multi_par_more and (round(par_line_height)>0) : + par_hang_after := max(0,round(par_hang_after - + (ypart urxy[fpos]-ypart _pa_)/par_line_height)) ; + fi ; + (xpart _pa_ + par_hang_indent,ypart _sa_) -- + (xpart _pa_ + par_hang_indent,ypart _pa_) -- + _pa_ + else : + (xpart lrcorner multipar, ypart _sa_) + fi +enddef ; + +vardef _pmp_x_left_bottom_hang_ (expr i, t) = + pair _ll_, _sa_, _pa_ ; + _sa_ := if t : llxy[tpos] else : llcorner multipar fi ; + if (par_hang_indent>0) and (ra>0) : + par_hang_after := max(0,ra - _pmp_estimated_multi_par_height_(i,t)) ; + _ll_ := ulcorner multipar ; + _pa_ := _ll_ shifted (0,-par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart llcorner multipar)) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart _sa_)) ; + % we need to compensate for topskip enlarged areas + if abs(ypart _pa_ - ypart _sa_) > par_line_height : + (xpart _pa_ + par_hang_indent,ypart _sa_) -- + (xpart _pa_ + par_hang_indent,ypart _pa_) -- + fi + _pa_ + else : + (xpart llcorner multipar, ypart _sa_) + fi +enddef ; + +vardef _pmp_x_right_bottom_hang_ (expr i, t) = + pair _lr_, _sa_, _pa_ ; + _sa_ := if t : _pmp_snapped_multi_pos_(ulxy[tpos]) else : llcorner multipar fi ; + if (par_hang_indent<0) and (ra>0) : + par_hang_after := max(0,ra - _pmp_estimated_multi_par_height_(i, t)) ; + _lr_ := urcorner multipar ; + _pa_ := _lr_ shifted (0,-par_hang_after*par_line_height) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart lrcorner multipar)) ; + _pa_ := (xpart _pa_,max(ypart _pa_,ypart _sa_)) ; + % we need to compensate for topskip enlarged areas + _pa_ + if abs(ypart _pa_ - ypart _sa_) > par_line_height : + -- (xpart _pa_ + par_hang_indent,ypart _pa_) + -- (xpart _pa_ + par_hang_indent,ypart _sa_) + fi + else : + (xpart lrcorner multipar, ypart _sa_) + fi +enddef ; + +% def _pmp_test_multipar_ = +% multipar := boundingbox multipar ; +% enddef ; + + % first loop + + ii := 0 ; nn := NOfTextAreas+1 ; nofmultipars := 0 ; + + if enable_multi_par_fallback and + (nxy[fpos]=RealPageNumber) and + (nxy[tpos]=RealPageNumber) and not + (InsideSomeTextArea(lxy[fpos]) and + InsideSomeTextArea(rxy[tpos])) : + + % fallback + + % multipar := + % llxy[fpos] -- + % lrxy[tpos] -- + % urxy[tpos] -- + % ulxy[fpos] -- cycle ; + % + % save_multipar (1,1,multipar) ; + + % we need to take the boundingbox because there can be + % more lines and we want a proper rectange + + multipar := + ulxy[fpos] -- + urxy[tpos] -- + lrxy[fpos] -- + llxy[tpos] -- cycle ; + + save_multipar (1,1,boundingbox(multipar)) ; + + else : + + % normal + + for i=1 upto NOfTextAreas : + + TopSkipCorrection := 0 ; + + multipar := _pmp_set_multipar_(i) ; + + % watch how we compensate for negative indentation + + if (nxy[fpos]=RealPageNumber) and (InsideTextArea(i,par_start_pos)) : + + % first one in chain + + ii := i ; + +% if (nxy[tpos]=RealPageNumber) and (InsideTextArea(i,llxy[tpos])) : + if (nxy[tpos]=RealPageNumber) and (InsideTextArea(i,par_stop_pos)) : + + % in same area + + nn := i ; + + if compensate_multi_par_topskip and (round(LineHeight-ph-pd)=0) : + + TopSkipCorrection := TopSkip - StrutHeight ; + + if round(ypart ulxy[fpos] + TopSkipCorrection) = + round(ypart ulcorner TextAreas[i]) : + ulxy[fpos] := ulxy[fpos] shifted (0,TopSkipCorrection) ; + urxy[fpos] := urxy[fpos] shifted (0,TopSkipCorrection) ; + else : + TopSkipCorrection := 0 ; + fi ; + + fi ; + + if ypart llxy[fpos] = ypart llxy[tpos] : + + multipar := + llxy[fpos] -- + lrxy[tpos] -- + %urxy[tpos] -- + _pmp_snapped_multi_pos_(urxy[tpos]) -- + %ulxy[fpos] -- + _pmp_snapped_multi_pos_(ulxy[fpos]) -- + cycle ; + + save_multipar (i,1,multipar) ; + + elseif (ypart llxy[fpos] = ypart ulxy[tpos]) and + (xpart llxy[tpos] < xpart llxy[fpos]) : + + % two loners + + multipar := if obey_multi_par_hang : + + _pmp_right_bottom_hang_(true) -- + _pmp_right_top_hang_(true) -- + _pmp_snapped_multi_pos_(urxy[fpos]) -- + lrxy[fpos] -- + + else : + + llxy[fpos] -- + (xpart urcorner multipar, ypart llxy[fpos]) -- + (xpart urcorner multipar, ypart ulxy[fpos]) -- + _pmp_snapped_multi_pos_(ulxy[fpos]) -- + + fi cycle ; + + save_multipar (i,1,multipar) ; + + multipar := _pmp_set_multipar_(i) ; + + multipar := if obey_multi_par_hang : + + _pmp_left_bottom_hang_(true) -- + llxy[tpos] -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + _pmp_left_top_hang_(true) -- + + else : + + (xpart llcorner multipar, ypart llxy[tpos]) -- + llxy[tpos] -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + (xpart llcorner multipar, ypart ulxy[tpos]) -- + + fi cycle ; + + save_multipar (i,1,multipar) ; + + else : + + multipar := if obey_multi_par_hang : + + _pmp_left_bottom_hang_(true) -- + llxy[tpos] -- + %ulxy[tpos] -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + _pmp_right_bottom_hang_(true) -- + _pmp_right_top_hang_(true) -- + %urxy[fpos] -- + _pmp_snapped_multi_pos_(urxy[fpos]) -- + lrxy[fpos] -- + _pmp_left_top_hang_(true) -- + + else : + + (xpart llcorner multipar, ypart llxy[tpos]) -- + llxy[tpos] -- + %ulxy[tpos] -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + (xpart lrcorner multipar, ypart ulxy[tpos]) -- + (xpart urcorner multipar, ypart urxy[fpos]) -- + %urxy[fpos] -- + _pmp_snapped_multi_pos_(urxy[fpos]) -- + lrxy[fpos] -- + (xpart ulcorner multipar, ypart lrxy[fpos]) -- + + fi cycle ; + + save_multipar (i,1,multipar) ; + + fi ; + + else : + + multipar := if obey_multi_par_hang : + + _pmp_left_bottom_hang_(false) -- + _pmp_right_bottom_hang_(false) -- + _pmp_right_top_hang_(false) -- + %urxy[fpos] -- + _pmp_snapped_multi_pos_(urxy[fpos]) -- + lrxy[fpos] -- + _pmp_left_top_hang_(false) -- + + else : + + llcorner multipar -- + lrcorner multipar -- + (xpart urcorner multipar, ypart urxy[fpos]) -- + %urxy[fpos] -- + _pmp_snapped_multi_pos_(urxy[fpos]) -- + lrxy[fpos] -- + (xpart ulcorner multipar, ypart lrxy[fpos]) -- + + fi cycle ; + + save_multipar (i,1,multipar) ; + + fi ; + +% elseif (nxy[tpos]=RealPageNumber) and (InsideTextArea(i,llxy[tpos])) : + elseif (nxy[tpos]=RealPageNumber) and (InsideTextArea(i,par_stop_pos)) : + + % last one in chain + + nn := i ; + + if obey_multi_par_hang and obey_multi_par_more : + + multipar := + _pmp_x_left_top_hang_(i,true) -- + _pmp_x_right_top_hang_(i,true) -- + _pmp_x_right_bottom_hang_(i,true) -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + llxy[tpos] -- + _pmp_x_left_bottom_hang_(i,true) -- + cycle ; + + else : + + multipar := + ulcorner multipar -- + urcorner multipar -- + (xpart lrcorner multipar, ypart urxy[tpos]) -- + _pmp_snapped_multi_pos_(ulxy[tpos]) -- + llxy[tpos] -- + (xpart llcorner multipar, ypart llxy[tpos]) -- + cycle ; + + fi ; + + save_multipar (i,3,multipar) ; + + elseif multi_column_first_page_hack and ((nxy[fpos]=RealPageNumber) and (nxy[tpos]>=RealPageNumber) and (NOfTextColumns>1)) : + + save_multipar (i,2,multipar) ; + + else : + % handled later + fi ; + + endfor ; + + % second loop + + if force_multi_par_chain or (ii > 1) : + + for i=ii+1 upto nn-1 : + + % rest of chain / todo : hang + +% hm, the second+ column in column sets now gets lost in a NOfTextColumns + + if (not check_multi_par_chain) or + ((nxy[fpos]<RealPageNumber) and (nxy[tpos]>RealPageNumber)) + : + + multipar := _pmp_set_multipar_(i) ; + + if obey_multi_par_hang and obey_multi_par_more : + + multipar := + _pmp_x_left_top_hang_(i,false) -- + _pmp_x_right_top_hang_(i,false) -- + _pmp_x_right_bottom_hang_(i,false) -- + _pmp_x_left_bottom_hang_(i,false) -- + cycle ; + + fi ; + + save_multipar(i,2,multipar) ; + + fi ; + + endfor ; + + fi ; + + % end of normal/fallback + +fi ; + + if span_multi_column_pars : + endgroup ; + fi ; + + % potential safeguard: + + % for i=1 upto nofmultipars : + % if length p <= 4 : + % multipars[i] := boundingbox(multipars[i]) ; + % fi ; + % end ; + + % quick hack for gb: + + one_piece_multi_par := (nofmultipars=1) and (pn=tn) ; + +enddef ; + +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 := 0pt ; +numeric boxfilloffset ; boxfilloffset := 0pt ; +numeric boxgriddistance ; boxgriddistance := .5cm ; +numeric boxgridshift ; boxgridshift := 0pt ; + +def draw_box = + draw pxy boxlineoptions withpen pencircle scaled boxlinewidth ; + draw lxy -- rxy boxlineoptions withpen pencircle scaled boxgridwidth ; +enddef ; + +def draw_par = % 1 2 3 11 12 + do_draw_par(pxy) ; do_draw_par(txy) ; do_draw_par(bxy) ; + for i = pxy, txy, bxy : + if boxgridtype = 1 : + boxgriddirection := origin ; + draw baseline_grid (i,boxgriddirection,true ) boxgridoptions ; + elseif boxgridtype = 2 : + boxgriddirection := origin ; + draw baseline_grid (i,boxgriddirection,false) boxgridoptions ; + elseif boxgridtype = 3 : + boxgriddirection := origin ; + draw baseline_grid (i,boxgriddirection,true ) boxgridoptions ; + draw baseline_grid (i,boxgriddirection,true ) + shifted (0,ExHeight) boxgridoptions ; + elseif boxgridtype = 4 : + boxgriddirection := origin ; + draw baseline_grid (i,boxgriddirection,true ) + shifted (0,ExHeight/2) boxgridoptions ; + elseif boxgridtype = 11 : + draw graphic_grid(i,boxgriddistance,boxgriddistance,boxgriddistance/2,boxgriddistance/2) ; + elseif boxgridtype = 12 : + draw graphic_grid(i,boxgriddistance,boxgriddistance,0,0) ; + fi ; + endfor ; +enddef ; + +def do_show_par (expr p, r, c) = + if length(p) > 2 : for i=0 upto length(p) : + draw fullcircle scaled r shifted point i of p + withpen pencircle scaled .5pt withcolor c ; + endfor ; fi ; + draw p withpen pencircle scaled .5pt withcolor c ; +enddef ; + +def show_par = + if length(mxy) > 2 : + draw mxy dashed evenly + withpen pencircle scaled .5pt withcolor .5white ; + fi ; + do_show_par(txy, 4pt, .5green) ; + do_show_par(bxy, 6pt, .5blue ) ; + do_show_par(pxy, 8pt, .5red ) ; + draw pref withpen pencircle scaled 2pt ; +enddef ; + +def sort_multi_pars = + if nofmultipars>1 : + begingroup ; save _p_, _n_ ; path _p_ ; numeric _n_ ; + for i := 1 upto nofmultipars : + if multilocs[i] = 3 : + _p_ := multipars[nofmultipars] ; + multipars[nofmultipars] := multipars[i] ; + multipars[i] := _p_ ; + _n_ := multirefs[nofmultipars] ; + multirefs[nofmultipars] := multirefs[i] ; + multirefs[i] := _n_ ; + _n_ := multilocs[nofmultipars] ; + multilocs[nofmultipars] := multilocs[i] ; + multilocs[i] := _n_ ; + fi ; + endfor ; + endgroup ; + fi ; +enddef ; + + +def collapse_multi_pars = + if nofmultipars>1 : + begingroup ; save _nofmultipars_ ; numeric _nofmultipars_ ; + _nofmultipars_ := 1 ; + sort_multi_pars ; % block not in order: 1, 3, 2.... + for i:=1 upto nofmultipars-1 : + if (round(xpart(llcorner multipars[i]-llcorner multipars[i+1]))=0) and + (round(xpart(lrcorner multipars[i]-lrcorner multipars[i+1]))=0) : +multilocs[_nofmultipars_] := multilocs[i+1] ; +multirefs[_nofmultipars_] := multirefs[i+1] ; + multipars[_nofmultipars_] := + ulcorner multipars[_nofmultipars_] -- + urcorner multipars[_nofmultipars_] -- + lrcorner multipars[i+1] -- + llcorner multipars[i+1] -- cycle ; + else : + _nofmultipars_ := _nofmultipars_ + 1 ; + multipars[_nofmultipars_] := multipars[i+1] ; + multilocs[_nofmultipars_] := multilocs[i+1] ; + multirefs[_nofmultipars_] := multirefs[i+1] ; + fi ; + endfor ; + nofmultipars := _nofmultipars_ ; + endgroup ; + fi ; +enddef ; + +def draw_multi_pars = + for i=1 upto nofmultipars : + do_draw_par(multipars[i]) ; + if boxgridtype= 1 : + draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up fi,true) ; + elseif boxgridtype= 2 : + draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up fi,false) ; + elseif boxgridtype= 3 : + draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up fi,true) ; + draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight) ; + elseif boxgridtype= 4 : + draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up fi,true) shifted (0,ExHeight/2) ; + elseif boxgridtype=11 : + draw graphic_grid(multipars[i],boxgriddistance,boxgriddistance,boxgriddistance/2,boxgriddistance/2) ; + elseif boxgridtype=12 : + draw graphic_grid(multipars[i],boxgriddistance,boxgriddistance,0,0) ; + fi ; + endfor ; +enddef ; + +def show_multi_pars = + for i=1 upto nofmultipars : + do_show_par(multipars[i], 6pt, .5blue) ; + endfor ; +enddef ; + +vardef do_draw_par (expr p) = + if (length p>2) and (bbwidth(p)>1) and (bbheight(p)>1) : + save pp ; path pp ; + if (boxlineradius>0) and (boxlinetype=2) : + pp := p cornered boxlineradius ; + else : + pp := p ; + fi ; + if boxfilltype>0 : + if boxfilloffset>0 : + % temporary hack + begingroup ; interim linejoin := mitered ; + filldraw pp boxfilloptions withpen pencircle scaled (2*boxfilloffset) ; + endgroup ; + else : + fill pp boxfilloptions ; + fi ; + fi ; + if boxlinetype>0 : + draw pp boxlineoptions withpen pencircle scaled boxlinewidth ; + fi ; + fi ; +enddef ; + +vardef baseline_grid (expr pxy, pdir, at_baseline) = + if (par_line_height>0) and (bbheight(pxy)>1) and (bbwidth(pxy)>1) and (boxgridwidth>0) : + save i, grid, bb ; picture grid ; pair start ; path bb ; + def _do_ (expr start) = + % 1 = normal, 2 = with background (i.e. no shine-through) + if boxdashtype = 2 : + draw start -- start shifted (bbwidth(pxy),0) + withpen pencircle scaled boxgridwidth + boxfilloptions ; + fi ; + draw start -- start shifted (bbwidth(pxy),0) + if boxdashtype > 0 : dashed evenly fi + withpen pencircle scaled boxgridwidth + boxgridoptions ; + enddef ; + 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(bbheight(pxy),par_line_height) : + _do_ (llcorner pxy shifted (0,+i)) ; + endfor ; + else : + for i = if at_baseline : par_strut_height else : 0 fi + step par_line_height + until bbheight(pxy) : + _do_ (ulcorner pxy shifted (0,-i)) ; + endfor ; + fi ; + ) ; + clip grid to pxy ; + bb := boundingbox grid ; + grid := grid shifted (0,boxgridshift) ; + setbounds grid to bb ; + grid + else : + nullpicture + fi +enddef ; + +vardef 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 anchor_box (expr n,x,y,w,h,d) = + currentpicture := currentpicture shifted (-x,-y) ; +enddef ; + +let draw_area = draw_box ; +let anchor_area = anchor_box ; +let anchor_par = anchor_box ; + + +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 ; + +endinput ; diff --git a/metapost/context/base/mp-mlib.mp b/metapost/context/base/mp-mlib.mp deleted file mode 100644 index 59028640c..000000000 --- a/metapost/context/base/mp-mlib.mp +++ /dev/null @@ -1,573 +0,0 @@ -%D \module -%D [ file=mp-mlib.mp, -%D version=2008.03.21, -%D title=\CONTEXT\ \METAPOST\ graphics, -%D subtitle=plugins, -%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 licen-en.pdf for -%C details. - -if unknown mplib : endinput ; fi ; -if known context_mlib : endinput ; fi ; - -boolean context_mlib ; context_mlib := true ; - -%D Color and transparency - -%D Standard separable blend modes -newinternal normaltransparent ; normaltransparent := 1 ; -newinternal multiplytransparent ; multiplytransparent := 2 ; -newinternal screentransparent ; screentransparent := 3 ; -newinternal overlaytransparent ; overlaytransparent := 4 ; -newinternal softlighttransparent ; softlighttransparent := 5 ; -newinternal hardlighttransparent ; hardlighttransparent := 6 ; -newinternal colordodgetransparent ; colordodgetransparent := 7 ; -newinternal colorburntransparent ; colorburntransparent := 8 ; -newinternal darkentransparent ; darkentransparent := 9 ; -newinternal lightentransparent ; lightentransparent := 10 ; -newinternal differencetransparent ; differencetransparent := 11 ; -newinternal exclusiontransparent ; exclusiontransparent := 12 ; -%D Standard nonseparable blend modes -newinternal huetransparent ; huetransparent := 13 ; -newinternal saturationtransparent ; saturationtransparent := 14 ; -newinternal colortransparent ; colortransparent := 15 ; -newinternal luminositytransparent ; luminositytransparent := 16 ; - -vardef transparency_alternative_to_number(expr name) = - if string name : - if expandafter known scantokens(name & "transparent") : - scantokens(name & "transparent") - else : - 0 - fi - elseif name < 17 : - name - else : - 0 - fi -enddef ; - -def spotcolor(expr n, v) = - 1 - withprescript "sp_name=" & n - withprescript "sp_value=" & v -enddef ; - -def multitonecolor(expr name, fractions, components, value) = - 1 - withprescript "sp_name=" & name - withprescript "sp_fractions=" & decimal fractions - withprescript "sp_components=" & components - withprescript "sp_value=" & value -enddef ; - -def transparent(expr alternative, transparency)(text c) = - 1 % this permits withcolor x intoshade y - withprescript "tr_alternative=" & decimal transparency_alternative_to_number(alternative) - withprescript "tr_transparency=" & decimal transparency - withcolor c -enddef ; - -def withtransparency(expr alternative, transparency) = - withprescript "tr_alternative=" & decimal transparency_alternative_to_number(alternative) - withprescript "tr_transparency=" & decimal transparency -enddef ; - -def cmyk(expr c, m, y, k) = - (c,m,y,k) -enddef ; - -% Texts - -numeric _tt_w_[], _tt_h_[], _tt_d_[] ; -numeric _tt_n_ ; _tt_n_ := 0 ; -picture _tt_p_ ; _tt_p_ := nullpicture ; -boolean _trial_run_ ; _trial_run_ := false ; - -def resettextexts = - _tt_n_ := 0 ; - _tt_p_ := nullpicture ; -enddef ; - -def flushtextexts = - addto currentpicture also _tt_p_ -enddef ; - -extra_endfig := "flushtextexts;" & extra_endfig; -extra_beginfig := extra_beginfig & "resettextexts;"; - -% We collect and flush them all, as we can also have temporary textexts -% that gets never really flushed but are used for calculations. So, we -% flush twice: once in location in order to pick up e.g. color properties, -% and once at the end because we need to flush missing ones. - -vardef rawtextext(expr str) = - if str = "" : - nullpicture - elseif _trial_run_ : - _tt_n_ := _tt_n_ + 1 ; - addto _tt_p_ doublepath unitsquare - withprescript "tx_number=" & decimal _tt_n_ - withprescript "tx_stage=extra" - withpostscript str ; - image ( - addto currentpicture doublepath unitsquare - withprescript "tx_number=" & decimal _tt_n_ - withprescript "tx_stage=trial" - withpostscript str - ) - else : - _tt_n_ := _tt_n_ + 1 ; - if known _tt_d_[_tt_n_] : - image ( - addto currentpicture doublepath unitsquare - xscaled _tt_w_[_tt_n_] - yscaled (_tt_h_[_tt_n_] + _tt_d_[_tt_n_]) - withprescript "tx_number=" & decimal _tt_n_ - withprescript "tx_stage=final" - ; % withpostscript str ; - ) shifted (0,-_tt_d_[_tt_n_]) - else : - image ( - addto currentpicture doublepath unitsquare ; - ) - fi - fi -enddef ; - -% More text - -pair laboff.d, laboff.dlft, laboff.drt ; % new positional suffixes -pair laboff.origin, laboff.raw ; % graph mess - -laboff.d := laboff ; labxf.d := labxf ; labyf.d := labyf ; -laboff.dlft := laboff.lft ; labxf.dlft := labxf.lft ; labyf.dlft := labyf.lft ; -laboff.drt := laboff.rt ; labxf.drt := labxf.rt ; labyf.drt := labyf.rt ; - -labtype := 0 ; labtype.lft := 1 ; labtype.rt := 2 ; -labtype.bot := 3 ; labtype.top := 4 ; labtype.ulft := 5 ; -labtype.urt := 6 ; labtype.llft := 7 ; labtype.lrt := 8 ; -labtype.d := 10 ; labtype.dlft := 11 ; labtype.drt := 12 ; -labtype.origin := 0 ; labtype.raw := 0 ; - -% laboff.origin = (infinity,infinity) ; labxf.origin := 0 ; labyf.origin := 0 ; -% laboff.raw = (infinity,infinity) ; labxf.raw := 0 ; labyf.raw := 0 ; - -% todo: thelabel.origin("xxxx",origin) (overflows) - -laboff.origin = (0,0) ; labxf.origin := 0 ; labyf.origin := 0 ; -laboff.raw = (0,0) ; labxf.raw := 0 ; labyf.raw := 0 ; - -pair laboff.l ; laboff.l = laboff.lft ; -pair laboff.r ; laboff.r = laboff.rt ; -pair laboff.b ; laboff.b = laboff.bot ; -pair laboff.t ; laboff.t = laboff.top ; -pair laboff.l_t ; laboff.l_t = laboff.ulft ; -pair laboff.r_t ; laboff.r_t = laboff.urt ; -pair laboff.l_b ; laboff.l_b = laboff.llft ; -pair laboff.r_b ; laboff.r_b = laboff.lrt ; -pair laboff.t_l ; laboff.t_l = laboff.ulft ; -pair laboff.t_r ; laboff.t_r = laboff.urt ; -pair laboff.b_l ; laboff.b_l = laboff.llft ; -pair laboff.b_r ; laboff.b_r = laboff.lrt ; - -numeric labxf.l ; labxf.l = labxf.lft ; -numeric labxf.r ; labxf.r = labxf.rt ; -numeric labxf.b ; labxf.b = labxf.bot ; -numeric labxf.t ; labxf.t = labxf.top ; -numeric labxf.l_t ; labxf.l_t = labxf.ulft ; -numeric labxf.r_t ; labxf.r_t = labxf.urt ; -numeric labxf.l_b ; labxf.l_b = labxf.llft ; -numeric labxf.r_b ; labxf.r_b = labxf.lrt ; -numeric labxf.t_l ; labxf.t_l = labxf.ulft ; -numeric labxf.t_r ; labxf.t_r = labxf.urt ; -numeric labxf.b_l ; labxf.b_l = labxf.llft ; -numeric labxf.b_r ; labxf.b_r = labxf.lrt ; - -numeric labyf.l ; labyf.l = labyf.lft ; -numeric labyf.r ; labyf.r = labyf.rt ; -numeric labyf.b ; labyf.b = labyf.bot ; -numeric labyf.t ; labyf.t = labyf.top ; -numeric labyf.l_t ; labyf.l_t = labyf.ulft ; -numeric labyf.r_t ; labyf.r_t = labyf.urt ; -numeric labyf.l_b ; labyf.l_b = labyf.llft ; -numeric labyf.r_b ; labyf.r_b = labyf.lrt ; -numeric labyf.t_l ; labyf.t_l = labyf.ulft ; -numeric labyf.t_r ; labyf.t_r = labyf.urt ; -numeric labyf.b_l ; labyf.b_l = labyf.llft ; -numeric labyf.b_r ; labyf.b_r = labyf.lrt ; - -numeric labtype.l ; labtype.l = labtype.lft ; -numeric labtype.r ; labtype.r = labtype.rt ; -numeric labtype.b ; labtype.b = labtype.bot ; -numeric labtype.t ; labtype.t = labtype.top ; -numeric labtype.l_t ; labtype.l_t = labtype.ulft ; -numeric labtype.r_t ; labtype.r_t = labtype.urt ; -numeric labtype.l_b ; labtype.l_b = labtype.llft ; -numeric labtype.r_b ; labtype.r_b = labtype.lrt ; -numeric labtype.t_l ; labtype.t_l = labtype.ulft ; -numeric labtype.t_r ; labtype.t_r = labtype.urt ; -numeric labtype.b_l ; labtype.b_l = labtype.llft ; -numeric labtype.b_r ; labtype.b_r = labtype.lrt ; - -vardef thetextext@#(expr p,z) = % adapted copy of thelabel@ - if string p : - thetextext@#(rawtextext(p),z) - else : - p - if (labtype@# >= 10) : shifted (0,ypart center p) fi - shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p)) - fi -enddef ; - -vardef textext@#(expr txt) = - interim labeloffset := textextoffset ; - if string txt : - thetextext@#(rawtextext(txt),origin) - else : - thetextext@#(txt,origin) - fi -enddef ; - -% \starttext -% \startMPpage -% numeric value ; value = 123 ; -% label.lft(decimal value,origin) ; -% draw "oeps" infont defaultfont ; -% \stopMPpage -% \stoptext - -vardef thelabel@#(expr s, z) = - save p ; picture p ; - if picture s : - p = s ; - else : - p = textext("\definedfont[" & defaultfont & "]" & s) scaled defaultscale ; - fi ; - p shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p)) -enddef; - -let normalinfont = infont ; - -primarydef str infont name = % very naughty ! - if name = "" : - textext(str) - else : - textext("\definedfont[" & name & "]" & str) - fi -enddef ; - -% Shades - -newinternal shadefactor ; shadefactor := 1 ; -pair shadeoffset ; shadeoffset := origin ; -boolean trace_shades ; trace_shades := false ; - -def set_linear_vector (suffix a,b)(expr p,n) = - if (n=1) : a := llcorner p ; b := urcorner p ; - elseif (n=2) : a := lrcorner p ; b := ulcorner p ; - elseif (n=3) : a := urcorner p ; b := llcorner p ; - elseif (n=4) : a := ulcorner p ; b := lrcorner p ; - elseif (n=5) : a := .5[ulcorner p,llcorner p] ; b := .5[urcorner p,lrcorner p] ; - elseif (n=6) : a := .5[llcorner p,lrcorner p] ; b := .5[ulcorner p,urcorner p] ; - elseif (n=7) : a := .5[lrcorner p,urcorner p] ; b := .5[llcorner p,ulcorner p] ; - elseif (n=8) : a := .5[urcorner p,ulcorner p] ; b := .5[lrcorner p,llcorner p] ; - else : a := .5[ulcorner p,llcorner p] ; b := .5[urcorner p,lrcorner p] ; - fi ; -enddef ; - -def set_circular_vector (suffix ab, r)(expr p,n) = - if (n=1) : ab := llcorner p ; - elseif (n=2) : ab := lrcorner p ; - elseif (n=3) : ab := urcorner p ; - elseif (n=4) : ab := ulcorner p ; - else : ab := center p ; r := .5r ; - fi ; -enddef ; - -def circular_shade (expr p, n, ca, cb) = - begingroup ; - save ab, r ; pair ab ; numeric r ; - r := (xpart lrcorner p - xpart llcorner p) ++ (ypart urcorner p - ypart lrcorner p) ; - set_circular_vector(ab,r)(p,n) ; - fill p withcircularshade(ab,ab,0,r,ca,cb) ; - if trace_shades : - drawarrow ab -- ab shifted (0,r) withpen pencircle scaled 1pt withcolor .5white ; - fi ; - endgroup ; -enddef ; - -def linear_shade (expr p, n, ca, cb) = - begingroup ; - save a, b, sh ; pair a, b ; - set_linear_vector(a,b)(p,n) ; - fill p withlinearshade(a,b,ca,cb) ; - if trace_shades : - drawarrow a -- b withpen pencircle scaled 1pt withcolor .5white ; - fi ; - endgroup ; -enddef ; - -def withcircularshade (expr a, b, ra, rb, ca, cb) = - withprescript "sh_type=circular" - withprescript "sh_domain=0 1" - withprescript "sh_factor=" & decimal shadefactor - withprescript "sh_color_a=" & colordecimals ca - withprescript "sh_color_b=" & colordecimals cb - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) - withprescript "sh_radius_a=" & decimal ra - withprescript "sh_radius_b=" & decimal rb -enddef ; - -def withlinearshade (expr a, b, ca, cb) = - withprescript "sh_type=linear" - withprescript "sh_domain=0 1" - withprescript "sh_factor=" & decimal shadefactor - withprescript "sh_color_a=" & colordecimals ca - withprescript "sh_color_b=" & colordecimals cb - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) -enddef ; - -string _defined_cs_pre_[] ; numeric _defined_cs_ ; _defined_cs_:= 0 ; -string prescript_separator ; prescript_separator := char(13) ; - -vardef define_circular_shade (expr a, b, ra, rb, ca, cb) = - _defined_cs_ := _defined_cs_ + 1 ; - _defined_cs_pre_ [_defined_cs_] := "sh_type=circular" - & prescript_separator & "sh_domain=0 1" - & prescript_separator & "sh_factor=" & decimal shadefactor - & prescript_separator & "sh_color_a=" & colordecimals ca - & prescript_separator & "sh_color_b=" & colordecimals cb - & prescript_separator & "sh_center_a=" & ddecimal (a shifted shadeoffset) - & prescript_separator & "sh_center_b=" & ddecimal (b shifted shadeoffset) - & prescript_separator & "sh_radius_a=" & decimal ra - & prescript_separator & "sh_radius_b=" & decimal rb - ; - _defined_cs_ -enddef ; - -vardef define_linear_shade (expr a, b, ca, cb) = - _defined_cs_ := _defined_cs_ + 1 ; - _defined_cs_pre_ [_defined_cs_] := "sh_type=linear" - & prescript_separator & "sh_domain=0 1" - & prescript_separator & "sh_factor=" & decimal shadefactor - & prescript_separator & "sh_color_a=" & colordecimals ca - & prescript_separator & "sh_color_b=" & colordecimals cb - & prescript_separator & "sh_center_a=" & ddecimal (a shifted shadeoffset) - & prescript_separator & "sh_center_b=" & ddecimal (b shifted shadeoffset) - ; - _defined_cs_ -enddef ; - -primarydef p withshade sc = - p withprescript _defined_cs_pre_[sc] -enddef ; - - -vardef define_sampled_linear_shade(expr a,b,n)(text t) = - _defined_cs_ := _defined_cs_ + 1 ; - _defined_cs_pre_ [_defined_cs_] := "ssh_type=linear" - & prescript_separator & "ssh_center_a=" & ddecimal (a shifted shadeoffset) - & prescript_separator & "ssh_center_b=" & ddecimal (b shifted shadeoffset) - & prescript_separator & "ssh_nofcolors=" & decimal n - & prescript_separator & "ssh_domain=" & domstr - & prescript_separator & "ssh_extend=" & extstr - & prescript_separator & "ssh_colors=" & colstr - & prescript_separator & "ssh_bounds=" & bndstr - & prescript_separator & "ssh_ranges=" & ranstr - ; - _defined_cs_ -enddef ; - -vardef define_sampled_circular_shade(expr a,b,ra,rb,n)(text t) = - _defined_cs_ := _defined_cs_ + 1 ; - _defined_cs_pre_ [_defined_cs_] := "ssh_type=circular" - & prescript_separator & "ssh_center_a=" & ddecimal (a shifted shadeoffset) - & prescript_separator & "ssh_radius_a=" & decimal ra - & prescript_separator & "ssh_center_b=" & ddecimal (b shifted shadeoffset) - & prescript_separator & "ssh_radius_b=" & decimal rb - & prescript_separator & "ssh_nofcolors=" & decimal n - & prescript_separator & "ssh_domain=" & domstr - & prescript_separator & "ssh_extend=" & extstr - & prescript_separator & "ssh_colors=" & colstr - & prescript_separator & "ssh_bounds=" & bndstr - & prescript_separator & "ssh_ranges=" & ranstr - ; - _defined_cs_ -enddef ; - -% vardef predefined_linear_shade (expr p, n, ca, cb) = -% save a, b, sh ; pair a, b ; -% set_linear_vector(a,b)(p,n) ; -% define_linear_shade (a,b,ca,cb) -% enddef ; -% -% vardef predefined_circular_shade (expr p, n, ca, cb) = -% save ab, r ; pair ab ; numeric r ; -% r := (xpart lrcorner p - xpart llcorner p) ++ (ypart urcorner p - ypart lrcorner p) ; -% set_circular_vector(ab,r)(p,n) ; -% define_circular_shade(ab,ab,0,r,ca,cb) -% enddef ; - -% NEW EXPERIMENTAL CODE - -def withlinearshading (expr a, b) = - withprescript "sh_type=linear" - withprescript "sh_domain=0 1" - withprescript "sh_factor=" & decimal shadefactor - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) -enddef ; - -def withcircularshading (expr a, b, ra, rb) = - withprescript "sh_type=circular" - withprescript "sh_domain=0 1" - withprescript "sh_factor=" & decimal shadefactor - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) - withprescript "sh_radius_a=" & decimal ra - withprescript "sh_radius_b=" & decimal rb -enddef ; - -def withfromshadecolor expr t = - withprescript "sh_color=into" - withprescript "sh_color_a=" & colordecimals t -enddef ; - -def withtoshadecolor expr t = - withprescript "sh_color=into" - withprescript "sh_color_b=" & colordecimals t -enddef ; - -def withshading (expr how)(text rest) = - if how = "linear" : - withlinearshading(rest) - elseif how = "circular" : - withcircularshading(rest) - else : - % nothing - fi -enddef ; - -primarydef a shadedinto b = - 1 % does not work with transparency - withprescript "sh_color=into" - withprescript "sh_color_a=" & colordecimals a - withprescript "sh_color_b=" & colordecimals b -enddef ; - -% END OF NEW - -% Graphic text (we will move code here) - -def graphictext primary t = - if _trial_run_ : - let dographictextindeed = nographictext ; - else : - let dographictextindeed = dographictext ; - fi - dographictextindeed(t) -enddef ; - -def dographictext (expr t) = - % withprescript "gt_stage=final" - begingroup ; - save figurepicture ; picture figurepicture ; - figurepicture := currentpicture ; currentpicture := nullpicture ; - currentgraphictext := currentgraphictext + 1 ; - dofinishgraphictext -enddef ; - -def nographictext (expr t) text rest = - draw unitsquare withprescript "gt_stage=trial" withpostscript t -enddef ; - -% def savegraphictext (expr str) = -% enddef ; - -% def erasegraphictextfile = -% enddef ; - -% Layers - -def onlayer primary name = - withprescript "la_name=" & name -enddef ; - - -% Figures - -% def externalfigure primary filename = -% doexternalfigure (filename) -% enddef ; -% -% def doexternalfigure (expr filename) text transformation = -% if true : % a bit incompatible esp scaled 1cm now scaled the natural size -% draw rawtextext("\externalfigure[" & filename & "]") transformation ; -% else : -% draw unitsquare transformation withprescript "fg_name=" & filename ; -% fi ; -% enddef ; - -def withmask primary filename = - withprescript "fg_mask=" & filename -enddef ; - -def externalfigure primary filename = - if false : - rawtextext("\externalfigure[" & filename & "]") - else : - image ( - addto currentpicture doublepath unitsquare - withprescript "fg_name=" & filename ; - ) -% unitsquare -% withpen pencircle scaled 0 -% withprescript "fg_name=" & filename - fi -enddef ; - -def figure primary filename = - rawtextext("\externalfigure[" & filename & "]") -enddef ; - -% Positions - -def register (expr label, width, height, offset) = - image ( - addto currentpicture doublepath unitsquare xscaled width yscaled height shifted offset - withprescript "ps_label=" & label ; - ) ; % no transformations -enddef ; - -% Housekeeping - -extra_beginfig := extra_beginfig & "currentgraphictext := 0 ; " ; -extra_endfig := extra_endfig & "finishsavingdata ; " ; -extra_endfig := extra_endfig & "resettextexts ; " ; - -boolean cmykcolors ; cmykcolors := true ; -boolean spotcolors ; spotcolors := true ; - -% Bonus - -vardef verbatim(expr str) = - ditto & "\detokenize{" & str & "}" & ditto -enddef ; - -% New - -def bitmapimage(expr xresolution, yresolution, data) = - image ( - addto currentpicture doublepath unitsquare - withprescript "bm_xresolution=" & decimal xresolution - withprescript "bm_yresolution=" & decimal yresolution - withpostscript data ; - ) -enddef ; diff --git a/metapost/context/base/mp-spec.mp b/metapost/context/base/mp-spec.mpii index 123e75faa..123e75faa 100644 --- a/metapost/context/base/mp-spec.mp +++ b/metapost/context/base/mp-spec.mpii diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index cabbadb66..3953eeea2 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -10950,12 +10950,12 @@ local relations = allocate { -- todo: handlers also here mp = { names = { "mp" }, variable = 'MPINPUTS', - suffixes = { 'mp' }, + suffixes = { 'mp', 'mpvi', 'mpiv', 'mpii' }, }, tex = { names = { "tex" }, variable = 'TEXINPUTS', - suffixes = { 'tex', "mkiv", "mkiv", "mkii" }, + suffixes = { 'tex', "mkvi", "mkiv", "mkii" }, }, icc = { names = { "icc", "icc profile", "icc profiles" }, diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index cabbadb66..3953eeea2 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -10950,12 +10950,12 @@ local relations = allocate { -- todo: handlers also here mp = { names = { "mp" }, variable = 'MPINPUTS', - suffixes = { 'mp' }, + suffixes = { 'mp', 'mpvi', 'mpiv', 'mpii' }, }, tex = { names = { "tex" }, variable = 'TEXINPUTS', - suffixes = { 'tex', "mkiv", "mkiv", "mkii" }, + suffixes = { 'tex', "mkvi", "mkiv", "mkii" }, }, icc = { names = { "icc", "icc profile", "icc profiles" }, diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index cabbadb66..3953eeea2 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -10950,12 +10950,12 @@ local relations = allocate { -- todo: handlers also here mp = { names = { "mp" }, variable = 'MPINPUTS', - suffixes = { 'mp' }, + suffixes = { 'mp', 'mpvi', 'mpiv', 'mpii' }, }, tex = { names = { "tex" }, variable = 'TEXINPUTS', - suffixes = { 'tex', "mkiv", "mkiv", "mkii" }, + suffixes = { 'tex', "mkvi", "mkiv", "mkii" }, }, icc = { names = { "icc", "icc profile", "icc profiles" }, diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index ebfd67083..f052b4ddb 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -440,8 +440,8 @@ \startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} initialize_box(\MPpos{\MPvar{self}}) ; - boxfillcolor := \MPvar{fillcolor} ; - boxlinecolor := \MPvar{linecolor} ; + def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; + def boxlineoptions = withcolor \MPvar{linecolor} enddef ; boxlinewidth := \MPvar{linewidth} ; boxfilloffset := \MPvar{filloffset} ; draw_box ; @@ -457,8 +457,8 @@ \startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth} initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ; - boxfillcolor := \MPvar{fillcolor} ; - boxlinecolor := \MPvar{linecolor} ; + def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; + def boxlineoptions = withcolor \MPvar{linecolor} enddef ; boxlinewidth := \MPvar{linewidth} ; boxfilloffset := \MPvar{filloffset} ; draw_area ; @@ -497,9 +497,9 @@ boxlinetype := \MPvar{linetype} ; boxfilltype := \MPvar{filltype} ; boxdashtype := \MPvar{dashtype} ; - boxgridcolor := \MPvar{gridcolor} ; - boxlinecolor := \MPvar{linecolor} ; - boxfillcolor := \MPvar{fillcolor} ; + 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} ; @@ -1058,13 +1058,12 @@ % these might become macros in mp-page \startuseMPgraphic{mpos:common:ec} - path pa ; pair ca ; color lc ; numeric lw ; + path pa ; pair ca ; numeric lw ; lw := \MPvar{linewidth} ; - lc := \MPvar{linecolor} ; 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 lc) ; + 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} diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index 1389eb71f..4ad564213 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -433,7 +433,7 @@ function colors.definemultitonecolor(name,multispec,colorspec,selfspec) end end -function colors.mpcolor(model,ca,ta,default) -- will move to mlib-col +local function mpcolor(model,ca,ta,default) -- will move to mlib-col local cv = colors.supported and colors.value(ca) -- faster when direct colors.values[ca] if cv then local tv = transparencies.supported and transparencies.value(ta) @@ -468,7 +468,7 @@ function colors.mpcolor(model,ca,ta,default) -- will move to mlib-col end end ---~ function colors.mpcolor(model,ca,ta,default) -- will move to mlib-col +--~ local function mpcolor(model,ca,ta,default) -- will move to mlib-col --~ local cv = colors.supported and colors.value(ca) -- faster when direct colors.values[ca] --~ if cv then --~ local tv = transparencies.supported and transparencies.value(ta) @@ -503,6 +503,13 @@ end --~ end --~ end +local function mpoptions(model,ca,ta,default) -- will move to mlib-col + return format("withcolor %s",mpcolor(model,ca,ta,default)) +end + +colors.mpcolor = mpcolor +colors.mpoptions = mpoptions + function colors.formatcolor(ca,separator) local cv = colors.value(ca) if cv then @@ -752,7 +759,7 @@ function colors.usecolors(name) } end --- interface +-- interface (todo: use locals) local setcolormodel = colors.setmodel @@ -783,7 +790,11 @@ function commands.formatcolor (...) context(colors.formatcolor function commands.formatgray (...) context(colors.formatgray (...)) end function commands.mpcolor(model,ca,ta,default) - context(colors.mpcolor(model,ca,ta,default)) + context(mpcolor(model,ca,ta,default)) +end + +function commands.mpoptions(model,ca,ta,default) + context(mpoptions(model,ca,ta,default)) end function commands.doifblackelse(a) diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 9b1f37521..80be9619c 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -669,10 +669,6 @@ \newif\ifMPcmykcolors % \MPcmykcolorsfalse \newif\ifMPspotcolors % \MPspotcolorsfalse -\ifx\MPcolor\undefined - \def\MPcolor#1{(0,0,0)} -\fi - %D For the moment we keep the next downward compatibility %D switch, i.e.\ expanded colors. However, predefined colors %D and palets are no longer expanded (which is what I wanted @@ -1022,6 +1018,7 @@ \let\colorformatseparator\space \def\MPcolor #1{\ctxcommand{mpcolor(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1})}} +\def\MPoptions #1{\ctxcommand{mpoptions(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1})}} \def\thecolorattribute #1{\number\csname(ca:\ifcsname(ca:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ca:#1)\endcsname#1\fi\fi)\endcsname} \def\thetransparencyattribute#1{\number\csname(ta:\ifcsname(ta:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ta:#1)\endcsname#1\fi\fi)\endcsname} diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index e7ca44ef5..f00ce074f 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{2011.09.05 12:54} +\newcontextversion{2011.09.05 19:28} %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 2f892eae1..d4898e038 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{2011.09.05 12:54} +\newcontextversion{2011.09.05 19:28} %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 Binary files differindex 900d76a23..574205d6f 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 81513ef96..a28dc928d 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 74a27402b..22577f103 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{2011.09.05 12:54} +\edef\contextversion{2011.09.05 19:28} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 017f29af3..896cad28b 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.09.05 12:54} +\edef\contextversion{2011.09.05 19:28} %D For those who want to use this: diff --git a/tex/context/base/data-env.lua b/tex/context/base/data-env.lua index 7d12f8d5f..2d9787b91 100644 --- a/tex/context/base/data-env.lua +++ b/tex/context/base/data-env.lua @@ -89,12 +89,12 @@ local relations = allocate { -- todo: handlers also here mp = { names = { "mp" }, variable = 'MPINPUTS', - suffixes = { 'mp' }, + suffixes = { 'mp', 'mpvi', 'mpiv', 'mpii' }, }, tex = { names = { "tex" }, variable = 'TEXINPUTS', - suffixes = { 'tex', "mkiv", "mkiv", "mkii" }, + suffixes = { 'tex', "mkvi", "mkiv", "mkii" }, }, icc = { names = { "icc", "icc profile", "icc profiles" }, diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 3dd90ab50..8034fbc32 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -937,6 +937,8 @@ local value = Cs ( ( + P(","))^1 ) +-- should be codeinjections + local function tr_process(object,prescript,before,after) -- before can be shortcut to t local tr_alternative = prescript.tr_alternative @@ -947,9 +949,12 @@ local function tr_process(object,prescript,before,after) end local cs = object.color if cs and #cs > 0 then - local sp_name = prescript.sp_name local b, a - if sp_name then + local sp_type = prescript.sp_type + if not sp_type then + b, a = colorconverter(cs) + elseif sp_type == "spot" or sp_type == "multitone" then + local sp_name = prescript.sp_name or "black" local sp_fractions = prescript.sp_fractions or 1 local sp_components = prescript.sp_components or "" local sp_value = prescript.sp_value or "1" @@ -958,14 +963,18 @@ local function tr_process(object,prescript,before,after) -- beware, we do scale the spotcolors but not the alternative representation sp_value = lpeg.match(value,sp_value,1,cf) or sp_value end - -- should be codeinjections b, a = spotcolorconverter(sp_name,sp_fractions,sp_components,sp_value) - else - -- should be codeinjections + elseif sp_type == "named" then +--~ local sp_name = prescript.sp_name or "black" +--~ local c = attributes.list[attributes.private('color')][sp_name] -- string or attribute +--~ local r = attributes.colors.registered[r] +--~ local v = attributes.colors.value(r) b, a = colorconverter(cs) end - before[#before+1] = b - after[#after+1] = a + if a and b then + before[#before+1] = b + after[#after+1] = a + end end end diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 900f466e2..f8c0456a1 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -224,7 +224,7 @@ else if not mpx then result = { status = 99, error = "out of memory"} else - result = mpx:execute(format(preamble, file.replacesuffix(name,"mp"))) + result = mpx:execute(format(preamble, file.addsuffix(name,"mp"))) end stoptiming(mplib) metapost.reporterror(result) @@ -233,14 +233,31 @@ else function metapost.checkformat(mpsinput) local mpsversion = environment.version or "unset version" - local mpsinput = file.addsuffix(mpsinput or "metafun", "mp") - report_metapost("loading '%s' (experimental metapost version two)",mpsinput) - local mpx, result = metapost.load(mpsinput) - if mpx then - return mpx + local mpsinput = mpsinput or "metafun" + local foundfile = "" + if file.suffix(mpsinput) ~= "" then + foundfile = finder(mpsinput) or "" + end + if foundfile == "" then + foundfile = finder(file.replacesuffix(mpsinput,"mpvi")) or "" + end + if foundfile == "" then + foundfile = finder(file.replacesuffix(mpsinput,"mpiv")) or "" + end + if foundfile == "" then + foundfile = finder(file.replacesuffix(mpsinput,"mp")) or "" + end + if foundfile == "" then + report_metapost("loading '%s' fails, format not found",mpsinput) else - report_metapost("error in loading '%s'",mpsinput) - metapost.reporterror(result) + report_metapost("loading '%s': %s",mpsinput,foundfile) + local mpx, result = metapost.load(foundfile) + if mpx then + return mpx + else + report_metapost("error in loading '%s'",mpsinput) + metapost.reporterror(result) + end end end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 520f214af..0571a3e77 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex ca6ebc34e..bc371c7ac 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index e493ba948..6221d92a8 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 : 09/05/11 12:54:46 +-- merge date : 09/05/11 19:28:27 do -- begin closure to overcome local limits and interference |