summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/documents/general/qrcs/setup-cs.pdfbin857586 -> 857587 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-de.pdfbin858081 -> 858090 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-en.pdfbin864656 -> 864658 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-fr.pdfbin856252 -> 856250 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-it.pdfbin861439 -> 861434 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-cs.pdfbin348071 -> 348075 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-de.pdfbin432565 -> 432578 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-en.pdfbin345871 -> 345874 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-fr.pdfbin348776 -> 348779 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-it.pdfbin347186 -> 347186 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-nl.pdfbin346588 -> 346590 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-mapping-ro.pdfbin509893 -> 509893 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-nl.pdfbin851290 -> 851293 bytes
-rw-r--r--doc/context/documents/general/qrcs/setup-ro.pdfbin855443 -> 855450 bytes
-rw-r--r--doc/context/sources/general/manuals/luatex/luatex-enhancements.tex6
-rw-r--r--metapost/context/base/mpiv/mp-bare.mpiv132
-rw-r--r--metapost/context/base/mpiv/mp-blob.mpiv241
-rw-r--r--metapost/context/base/mpiv/mp-grph.mpiv165
-rw-r--r--metapost/context/base/mpiv/mp-mlib.mpiv323
-rw-r--r--metapost/context/base/mpiv/mp-tool.mpiv8
-rw-r--r--scripts/context/lua/mtx-context.lua2
-rw-r--r--scripts/context/lua/mtxrun.lua54
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua54
-rw-r--r--scripts/context/stubs/unix/mtxrun54
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua54
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/cont-run.lua29
-rw-r--r--tex/context/base/mkiv/context.mkiv10
-rw-r--r--tex/context/base/mkiv/data-zip.lua10
-rw-r--r--tex/context/base/mkiv/font-sol.lua2
-rw-r--r--tex/context/base/mkiv/lpdf-ini.lua60
-rw-r--r--tex/context/base/mkiv/lpdf-u3d.lua12
-rw-r--r--tex/context/base/mkiv/lpdf-xmp.lua6
-rw-r--r--tex/context/base/mkiv/luat-cod.lua4
-rw-r--r--tex/context/base/mkiv/math-fbk.lua37
-rw-r--r--tex/context/base/mkiv/math-noa.lua2
-rw-r--r--tex/context/base/mkiv/meta-blb.lua89
-rw-r--r--tex/context/base/mkiv/meta-fnt.lua3
-rw-r--r--tex/context/base/mkiv/meta-ini.mkiv13
-rw-r--r--tex/context/base/mkiv/mlib-ctx.lua14
-rw-r--r--tex/context/base/mkiv/mlib-pdf.lua96
-rw-r--r--tex/context/base/mkiv/mlib-pps.lua945
-rw-r--r--tex/context/base/mkiv/mlib-run.lua41
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26047 -> 26060 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin268713 -> 269299 bytes
-rw-r--r--tex/context/base/mkiv/task-ini.lua2
-rw-r--r--tex/context/base/mkiv/util-tab.lua50
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin864656 -> 864658 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin60769 -> 60769 bytes
-rw-r--r--tex/generic/context/luatex/luatex-basics-nod.lua20
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua16
53 files changed, 857 insertions, 1703 deletions
diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf
index 295f1c3e0..71d8eb54d 100644
--- a/doc/context/documents/general/qrcs/setup-cs.pdf
+++ b/doc/context/documents/general/qrcs/setup-cs.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf
index 86af27a4a..cad5b8d43 100644
--- a/doc/context/documents/general/qrcs/setup-de.pdf
+++ b/doc/context/documents/general/qrcs/setup-de.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf
index 744cc36a9..1809a7c91 100644
--- a/doc/context/documents/general/qrcs/setup-en.pdf
+++ b/doc/context/documents/general/qrcs/setup-en.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf
index 73e9f5265..2cbd3c68b 100644
--- a/doc/context/documents/general/qrcs/setup-fr.pdf
+++ b/doc/context/documents/general/qrcs/setup-fr.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf
index eaf8559a5..6a8a1c586 100644
--- a/doc/context/documents/general/qrcs/setup-it.pdf
+++ b/doc/context/documents/general/qrcs/setup-it.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf
index dc15863ce..7f08d5350 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf
index 727dcc31f..a861f8bd0 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-de.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-de.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf
index f3502be9b..f9960640a 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-en.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-en.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf
index 448418f16..eb6995b3a 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf
index 82aa945ed..e54ce4ba9 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-it.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-it.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf
index a86f0fcf1..7acf48429 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf
index 6afd05296..c9632d1f2 100644
--- a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf
+++ b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf
index 1ef83189e..2ab474370 100644
--- a/doc/context/documents/general/qrcs/setup-nl.pdf
+++ b/doc/context/documents/general/qrcs/setup-nl.pdf
Binary files differ
diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf
index 46bded9e2..672199d15 100644
--- a/doc/context/documents/general/qrcs/setup-ro.pdf
+++ b/doc/context/documents/general/qrcs/setup-ro.pdf
Binary files differ
diff --git a/doc/context/sources/general/manuals/luatex/luatex-enhancements.tex b/doc/context/sources/general/manuals/luatex/luatex-enhancements.tex
index 0af479dc8..b81e1dbda 100644
--- a/doc/context/sources/general/manuals/luatex/luatex-enhancements.tex
+++ b/doc/context/sources/general/manuals/luatex/luatex-enhancements.tex
@@ -61,7 +61,11 @@ chapters on fonts and math we discuss a few more new ones.
There are three new primitives to test the version of \LUATEX:
\unexpanded\def\VersionHack#1% otherwise different luatex and luajittex runs
- {\cldcontext{(string.gsub(string.match("\luatexbanner","(.+)\letterpercent("),"jit",""))}}
+ {\ctxlua{%
+ local banner = "\luatexbanner"
+ local banner = string.match(banner,"(.+)\letterpercent(") or banner
+ context(string.gsub(banner ,"jit",""))%
+ }}
\starttabulate[|l|l|pl|]
\DB primitive \BC value
diff --git a/metapost/context/base/mpiv/mp-bare.mpiv b/metapost/context/base/mpiv/mp-bare.mpiv
index e995556c1..8f517b268 100644
--- a/metapost/context/base/mpiv/mp-bare.mpiv
+++ b/metapost/context/base/mpiv/mp-bare.mpiv
@@ -14,8 +14,6 @@
if known context_bare : endinput ; fi ;
boolean context_bare ; context_bare := true ;
-boolean mfun_use_one_pass ; mfun_use_one_pass := runscript("mp.print(metapost.use_one_pass)") ;
-
vardef colordecimals primary c =
if cmykcolor c :
decimal cyanpart c & ":" & decimal magentapart c & ":" & decimal yellowpart c & ":" & decimal blackpart c
@@ -26,49 +24,29 @@ vardef colordecimals primary c =
fi
enddef ;
-if mfun_use_one_pass :
-
- rgbcolor mfun_tt_r ;
- numeric mfun_tt_n ; mfun_tt_n := 0 ;
- picture mfun_tt_o ; mfun_tt_o := nullpicture ;
- picture mfun_tt_c ; mfun_tt_c := nullpicture ;
+rgbcolor mfun_tt_r ;
+numeric mfun_tt_n ; mfun_tt_n := 0 ;
+picture mfun_tt_o ; mfun_tt_o := nullpicture ;
+picture mfun_tt_c ; mfun_tt_c := nullpicture ;
- def mfun_reset_tex_texts =
- mfun_tt_n := 0 ;
- mfun_tt_o := nullpicture ; % redundant
- mfun_tt_c := nullpicture ; % redundant
- enddef ;
-
- def mfun_flush_tex_texts =
- enddef ;
+def mfun_reset_tex_texts =
+ mfun_tt_n := 0 ;
+ mfun_tt_o := nullpicture ; % redundant
+ mfun_tt_c := nullpicture ; % redundant
+enddef ;
- vardef rawtextext(expr s) =
- if s = "" :
- nullpicture
- else :
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := runscript("mp.SomeText(" & decimal mfun_tt_n & "," & ditto & s & ditto & ")") ;
- addto mfun_tt_c doublepath unitsquare
- xscaled redpart mfun_tt_r
- yscaled (greenpart mfun_tt_r + bluepart mfun_tt_r)
- shifted (0,-bluepart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
- mfun_tt_c
- fi
- enddef ;
+def mfun_flush_tex_texts =
+enddef ;
- vardef rawmadetext =
+vardef rawtextext(expr s) =
+ if s = "" :
+ nullpicture
+ else :
mfun_tt_n := mfun_tt_n + 1 ;
mfun_tt_c := nullpicture ;
mfun_tt_o := nullpicture ;
addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := runscript("mp.MadeText(" & decimal mfun_tt_n & ")") ;
+ mfun_tt_r := runscript("mp.SomeText(" & decimal mfun_tt_n & "," & ditto & s & ditto & ")") ;
addto mfun_tt_c doublepath unitsquare
xscaled redpart mfun_tt_r
yscaled (greenpart mfun_tt_r + bluepart mfun_tt_r)
@@ -78,67 +56,25 @@ if mfun_use_one_pass :
withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
;
mfun_tt_c
- enddef ;
-
-else :
-
- numeric mfun_tt_w[], mfun_tt_h[], mfun_tt_d[] ;
- numeric mfun_tt_n ; mfun_tt_n := 0 ;
- picture mfun_tt_p ; mfun_tt_p := nullpicture ;
- picture mfun_tt_o ; mfun_tt_o := nullpicture ;
- picture mfun_tt_c ; mfun_tt_c := nullpicture ;
-
- if unknown mfun_trial_run :
- boolean mfun_trial_run ;
- mfun_trial_run := false ;
- fi ;
-
- if unknown mfun_first_run :
- boolean mfun_first_run ;
- mfun_first_run := true ;
- fi ;
-
- def mfun_reset_tex_texts =
- mfun_tt_n := 0 ;
- mfun_tt_p := nullpicture ;
- mfun_tt_o := nullpicture ; % redundant
- mfun_tt_c := nullpicture ; % redundant
- enddef ;
-
- def mfun_flush_tex_texts =
- addto currentpicture also mfun_tt_p
- enddef ;
-
- vardef rawtextext(expr str) = % todo: avoid currentpicture
- if str = "" :
- nullpicture
- else :
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- if mfun_trial_run :
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- addto mfun_tt_c doublepath unitsquare
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=trial"
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- withpostscript str ;
- addto mfun_tt_p also mfun_tt_c ;
- elseif known mfun_tt_d[mfun_tt_n] :
- addto mfun_tt_c doublepath unitsquare
- xscaled mfun_tt_w[mfun_tt_n]
- yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n])
- shifted (0,-mfun_tt_d[mfun_tt_n])
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=final" ;
- else :
- addto mfun_tt_c doublepath unitsquare ; % unitpicture
- fi ;
- mfun_tt_c
- fi
- enddef ;
+ fi
+enddef ;
-fi ;
+vardef rawmadetext =
+ mfun_tt_n := mfun_tt_n + 1 ;
+ mfun_tt_c := nullpicture ;
+ mfun_tt_o := nullpicture ;
+ addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+ mfun_tt_r := runscript("mp.MadeText(" & decimal mfun_tt_n & ")") ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled redpart mfun_tt_r
+ yscaled (greenpart mfun_tt_r + bluepart mfun_tt_r)
+ shifted (0,-bluepart mfun_tt_r)
+ withprescript "mf_object=text"
+ withprescript "tx_index=" & decimal mfun_tt_n
+ withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+ ;
+ mfun_tt_c
+enddef ;
extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ;
extra_endfig := "mfun_flush_tex_texts ; mfun_reset_tex_texts ; " & extra_endfig ;
diff --git a/metapost/context/base/mpiv/mp-blob.mpiv b/metapost/context/base/mpiv/mp-blob.mpiv
index 318c78f4f..d1fc7357b 100644
--- a/metapost/context/base/mpiv/mp-blob.mpiv
+++ b/metapost/context/base/mpiv/mp-blob.mpiv
@@ -28,36 +28,17 @@ enddef ;
extra_endfig := extra_endfig & "mfun_reset_tex_blobs ; " ;
-if mfun_use_one_pass :
-
- vardef mfun_inject_blob(expr n) =
- mfun_blob_c := nullpicture ;
- mfun_blob_b := lua.mp.mf_blob_dimensions(mfun_blob_n,n) ;
- addto mfun_blob_c doublepath unitsquare
- xscaled redpart mfun_blob_b
- yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
- shifted (0,- bluepart mfun_blob_b)
- withprescript "mf_object=texblob"
- withprescript "tb_blob=" & decimal lua.mp.mf_blob_index(mfun_blob_n,n) ;
- mfun_blob_c
- enddef ;
-
-else :
-
- vardef mfun_inject_blob(expr n) =
- mfun_blob_c := nullpicture ;
- mfun_blob_b := lua.mp.mf_blob_dimensions(mfun_blob_n,n) ;
- addto mfun_blob_c doublepath unitsquare
- xscaled redpart mfun_blob_b
- yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
- shifted (0,- bluepart mfun_blob_b)
- withprescript "mf_object=texblob"
- withprescript "tb_stage=inject"
- withprescript "tb_blob=" & decimal lua.mp.mf_blob_index(mfun_blob_n,n) ;
- mfun_blob_c
- enddef ;
-
-fi ;
+vardef mfun_inject_blob(expr n) =
+ mfun_blob_c := nullpicture ;
+ mfun_blob_b := lua.mp.mf_blob_dimensions(mfun_blob_n,n) ;
+ addto mfun_blob_c doublepath unitsquare
+ xscaled redpart mfun_blob_b
+ yscaled (greenpart mfun_blob_b + bluepart mfun_blob_b)
+ shifted (0,- bluepart mfun_blob_b)
+ withprescript "mf_object=texblob"
+ withprescript "tb_blob=" & decimal lua.mp.mf_blob_index(mfun_blob_n,n) ;
+ mfun_blob_c
+enddef ;
% An example of usage:
@@ -66,144 +47,66 @@ newinternal tracingfollowtext ; tracingfollowtext := 0 ;
newinternal autoscaleupfollowtext ; autoscaleupfollowtext := 2 ;
newinternal autoscaledownfollowtext ; autoscaledownfollowtext := 0 ;
-if mfun_use_one_pass :
-
- vardef followtext(expr pth, txt) =
- image (
- mfun_blob_n := mfun_blob_n + 1 ;
- lua.mp.mf_inject_blob(mfun_blob_n,txt);
- save pat, al, at, pl, pc, wid, pos, ap, ad, pic, len, n, sc ;
- path pat ; pat := pth ;
- numeric al, at, pl, pc, wid, pos, len[], n, sc ;
- pair ap, ad ;
- picture pic[] ;
- len[0] := 0 ;
- n := lua.mp.mf_blob_size(mfun_blob_n) ;
- sc := 0 ;
- for i=1 upto n :
- pic[i] := mfun_inject_blob(i) ;
- pic[i] := pic[i] shifted - llcorner pic[i] ;
- len[i] := len[i-1] + lua.mp.mf_blob_width(mfun_blob_n,i) ;
- endfor ;
- al := arclength pth ;
- if al = 0 :
- al := len[n] ;
- pat := origin -- (al,0) ;
- fi ;
- if ((al < len[n]) and (autoscaleupfollowtext > 0)) or
- ((al > len[n]) and (autoscaledownfollowtext > 0)) :
- sc := len[n] /al ;
- pat := pat scaled sc ;
- al := arclength pat ;
- fi ;
- if followtextalternative = 1 :
- pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
- pc := 0 ;
- else : % centered / MP
- pl := 0 ;
- pc := arclength pat/2 - len[n]/2 ;
- fi ;
+vardef followtext(expr pth, txt) =
+ image (
+ mfun_blob_n := mfun_blob_n + 1 ;
+ lua.mp.mf_inject_blob(mfun_blob_n,txt);
+ save pat, al, at, pl, pc, wid, pos, ap, ad, pic, len, n, sc ;
+ path pat ; pat := pth ;
+ numeric al, at, pl, pc, wid, pos, len[], n, sc ;
+ pair ap, ad ;
+ picture pic[] ;
+ len[0] := 0 ;
+ n := lua.mp.mf_blob_size(mfun_blob_n) ;
+ sc := 0 ;
+ for i=1 upto n :
+ pic[i] := mfun_inject_blob(i) ;
+ pic[i] := pic[i] shifted - llcorner pic[i] ;
+ len[i] := len[i-1] + lua.mp.mf_blob_width(mfun_blob_n,i) ;
+ endfor ;
+ al := arclength pth ;
+ if al = 0 :
+ al := len[n] ;
+ pat := origin -- (al,0) ;
+ fi ;
+ if ((al < len[n]) and (autoscaleupfollowtext > 0)) or
+ ((al > len[n]) and (autoscaledownfollowtext > 0)) :
+ sc := len[n] /al ;
+ pat := pat scaled sc ;
+ al := arclength pat ;
+ fi ;
+ if followtextalternative = 1 :
+ pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
+ pc := 0 ;
+ else : % centered / MP
+ pl := 0 ;
+ pc := arclength pat/2 - len[n]/2 ;
+ fi ;
+ if tracingfollowtext = 1 :
+ draw pat withpen pencircle scaled 1pt withcolor blue ;
+ fi ;
+ for i=1 upto n :
+ wid := lua.mp.mf_blob_width(mfun_blob_n,i) ;
+ pos := len[i]-wid/2 + (i-1)*pl + pc ;
+ at := arctime pos of pat ;
+ ap := point at of pat ;
+ ad := direction at of pat ;
+ pic[i] := pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap ;
+ draw pic[i] ;
if tracingfollowtext = 1 :
- draw pat withpen pencircle scaled 1pt withcolor blue ;
- fi ;
- for i=1 upto n :
- wid := lua.mp.mf_blob_width(mfun_blob_n,i) ;
- pos := len[i]-wid/2 + (i-1)*pl + pc ;
- at := arctime pos of pat ;
- ap := point at of pat ;
- ad := direction at of pat ;
- pic[i] := pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap ;
- draw pic[i] ;
- if tracingfollowtext = 1 :
- draw boundingbox pic[i] withpen pencircle scaled .25pt withcolor red ;
- draw ap withpen pencircle scaled .50pt withcolor green ;
- fi ;
- endfor ;
- if ((autoscaleupfollowtext = 2) or (autoscaledownfollowtext = 2)) and
- (sc <> 0) and (sc <> 1):
- currentpicture := currentpicture scaled (1/sc) ;
+ draw boundingbox pic[i] withpen pencircle scaled .25pt withcolor red ;
+ draw ap withpen pencircle scaled .50pt withcolor green ;
fi ;
- if tracingfollowtext = 1 :
- draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ;
- fi ;
- draw fullcircle scaled 100bp
- withprescript "mf_object=followtext"
- withprescript "ft_category=" & decimal mfun_blob_n ;
- )
- enddef ;
-
-else :
-
- vardef followtext(expr pth, txt) =
- image (
- mfun_blob_n := mfun_blob_n + 1 ;
- if mfun_trial_run :
- draw fullcircle scaled 100bp
- withprescript "mf_object=followtext"
- withprescript "ft_stage=trial"
- withprescript "ft_category=" & decimal mfun_blob_n
- withpostscript txt ;
- else :
- save pat, al, at, pl, pc, wid, pos, ap, ad, pic, len, n, sc ;
- path pat ; pat := pth ;
- numeric al, at, pl, pc, wid, pos, len[], n, sc ;
- pair ap, ad ;
- picture pic[] ;
- len[0] := 0 ;
- n := lua.mp.mf_blob_size(mfun_blob_n) ;
- sc := 0 ;
- for i=1 upto n :
- pic[i] := mfun_inject_blob(i) ;
- pic[i] := pic[i] shifted - llcorner pic[i] ;
- len[i] := len[i-1] + lua.mp.mf_blob_width(mfun_blob_n,i) ;
- endfor ;
- al := arclength pth ;
- if al = 0 :
- al := len[n] ;
- pat := origin -- (al,0) ;
- fi ;
- if ((al < len[n]) and (autoscaleupfollowtext > 0)) or
- ((al > len[n]) and (autoscaledownfollowtext > 0)) :
- sc := len[n] /al ;
- pat := pat scaled sc ;
- al := arclength pat ;
- fi ;
- if followtextalternative = 1 :
- pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
- pc := 0 ;
- else : % centered / MP
- pl := 0 ;
- pc := arclength pat/2 - len[n]/2 ;
- fi ;
- if tracingfollowtext = 1 :
- draw pat withpen pencircle scaled 1pt withcolor blue ;
- fi ;
- for i=1 upto n :
- wid := lua.mp.mf_blob_width(mfun_blob_n,i) ;
- pos := len[i]-wid/2 + (i-1)*pl + pc ;
- at := arctime pos of pat ;
- ap := point at of pat ;
- ad := direction at of pat ;
- pic[i] := pic[i] shifted (-wid/2,0) rotated(angle(ad)) shifted ap ;
- draw pic[i] ;
- if tracingfollowtext = 1 :
- draw boundingbox pic[i] withpen pencircle scaled .25pt withcolor red ;
- draw ap withpen pencircle scaled .50pt withcolor green ;
- fi ;
- endfor ;
- if ((autoscaleupfollowtext = 2) or (autoscaledownfollowtext = 2)) and
- (sc <> 0) and (sc <> 1):
- currentpicture := currentpicture scaled (1/sc) ;
- fi ;
- if tracingfollowtext = 1 :
- draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ;
- fi ;
- draw fullcircle scaled 100bp
- withprescript "mf_object=followtext"
- withprescript "ft_stage=final"
- withprescript "ft_category=" & decimal mfun_blob_n ;
- fi ;
- )
- enddef ;
-
-fi ;
+ endfor ;
+ if ((autoscaleupfollowtext = 2) or (autoscaledownfollowtext = 2)) and
+ (sc <> 0) and (sc <> 1):
+ currentpicture := currentpicture scaled (1/sc) ;
+ fi ;
+ if tracingfollowtext = 1 :
+ draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ;
+ fi ;
+ draw fullcircle scaled 100bp
+ withprescript "mf_object=followtext"
+ withprescript "ft_category=" & decimal mfun_blob_n ;
+ )
+enddef ;
diff --git a/metapost/context/base/mpiv/mp-grph.mpiv b/metapost/context/base/mpiv/mp-grph.mpiv
index 2133d0ee5..3c042f83c 100644
--- a/metapost/context/base/mpiv/mp-grph.mpiv
+++ b/metapost/context/base/mpiv/mp-grph.mpiv
@@ -65,8 +65,6 @@ enddef ;
numeric currentgraphictext ; currentgraphictext := 0 ;
-def data_mpy_file = job_name & "-mpgraph.mpy" enddef ;
-
def begingraphictextfig (expr n) =
foundpicture := n ;
scratchpicture := nullpicture ;
@@ -117,7 +115,7 @@ def mfun_load_figure (expr filename) text figureattributes =
endgroup ;
enddef ;
-% shared between old and new
+% We only use the new method now.
boolean mfun_gt_color_fill ;
boolean mfun_gt_color_draw ;
@@ -126,168 +124,12 @@ boolean mfun_gt_reverse_fill ;
boolean mfun_gt_outline_fill ;
picture mfun_gt_picture ;
-% this is the old version:
-
-if mfun_use_one_pass :
-
- def old_graphictext primary t =
- mfun_do_graphic_text(t)
- enddef ;
-
- def mfun_do_graphic_text (expr t) =
- begingroup ;
- save figurepicture ; picture figurepicture ;
- figurepicture := currentpicture ; currentpicture := nullpicture ;
- currentgraphictext := currentgraphictext + 1 ;
- lua.mp.mf_graphic_text(currentgraphictext,t) ;
- mfun_finish_graphic_text % picks up directives
- enddef ;
-
-else :
-
- def old_graphictext primary t =
- hide (
- if mfun_trial_run :
- let mfun_graphic_text = mfun_no_graphic_text ;
- else :
- let mfun_graphic_text = mfun_do_graphic_text ;
- fi
- )
- mfun_graphic_text(t)
- enddef ;
-
- def mfun_do_graphic_text (expr t) =
- % withprescript "gt_stage=final"
- begingroup ;
- save figurepicture ; picture figurepicture ;
- figurepicture := currentpicture ; currentpicture := nullpicture ;
- currentgraphictext := currentgraphictext + 1 ;
- mfun_finish_graphic_text % picks up directives
- enddef ;
-
- def mfun_no_graphic_text (expr t) text rest =
- currentgraphictext := currentgraphictext + 1 ;
- draw unitsquare
- withprescript "mf_object=graphictext"
- withprescript "gt_stage=trial"
- withprescript "gt_index=" & decimal currentgraphictext
- withpostscript t
- enddef ;
-
-fi ;
-
-def mfun_finish_graphic_text text rest =
- protectgraphicmacros ; % resets currentpicture
- interim linecap := butt ; % normally rounded
- interim linejoin := mitered ; % normally rounded
- interim miterlimit := 10 ; % todo
- let normalwithshade = withshade ;
- save foundpicture, scratchpicture, str ;
- save fill, draw, withshade, reversefill, outlinefill ;
- save withfillcolor, withdrawcolor ; % quite important
- numeric foundpicture ; picture scratchpicture ; string str ;
- def draw expr p =
- % the first, naive implementation was:
- % addto scratchpicture doublepath p withpen currentpen ;
- % but it is better to turn lines into fills
- addto scratchpicture contour boundingbox
- image (addto currentpicture doublepath p withpen currentpen) ;
- enddef ;
- def fill expr p =
- addto scratchpicture contour p withpen currentpen ;
- enddef ;
- def mfun_gt_fill = enddef ; boolean mfun_gt_color_fill ; mfun_gt_color_fill := false ;
- def mfun_gt_draw = enddef ; boolean mfun_gt_color_draw ; mfun_gt_color_draw := false ;
- def mfun_gt_shade = enddef ; boolean mfun_gt_shade_fill ; mfun_gt_shade_fill := false ;
- boolean mfun_gt_reverse_fill ; mfun_gt_reverse_fill := false ;
- boolean mfun_gt_outline_fill ; mfun_gt_outline_fill := false ;
- def reversefill =
- hide(mfun_gt_reverse_fill := true )
- enddef ;
- def outlinefill =
- hide(mfun_gt_outline_fill := true )
- enddef ;
- def withshade primary c =
- hide(def mfun_gt_shade = normalwithshade c enddef ; mfun_gt_shade_fill := true )
- enddef ;
- def withfillcolor primary c =
- hide(def mfun_gt_fill = withcolor c enddef ; mfun_gt_color_fill := true )
- enddef ;
- def withdrawcolor primary c =
- hide(def mfun_gt_draw = withcolor c enddef ; mfun_gt_color_draw := true )
- enddef ;
- scratchpicture := nullpicture ;
- addto scratchpicture doublepath origin rest ; % pre-roll
- for i within scratchpicture : % Below here is a dirty tricky test!
- if (urcorner dashpart i) = origin :
- mfun_gt_outline_fill := false ;
- fi ;
- endfor ;
- scratchpicture := nullpicture ;
- readfile(data_mpy_file) ;
- scratchpicture := (scratchpicture shifted -llcorner scratchpicture) scaled (1/10) ;
- if not mfun_gt_color_draw and not mfun_gt_color_fill :
- mfun_gt_color_draw := true ;
- fi
- if mfun_gt_shade_fill :
- mfun_gt_color_draw := false ;
- mfun_gt_color_fill := false ;
- fi ;
- currentpicture := figurepicture ;
- if mfun_gt_shade_fill :
- for i within scratchpicture :
- if filled i :
- addto currentpicture contour pathpart i _op_ rest mfun_gt_shade ;
- fi ;
- endfor ;
- else :
- if mfun_gt_color_draw and not mfun_gt_reverse_fill :
- for i within scratchpicture :
- if mfun_gt_color_fill and mfun_gt_outline_fill :
- addto currentpicture doublepath pathpart i _op_ rest mfun_gt_fill dashed nullpicture ;
- fi ;
- if filled i :
- addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
- fi ;
- endfor ;
- fi ;
- if mfun_gt_color_fill :
- for i within scratchpicture :
- if filled i :
- addto currentpicture contour pathpart i _op_ rest mfun_gt_fill withpen pencircle scaled 0 ;
- fi ;
- endfor ;
- fi ;
- if mfun_gt_color_draw and mfun_gt_reverse_fill :
- for i within scratchpicture :
- if filled i :
- addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
- fi ;
- endfor ;
- fi ;
- for i within scratchpicture :
- if stroked i :
- addto currentpicture doublepath pathpart i _op_ rest mfun_gt_draw ;
- fi ;
- endfor ;
- fi ;
- endgroup ;
-enddef ;
-
-% and this is the new one:
-
-% boolean mfun_gt_color_fill ;
-% boolean mfun_gt_color_draw ;
-% boolean mfun_gt_shade_fill ;
-% boolean mfun_gt_reverse_fill ;
-% picture mfun_gt_picture ;
-
def mfun_gt_default = % somewhat compatible
scaled 11.5
withpen pencircle scaled .1
enddef ;
-def new_graphictext primary t = % use outlinetext instead
+def graphictext primary t = % use outlinetext instead
begingroup ;
mfun_graphic_text_indeed(t)
enddef ;
@@ -345,9 +187,6 @@ def mfun_graphic_text_indeed(expr t) text rest =
endgroup ;
enddef ;
-let graphictext = old_graphictext ;
-%%% graphictext = new_graphictext ; % more than 10 times faster
-
% example
%
% beginfig (1) ;
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv
index f9f5e3877..131796757 100644
--- a/metapost/context/base/mpiv/mp-mlib.mpiv
+++ b/metapost/context/base/mpiv/mp-mlib.mpiv
@@ -18,8 +18,6 @@ boolean context_mlib ; context_mlib := true ;
numeric LUATEXFUNCTIONALITY ; LUATEXFUNCTIONALITY := runscript("mp.print(LUATEXFUNCTIONALITY)") ;
-boolean mfun_use_one_pass ; mfun_use_one_pass := runscript("mp.print(metapost.use_one_pass)") ;
-
%D Objects:
vardef isobject expr p =
@@ -194,39 +192,19 @@ boolean mfun_onetime_textext ; mfun_onetime_textext := false ;
def notcached = withprescript "tx_cache=no" enddef ;
-if mfun_use_one_pass :
-
- % todo: onetime
-
- rgbcolor mfun_tt_r ;
+% todo: onetime
- vardef rawtextext(expr s) =
- if s = "" :
- nullpicture
- else :
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_some_text(mfun_tt_n,s) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
- shifted (0,-dppart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
- mfun_tt_c
- fi
- enddef ;
+rgbcolor mfun_tt_r ;
- vardef rawmadetext =
+vardef rawtextext(expr s) =
+ if s = "" :
+ nullpicture
+ else :
mfun_tt_n := mfun_tt_n + 1 ;
mfun_tt_c := nullpicture ;
mfun_tt_o := nullpicture ;
addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_made_text(mfun_tt_n) ;
+ mfun_tt_r := lua.mp.mf_some_text(mfun_tt_n,s) ;
addto mfun_tt_c doublepath unitsquare
xscaled wdpart mfun_tt_r
yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
@@ -236,46 +214,25 @@ if mfun_use_one_pass :
withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
;
mfun_tt_c
- enddef ;
-
-else :
-
- vardef rawtextext(expr s) = % todo: avoid currentpicture
- if s = "" :
- mfun_onetime_textext := false ;
- nullpicture
- else :
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- if mfun_trial_run :
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- addto mfun_tt_c doublepath unitsquare
- withprescript "mf_object=text"
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=trial"
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- withpostscript s ;
- if not mfun_onetime_textext :
- addto mfun_tt_p also mfun_tt_c
- withprescript "tx_global=yes" ;
- fi ;
- else :
- mfun_tt_b := lua.mp.mf_tt_dimensions(mfun_tt_n) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_b
- yscaled (htpart mfun_tt_b + dppart mfun_tt_b)
- shifted (0,- dppart mfun_tt_b)
- withprescript "mf_object=text"
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=final" ;
- fi ;
- mfun_onetime_textext := false ;
- mfun_tt_c
- fi
- enddef ;
+ fi
+enddef ;
-fi ;
+vardef rawmadetext =
+ mfun_tt_n := mfun_tt_n + 1 ;
+ mfun_tt_c := nullpicture ;
+ mfun_tt_o := nullpicture ;
+ addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+ mfun_tt_r := lua.mp.mf_made_text(mfun_tt_n) ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled wdpart mfun_tt_r
+ yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
+ shifted (0,-dppart mfun_tt_r)
+ withprescript "mf_object=text"
+ withprescript "tx_index=" & decimal mfun_tt_n
+ withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+ ;
+ mfun_tt_c
+enddef ;
vardef validtexbox(expr category, name) =
if category == "" :
@@ -504,75 +461,25 @@ enddef ;
pair mfun_tt_z ;
-if mfun_use_one_pass :
-
- vardef rawfmttext(text t) =
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- mfun_tt_r := lua.mp.mf_formatted_text(mfun_tt_n,t) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
- shifted (0,-dppart mfun_tt_r)
- withprescript "mf_object=text"
- withprescript "tx_index=" & decimal mfun_tt_n
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- ;
- for s = t :
- if pair s : mfun_tt_z := s ; fi
- endfor ;
- mfun_tt_c
- enddef ;
-
-else :
-
- vardef rawfmttext(text t) = % todo: avoid currentpicture
- mfun_tt_n := mfun_tt_n + 1 ;
- mfun_tt_c := nullpicture ;
- if mfun_trial_run :
- mfun_tt_o := nullpicture ;
- addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
- addto mfun_tt_c doublepath unitsquare
- withprescript "mf_object=text"
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=trial"
- withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
- % begin of fmt specific
- withprescript "tx_type=format"
- for s = t :
- if string s : withpostscript "s:" & s
- elseif numeric s : withpostscript "n:" & decimal s
- elseif boolean s : withpostscript "b:" & if s : "true" else : "false" fi
- elseif pair s : hide(mfun_tt_z := s ; )
- fi
- endfor ;
- % end of fmt specific
- if not mfun_onetime_textext :
- addto mfun_tt_p also mfun_tt_c
- withprescript "tx_global=yes" ;
- fi ;
- else :
- mfun_tt_b := lua.mp.mf_tt_dimensions(mfun_tt_n) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_b
- yscaled (htpart mfun_tt_b + dppart mfun_tt_b)
- shifted (0,- dppart mfun_tt_b)
- withprescript "mf_object=text"
- withprescript "tx_number=" & decimal mfun_tt_n
- withprescript "tx_stage=final" ;
- % begin of fmt specific
- for s = t :
- if pair s : mfun_tt_z := s ; fi
- endfor ;
- % end of fmt specific
- fi ;
- mfun_onetime_textext := false ;
- mfun_tt_c
- enddef ;
-
-fi ;
+vardef rawfmttext(text t) =
+ mfun_tt_n := mfun_tt_n + 1 ;
+ mfun_tt_c := nullpicture ;
+ mfun_tt_o := nullpicture ;
+ addto mfun_tt_o doublepath origin _op_ ; % save drawoptions
+ mfun_tt_r := lua.mp.mf_formatted_text(mfun_tt_n,t) ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled wdpart mfun_tt_r
+ yscaled (htpart mfun_tt_r + dppart mfun_tt_r)
+ shifted (0,-dppart mfun_tt_r)
+ withprescript "mf_object=text"
+ withprescript "tx_index=" & decimal mfun_tt_n
+ withprescript "tx_color=" & colordecimals colorpart mfun_tt_o
+ ;
+ for s = t :
+ if pair s : mfun_tt_z := s ; fi
+ endfor ;
+ mfun_tt_c
+enddef ;
vardef thefmttext@#(text t) =
mfun_tt_z := origin ; % initialization
@@ -1113,38 +1020,17 @@ def withmask primary filename =
withprescript "fg_mask=" & filename
enddef ;
-if mfun_use_one_pass :
-
- vardef externalfigure primary filename =
- mfun_tt_c := nullpicture ;
- mfun_tt_r := lua.mp.mf_external_figure(filename) ;
- addto mfun_tt_c doublepath unitsquare
- xscaled wdpart mfun_tt_r
- yscaled htpart mfun_tt_r
- withprescript "mf_object=figure"
- withprescript "fg_name=" & filename ;
- ;
- mfun_tt_c
- enddef ;
-
-else :
-
- def externalfigure primary filename =
- if false :
- rawtextext("\externalfigure[" & filename & "]")
- else :
- image (
- addto currentpicture doublepath unitsquare
- withprescript "mf_object=figure"
- withprescript "fg_name=" & filename ;
- )
- % unitsquare
- % withpen pencircle scaled 0
- % withprescript "fg_name=" & filename
- fi
- enddef ;
-
-fi ;
+vardef externalfigure primary filename =
+ mfun_tt_c := nullpicture ;
+ mfun_tt_r := lua.mp.mf_external_figure(filename) ;
+ addto mfun_tt_c doublepath unitsquare
+ xscaled wdpart mfun_tt_r
+ yscaled htpart mfun_tt_r
+ withprescript "mf_object=figure"
+ withprescript "fg_name=" & filename ;
+ ;
+ mfun_tt_c
+enddef ;
def figure primary filename =
rawtextext("\externalfigure[" & filename & "]")
@@ -1311,77 +1197,34 @@ def drawoutlinetext(expr o) =
)
enddef ;
-if mfun_use_one_pass :
-
- vardef outlinetext@# (expr t) text rest =
- save kind ; string kind ; kind := str @# ;
- currentoutlinetext := currentoutlinetext + 1 ;
- def mfun_do_outline_options_d = enddef ;
- def mfun_do_outline_options_f = enddef ;
- def mfun_do_outline_options_r = enddef ;
- image ( normaldraw image (
- % lua.mp.report("set outline text",currentoutlinetext);
- lua.mp.mf_outline_text(currentoutlinetext,t,kind) ;
- % lua.mp.report("get outline text",currentoutlinetext);
- if kind = "f" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "d" :
- mfun_do_outline_text_set_d rest ;
- elseif kind = "b" :
- mfun_do_outline_text_set_b rest ;
- elseif kind = "u" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "r" :
- mfun_do_outline_text_set_r rest ;
- elseif kind = "p" :
- mfun_do_outline_text_set_p ;
- else :
- mfun_do_outline_text_set_n rest ;
- fi ;
- lua.mp.mf_get_outline_text(currentoutlinetext) ;
- ) mfun_do_outline_options_r ; )
- enddef ;
-
-else :
-
- vardef outlinetext@# (expr t) text rest =
- save kind ; string kind ; kind := str @# ;
- currentoutlinetext := currentoutlinetext + 1 ;
- def mfun_do_outline_options_d = enddef ;
- def mfun_do_outline_options_f = enddef ;
- def mfun_do_outline_options_r = enddef ;
- image ( normaldraw image (
- if mfun_trial_run :
- % lua.mp.report("set outline text",currentoutlinetext);
- normaldraw unitsquare
- withprescript "mf_object=outline"
- withprescript "ot_stage=trial"
- withprescript "ot_index=" & decimal currentoutlinetext
- withprescript "ot_kind=" & kind
- withpostscript t ;
- else :
- % lua.mp.report("get outline text",currentoutlinetext);
- if kind = "f" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "d" :
- mfun_do_outline_text_set_d rest ;
- elseif kind = "b" :
- mfun_do_outline_text_set_b rest ;
- elseif kind = "u" :
- mfun_do_outline_text_set_f rest ;
- elseif kind = "r" :
- mfun_do_outline_text_set_r rest ;
- elseif kind = "p" :
- mfun_do_outline_text_set_p ;
- else :
- mfun_do_outline_text_set_n rest ;
- fi ;
- lua.mp.mf_get_outline_text(currentoutlinetext) ;
- fi ;
- ) mfun_do_outline_options_r ; )
- enddef ;
-
-fi ;
+vardef outlinetext@# (expr t) text rest =
+ save kind ; string kind ; kind := str @# ;
+ currentoutlinetext := currentoutlinetext + 1 ;
+ def mfun_do_outline_options_d = enddef ;
+ def mfun_do_outline_options_f = enddef ;
+ def mfun_do_outline_options_r = enddef ;
+ image ( normaldraw image (
+ % lua.mp.report("set outline text",currentoutlinetext);
+ lua.mp.mf_outline_text(currentoutlinetext,t,kind) ;
+ % lua.mp.report("get outline text",currentoutlinetext);
+ if kind = "f" :
+ mfun_do_outline_text_set_f rest ;
+ elseif kind = "d" :
+ mfun_do_outline_text_set_d rest ;
+ elseif kind = "b" :
+ mfun_do_outline_text_set_b rest ;
+ elseif kind = "u" :
+ mfun_do_outline_text_set_f rest ;
+ elseif kind = "r" :
+ mfun_do_outline_text_set_r rest ;
+ elseif kind = "p" :
+ mfun_do_outline_text_set_p ;
+ else :
+ mfun_do_outline_text_set_n rest ;
+ fi ;
+ lua.mp.mf_get_outline_text(currentoutlinetext) ;
+ ) mfun_do_outline_options_r ; )
+enddef ;
% A few helpers:
diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv
index 01ea2521b..2cdb5fb39 100644
--- a/metapost/context/base/mpiv/mp-tool.mpiv
+++ b/metapost/context/base/mpiv/mp-tool.mpiv
@@ -3594,3 +3594,11 @@ def drawdot expr p =
)
fi
enddef ;
+
+% vardef textlength(text t) =
+% save n ; n := 0 ;
+% for i = t :
+% n := n + 1 ;
+% endfor;
+% n
+% enddef;
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 55aeb64c2..04226df4c 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -810,7 +810,7 @@ function scripts.context.run(ctxdata,filename)
local l_flags = {
["interaction"] = a_batchmode,
-- ["synctex"] = false, -- context has its own way
- ["no-parse-first-line"] = true, -- obsolete
+ -- ["no-parse-first-line"] = true, -- obsolete
-- ["safer"] = a_safer, -- better use --sandbox
-- ["no-mktex"] = true,
-- ["file-line-error-style"] = true,
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 16f745a10..2763cbc04 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -7193,7 +7193,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 27742, stripped down to: 17085
+-- original size: 28756, stripped down to: 17693
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7811,6 +7811,42 @@ if setinspector then
end
end)
end
+local mt={
+ __newindex=function(t,k,v)
+ local n=t.last+1
+ t.last=n
+ t.list[n]=k
+ t.hash[k]=v
+ end,
+ __index=function(t,k)
+ return t.hash[k]
+ end,
+ __len=function(t)
+ return t.last
+ end,
+}
+function table.orderedhash()
+ return setmetatable({ list={},hash={},last=0 },mt)
+end
+function table.ordered(t)
+ local n=t.last
+ if n>0 then
+ local l=t.list
+ local i=1
+ local h=t.hash
+ local f=function()
+ if i<=n then
+ local k=i
+ local v=h[l[k]]
+ i=i+1
+ return k,v
+ end
+ end
+ return f,1,h[l[1]]
+ else
+ return function() end
+ end
+end
end -- of closure
@@ -23174,7 +23210,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8716, stripped down to: 6795
+-- original size: 8700, stripped down to: 6781
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23189,10 +23225,10 @@ local report_zip=logs.reporter("resolvers","zip")
local resolvers=resolvers
zip=zip or {}
local zip=zip
-zip.archives=zip.archives or {}
-local archives=zip.archives
-zip.registeredfiles=zip.registeredfiles or {}
-local registeredfiles=zip.registeredfiles
+local archives=zip.archives or {}
+zip.archives=archives
+local registeredfiles=zip.registeredfiles or {}
+zip.registeredfiles=registeredfiles
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23258,7 +23294,7 @@ function resolvers.finders.zip(specification)
end
local dfile=zfile:open(queryname)
if dfile then
- dfile=zfile:close()
+ dfile:close()
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -24747,8 +24783,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 987988
--- stripped bytes : 348954
+-- original bytes : 988986
+-- stripped bytes : 349358
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 16f745a10..2763cbc04 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -7193,7 +7193,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 27742, stripped down to: 17085
+-- original size: 28756, stripped down to: 17693
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7811,6 +7811,42 @@ if setinspector then
end
end)
end
+local mt={
+ __newindex=function(t,k,v)
+ local n=t.last+1
+ t.last=n
+ t.list[n]=k
+ t.hash[k]=v
+ end,
+ __index=function(t,k)
+ return t.hash[k]
+ end,
+ __len=function(t)
+ return t.last
+ end,
+}
+function table.orderedhash()
+ return setmetatable({ list={},hash={},last=0 },mt)
+end
+function table.ordered(t)
+ local n=t.last
+ if n>0 then
+ local l=t.list
+ local i=1
+ local h=t.hash
+ local f=function()
+ if i<=n then
+ local k=i
+ local v=h[l[k]]
+ i=i+1
+ return k,v
+ end
+ end
+ return f,1,h[l[1]]
+ else
+ return function() end
+ end
+end
end -- of closure
@@ -23174,7 +23210,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8716, stripped down to: 6795
+-- original size: 8700, stripped down to: 6781
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23189,10 +23225,10 @@ local report_zip=logs.reporter("resolvers","zip")
local resolvers=resolvers
zip=zip or {}
local zip=zip
-zip.archives=zip.archives or {}
-local archives=zip.archives
-zip.registeredfiles=zip.registeredfiles or {}
-local registeredfiles=zip.registeredfiles
+local archives=zip.archives or {}
+zip.archives=archives
+local registeredfiles=zip.registeredfiles or {}
+zip.registeredfiles=registeredfiles
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23258,7 +23294,7 @@ function resolvers.finders.zip(specification)
end
local dfile=zfile:open(queryname)
if dfile then
- dfile=zfile:close()
+ dfile:close()
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -24747,8 +24783,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 987988
--- stripped bytes : 348954
+-- original bytes : 988986
+-- stripped bytes : 349358
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 16f745a10..2763cbc04 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -7193,7 +7193,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 27742, stripped down to: 17085
+-- original size: 28756, stripped down to: 17693
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7811,6 +7811,42 @@ if setinspector then
end
end)
end
+local mt={
+ __newindex=function(t,k,v)
+ local n=t.last+1
+ t.last=n
+ t.list[n]=k
+ t.hash[k]=v
+ end,
+ __index=function(t,k)
+ return t.hash[k]
+ end,
+ __len=function(t)
+ return t.last
+ end,
+}
+function table.orderedhash()
+ return setmetatable({ list={},hash={},last=0 },mt)
+end
+function table.ordered(t)
+ local n=t.last
+ if n>0 then
+ local l=t.list
+ local i=1
+ local h=t.hash
+ local f=function()
+ if i<=n then
+ local k=i
+ local v=h[l[k]]
+ i=i+1
+ return k,v
+ end
+ end
+ return f,1,h[l[1]]
+ else
+ return function() end
+ end
+end
end -- of closure
@@ -23174,7 +23210,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8716, stripped down to: 6795
+-- original size: 8700, stripped down to: 6781
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23189,10 +23225,10 @@ local report_zip=logs.reporter("resolvers","zip")
local resolvers=resolvers
zip=zip or {}
local zip=zip
-zip.archives=zip.archives or {}
-local archives=zip.archives
-zip.registeredfiles=zip.registeredfiles or {}
-local registeredfiles=zip.registeredfiles
+local archives=zip.archives or {}
+zip.archives=archives
+local registeredfiles=zip.registeredfiles or {}
+zip.registeredfiles=registeredfiles
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23258,7 +23294,7 @@ function resolvers.finders.zip(specification)
end
local dfile=zfile:open(queryname)
if dfile then
- dfile=zfile:close()
+ dfile:close()
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -24747,8 +24783,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 987988
--- stripped bytes : 348954
+-- original bytes : 988986
+-- stripped bytes : 349358
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 16f745a10..2763cbc04 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -7193,7 +7193,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 27742, stripped down to: 17085
+-- original size: 28756, stripped down to: 17693
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7811,6 +7811,42 @@ if setinspector then
end
end)
end
+local mt={
+ __newindex=function(t,k,v)
+ local n=t.last+1
+ t.last=n
+ t.list[n]=k
+ t.hash[k]=v
+ end,
+ __index=function(t,k)
+ return t.hash[k]
+ end,
+ __len=function(t)
+ return t.last
+ end,
+}
+function table.orderedhash()
+ return setmetatable({ list={},hash={},last=0 },mt)
+end
+function table.ordered(t)
+ local n=t.last
+ if n>0 then
+ local l=t.list
+ local i=1
+ local h=t.hash
+ local f=function()
+ if i<=n then
+ local k=i
+ local v=h[l[k]]
+ i=i+1
+ return k,v
+ end
+ end
+ return f,1,h[l[1]]
+ else
+ return function() end
+ end
+end
end -- of closure
@@ -23174,7 +23210,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8716, stripped down to: 6795
+-- original size: 8700, stripped down to: 6781
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23189,10 +23225,10 @@ local report_zip=logs.reporter("resolvers","zip")
local resolvers=resolvers
zip=zip or {}
local zip=zip
-zip.archives=zip.archives or {}
-local archives=zip.archives
-zip.registeredfiles=zip.registeredfiles or {}
-local registeredfiles=zip.registeredfiles
+local archives=zip.archives or {}
+zip.archives=archives
+local registeredfiles=zip.registeredfiles or {}
+zip.registeredfiles=registeredfiles
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23258,7 +23294,7 @@ function resolvers.finders.zip(specification)
end
local dfile=zfile:open(queryname)
if dfile then
- dfile=zfile:close()
+ dfile:close()
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -24747,8 +24783,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 987988
--- stripped bytes : 348954
+-- original bytes : 988986
+-- stripped bytes : 349358
-- end library merge
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index 1b9f858fc..30a77ed87 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2019.01.07 16:10}
+\newcontextversion{2019.01.17 22:10}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index 0aaf30a95..df046d115 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2019.01.07 16:10}
+\edef\contextversion{2019.01.17 22:10}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 8c55f9583..d09b56df9 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2019.01.07 16:10}
+\newcontextversion{2019.01.17 22:10}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/cont-run.lua b/tex/context/base/mkiv/cont-run.lua
index aed2178d8..c8030bf39 100644
--- a/tex/context/base/mkiv/cont-run.lua
+++ b/tex/context/base/mkiv/cont-run.lua
@@ -175,6 +175,8 @@ if sandboxing then
traceback = traceback,
}
+ package.loaded.debug = debug
+
elseif debugging then
-- we keep debug
@@ -187,15 +189,13 @@ else
sethook = sethook,
}
-end
+ package.loaded.debug = debug
-local function processjob()
+end
- environment.initializefilenames() -- todo: check if we really need to pre-prep the filename
+local preparejob preparejob = function() -- tricky: we need a hook for this
local arguments = environment.arguments
- local suffix = environment.suffix
- local filename = environment.filename -- hm, not inputfilename !
if arguments.lmtx or not status.obj_ptr then
report("enabling lmtx mode")
@@ -245,6 +245,24 @@ local function processjob()
-- directives.enable("logs.errors",arguments.errors)
-- end
+ preparejob = function() end
+
+ job.prepare = preparejob
+
+end
+
+job.prepare = preparejob
+
+local function processjob()
+
+ environment.initializefilenames() -- todo: check if we really need to pre-prep the filename
+
+ local arguments = environment.arguments
+ local suffix = environment.suffix
+ local filename = environment.filename -- hm, not inputfilename !
+
+ preparejob()
+
if not filename or filename == "" then
-- skip
elseif suffix == "xml" or arguments.forcexml then
@@ -308,7 +326,6 @@ local function processjob()
-- \writestatus{system}{processing as tex}
-- We have a regular tex file so no \starttext yet as we can
-- load fonts.
-
-- context.enabletrackers { "resolvers.*" }
context.input(filename)
-- context.disabletrackers { "resolvers.*" }
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 2ab2151b5..5d3401226 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -42,7 +42,7 @@
%D has to match \type {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2019.01.07 16:10}
+\edef\contextversion{2019.01.17 22:10}
\edef\contextkind {beta}
%D For those who want to use this:
@@ -606,6 +606,14 @@
\ctxlua{statistics.stoptiming(statistics)}%
\to \everyjob
+% \appendtoks
+% \ctxlua{job.prepare()}%
+% \to \everyjob
+
+% \appendtoks
+% \enabletrackers[*]%
+% \to \everyjob
+
\appendtoks
\ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextkind","\contextbanner")}% can become automatic
\to \everydump
diff --git a/tex/context/base/mkiv/data-zip.lua b/tex/context/base/mkiv/data-zip.lua
index 32666bef2..6f20b4a9d 100644
--- a/tex/context/base/mkiv/data-zip.lua
+++ b/tex/context/base/mkiv/data-zip.lua
@@ -31,11 +31,11 @@ local resolvers = resolvers
zip = zip or { }
local zip = zip
-zip.archives = zip.archives or { }
-local archives = zip.archives
+local archives = zip.archives or { }
+zip.archives = archives
-zip.registeredfiles = zip.registeredfiles or { }
-local registeredfiles = zip.registeredfiles
+local registeredfiles = zip.registeredfiles or { }
+zip.registeredfiles = registeredfiles
local function validzip(str) -- todo: use url splitter
if not find(str,"^zip://") then
@@ -108,7 +108,7 @@ function resolvers.finders.zip(specification)
end
local dfile = zfile:open(queryname)
if dfile then
- dfile = zfile:close()
+ dfile:close()
if trace_locating then
report_zip("finder: file %a found",queryname)
end
diff --git a/tex/context/base/mkiv/font-sol.lua b/tex/context/base/mkiv/font-sol.lua
index 20472746c..9f892332f 100644
--- a/tex/context/base/mkiv/font-sol.lua
+++ b/tex/context/base/mkiv/font-sol.lua
@@ -351,7 +351,7 @@ function splitters.split(head) -- best also pass the direction
local function flush() -- we can move this
local font = getfont(start)
local last = getnext(stop)
- local list = last and copy_node_list(start,stop) or copy_node_list(start)
+ local list = last and copy_node_list(start,last) or copy_node_list(start)
local n = #cache + 1
if encapsulate then
local user_one = new_usernumber(splitter_one,n)
diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua
index 09a4678a1..ddbfd6edb 100644
--- a/tex/context/base/mkiv/lpdf-ini.lua
+++ b/tex/context/base/mkiv/lpdf-ini.lua
@@ -521,6 +521,8 @@ do
for k, v in next, t do
if k == "__extra__" then
e = v
+ elseif k == "__stream__" then
+ -- do nothing (yet)
else
n = n + 1
r[n] = k
@@ -533,8 +535,9 @@ do
local tv = type(v)
-- mostly tables
if tv == "table" then
- local mv = getmetatable(v)
- if mv and mv.__lpdftype then
+ -- local mv = getmetatable(v)
+ -- if mv and mv.__lpdftype then
+ if v.__lpdftype__ then
-- if v == t then
-- report_objects("ignoring circular reference in dirctionary")
-- r[i] = f_key_null(k)
@@ -582,9 +585,9 @@ do
if tv == "number" then
r[k] = f_tonumber(v)
elseif tv == "table" then
- local mv = getmetatable(v)
- local mt = mv and mv.__lpdftype
- if mt then
+ -- local mv = getmetatable(v)
+ -- if mv and mv.__lpdftype then
+ if v.__lpdftype__ then
-- if v == t then
-- report_objects("ignoring circular reference in array")
-- r[k] = "null"
@@ -707,20 +710,35 @@ end
local function add_x(t,k,v) rawset(t,k,tostring(v)) end
-local mt_x = { __lpdftype = "stream", __tostring = tostring_x, __call = value_x, __newindex = add_x }
-local mt_d = { __lpdftype = "dictionary", __tostring = tostring_d, __call = value_d, __add = add_to_d }
-local mt_a = { __lpdftype = "array", __tostring = tostring_a, __call = value_a, __add = add_to_a }
-local mt_u = { __lpdftype = "unicode", __tostring = tostring_u, __call = value_u }
-local mt_s = { __lpdftype = "string", __tostring = tostring_s, __call = value_s }
-local mt_p = { __lpdftype = "docstring", __tostring = tostring_p, __call = value_p }
-local mt_n = { __lpdftype = "number", __tostring = tostring_n, __call = value_n }
-local mt_c = { __lpdftype = "constant", __tostring = tostring_c, __call = value_c }
-local mt_z = { __lpdftype = "null", __tostring = tostring_z, __call = value_z }
-local mt_t = { __lpdftype = "true", __tostring = tostring_t, __call = value_t }
-local mt_f = { __lpdftype = "false", __tostring = tostring_f, __call = value_f }
-local mt_r = { __lpdftype = "reference", __tostring = tostring_r, __call = value_r }
-local mt_v = { __lpdftype = "verbose", __tostring = tostring_v, __call = value_v }
-local mt_l = { __lpdftype = "literal", __tostring = tostring_l, __call = value_l }
+-- local mt_x = { __index = { __lpdftype__ = "stream" }, __lpdftype = "stream", __tostring = tostring_x, __call = value_x, __newindex = add_x }
+-- local mt_d = { __index = { __lpdftype__ = "dictionary" }, __lpdftype = "dictionary", __tostring = tostring_d, __call = value_d, __add = add_to_d }
+-- local mt_a = { __index = { __lpdftype__ = "array" }, __lpdftype = "array", __tostring = tostring_a, __call = value_a, __add = add_to_a }
+-- local mt_u = { __index = { __lpdftype__ = "unicode" }, __lpdftype = "unicode", __tostring = tostring_u, __call = value_u }
+-- local mt_s = { __index = { __lpdftype__ = "string" }, __lpdftype = "string", __tostring = tostring_s, __call = value_s }
+-- local mt_p = { __index = { __lpdftype__ = "docstring" }, __lpdftype = "docstring", __tostring = tostring_p, __call = value_p }
+-- local mt_n = { __index = { __lpdftype__ = "number" }, __lpdftype = "number", __tostring = tostring_n, __call = value_n }
+-- local mt_c = { __index = { __lpdftype__ = "constant" }, __lpdftype = "constant", __tostring = tostring_c, __call = value_c }
+-- local mt_z = { __index = { __lpdftype__ = "null" }, __lpdftype = "null", __tostring = tostring_z, __call = value_z }
+-- local mt_t = { __index = { __lpdftype__ = "true" }, __lpdftype = "true", __tostring = tostring_t, __call = value_t }
+-- local mt_f = { __index = { __lpdftype__ = "false" }, __lpdftype = "false", __tostring = tostring_f, __call = value_f }
+-- local mt_r = { __index = { __lpdftype__ = "reference" }, __lpdftype = "reference", __tostring = tostring_r, __call = value_r }
+-- local mt_v = { __index = { __lpdftype__ = "verbose" }, __lpdftype = "verbose", __tostring = tostring_v, __call = value_v }
+-- local mt_l = { __index = { __lpdftype__ = "literal" }, __lpdftype = "literal", __tostring = tostring_l, __call = value_l }
+
+local mt_x = { __index = { __lpdftype__ = "stream" }, __tostring = tostring_x, __call = value_x, __newindex = add_x }
+local mt_d = { __index = { __lpdftype__ = "dictionary" }, __tostring = tostring_d, __call = value_d, __add = add_to_d }
+local mt_a = { __index = { __lpdftype__ = "array" }, __tostring = tostring_a, __call = value_a, __add = add_to_a }
+local mt_u = { __index = { __lpdftype__ = "unicode" }, __tostring = tostring_u, __call = value_u }
+local mt_s = { __index = { __lpdftype__ = "string" }, __tostring = tostring_s, __call = value_s }
+local mt_p = { __index = { __lpdftype__ = "docstring" }, __tostring = tostring_p, __call = value_p }
+local mt_n = { __index = { __lpdftype__ = "number" }, __tostring = tostring_n, __call = value_n }
+local mt_c = { __index = { __lpdftype__ = "constant" }, __tostring = tostring_c, __call = value_c }
+local mt_z = { __index = { __lpdftype__ = "null" }, __tostring = tostring_z, __call = value_z }
+local mt_t = { __index = { __lpdftype__ = "true" }, __tostring = tostring_t, __call = value_t }
+local mt_f = { __index = { __lpdftype__ = "false" }, __tostring = tostring_f, __call = value_f }
+local mt_r = { __index = { __lpdftype__ = "reference" }, __tostring = tostring_r, __call = value_r }
+local mt_v = { __index = { __lpdftype__ = "verbose" }, __tostring = tostring_v, __call = value_v }
+local mt_l = { __index = { __lpdftype__ = "literal" }, __tostring = tostring_l, __call = value_l }
local function pdfstream(t) -- we need to add attributes
if t then
@@ -730,9 +748,9 @@ local function pdfstream(t) -- we need to add attributes
t[i] = tostring(t[i])
end
elseif tt == "string" then
- t= { t }
+ t = { t }
else
- t= { tostring(t) }
+ t = { tostring(t) }
end
end
return setmetatable(t or { },mt_x)
diff --git a/tex/context/base/mkiv/lpdf-u3d.lua b/tex/context/base/mkiv/lpdf-u3d.lua
index fff89dc0f..f6897e92d 100644
--- a/tex/context/base/mkiv/lpdf-u3d.lua
+++ b/tex/context/base/mkiv/lpdf-u3d.lua
@@ -27,7 +27,6 @@ local nodeinjections = backends.pdf.nodeinjections
local pdfconstant = lpdf.constant
local pdfboolean = lpdf.boolean
-local pdfnumber = lpdf.number
local pdfunicode = lpdf.unicode
local pdfdictionary = lpdf.dictionary
local pdfarray = lpdf.array
@@ -448,13 +447,12 @@ local function insert3d(spec) -- width, height, factor, display, controls, label
stored_pr[tag] = ref
end
if ref then -- see back-pdf ** .. here we have a local /IM !
- local zero, one = pdfnumber(0), pdfnumber(1) -- not really needed
local pw = pdfdictionary {
Type = pdfconstant("XObject"),
Subtype = pdfconstant("Form"),
- FormType = one,
- BBox = pdfarray { zero, zero, pdfnumber(factor*width), pdfnumber(factor*height) },
- Matrix = pdfarray { one, zero, zero, one, zero, zero },
+ FormType = 1,
+ BBox = pdfarray { 0, 0, pdfnumber(factor*width), pdfnumber(factor*height) },
+ Matrix = pdfarray { 1, 0, 0, 1, 0, 0 },
ProcSet = lpdf.procset(),
Resources = pdfdictionary {
XObject = pdfdictionary {
@@ -464,8 +462,8 @@ local function insert3d(spec) -- width, height, factor, display, controls, label
ExtGState = pdfdictionary {
GS = pdfdictionary {
Type = pdfconstant("ExtGState"),
- CA = one,
- ca = one,
+ CA = 1,
+ ca = 1,
}
},
}
diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua
index ac7872fc2..508bb1997 100644
--- a/tex/context/base/mkiv/lpdf-xmp.lua
+++ b/tex/context/base/mkiv/lpdf-xmp.lua
@@ -136,11 +136,11 @@ local function update()
--
local t = type(dates)
if t == "number" or t == "string" then
- t = converters.totime(dates)
- if t then
+ local d = converters.totime(dates)
+ if d then
included.date = true
included.id = "fake"
- report_info("forced date/time information %a will be used",lpdf.settime(t))
+ report_info("forced date/time information %a will be used",lpdf.settime(d))
settrailerid(false)
return
end
diff --git a/tex/context/base/mkiv/luat-cod.lua b/tex/context/base/mkiv/luat-cod.lua
index 1a20908bd..9f8bbb544 100644
--- a/tex/context/base/mkiv/luat-cod.lua
+++ b/tex/context/base/mkiv/luat-cod.lua
@@ -11,6 +11,10 @@ local match, gsub, find, format, gmatch = string.match, string.gsub, string.find
local texconfig, lua = texconfig, lua
+-- maybe pick up from commandline:
+--
+-- texconfig.interaction: 0=batchmode 1=nonstopmode 2=scrollmode 3=errornonstopmode 4=normal
+
-- some basic housekeeping
texconfig.kpse_init = false
diff --git a/tex/context/base/mkiv/math-fbk.lua b/tex/context/base/mkiv/math-fbk.lua
index bfe2fde57..50c977178 100644
--- a/tex/context/base/mkiv/math-fbk.lua
+++ b/tex/context/base/mkiv/math-fbk.lua
@@ -318,9 +318,10 @@ local function accent_to_extensible(target,newchr,original,oldchr,height,depth,s
height = height or 0
depth = depth or 0
end
+ local oldheight = olddata.height or 0
local correction = swap and
- downcommand[(olddata.height or 0) - height]
- or downcommand[olddata.height + (offset or 0)]
+ downcommand[oldheight - height]
+ or downcommand[oldheight + (offset or 0)]
local newdata = {
commands = { correction, charcommand[oldchr] },
width = olddata.width,
@@ -654,3 +655,35 @@ virtualcharacters[0x2980] = function(data) return equals(data,0x2980,0x007C,-1/8
-- },
-- }
-- end
+
+-- lucida needs this
+
+virtualcharacters[0x305] = function(data)
+ local target = data.target
+ local height = target.parameters.xheight/8
+ local width = target.parameters.emwidth/2
+ local depth = height
+ local used = 0.8 * width
+ return {
+ width = width,
+ height = height,
+ depth = depth,
+ commands = { { "rule", height, width } },
+ horiz_variants = {
+ {
+ advance = width,
+ ["end"] = used,
+ glyph = 0x305,
+ start = 0,
+ },
+ {
+ advance = width,
+ ["end"] = 0,
+ extender = 1,
+ glyph = 0x305,
+ start = used,
+ },
+ }
+ }
+end
+
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua
index 7da84980e..51fc211dd 100644
--- a/tex/context/base/mkiv/math-noa.lua
+++ b/tex/context/base/mkiv/math-noa.lua
@@ -1446,7 +1446,7 @@ end
-- in opentype the italic correction of a limop is added to the width and luatex does
-- some juggling that we want to avoid but we need to do something here (in fact, we could
--- better fix the width of the character
+-- better fix the width of the character)
do
diff --git a/tex/context/base/mkiv/meta-blb.lua b/tex/context/base/mkiv/meta-blb.lua
index 5fea35f6d..ca3e55e42 100644
--- a/tex/context/base/mkiv/meta-blb.lua
+++ b/tex/context/base/mkiv/meta-blb.lua
@@ -31,10 +31,6 @@ local report = logs.reporter("metapost","blobs")
trackers.register("metapost.blobs", function(v) trace = v end)
--- We start with a text that comes from an analyze stage and can end up with
--- one or more results. For practical reasons we store the blobs in one array
--- and work with ranges.
-
local allblobs = { }
local function newcategory(t,k)
@@ -189,10 +185,6 @@ local function reset()
blob_raw_reset()
end
-local function analyze(object,prescript)
- -- nothing
-end
-
local function process(object,prescript,before,after)
-- if prescript.tb_stage == "inject" then
local tb_blob = tonumber(prescript.tb_blob)
@@ -205,7 +197,6 @@ end
metapost.installplugin {
name = "texblob",
reset = reset,
- analyze = analyze,
process = process,
}
@@ -291,71 +282,33 @@ interfaces.implement {
actions = initialize,
}
-local ft_reset, ft_analyze, ft_process do
-
- if metapost.use_one_pass then
-
- local mp_category = 0
- local mp_str = ""
-
- function mp.mf_inject_blob(category,str)
- newblob(category,str) -- only for tracing
- mp_category = category
- mp_str = str
- tex.runtoks("mpblobtext")
- end
-
- interfaces.implement {
- name = "mpblobtext",
- actions = function()
- context.MPLIBfollowtext(mp_category,mp_str)
- end
- }
-
- ft_process = function(object,prescript,before,after)
- if prescript.ft_category then
- object.path = false
- object.color = false
- object.grouped = true
- object.istext = true
- end
- end
-
-
- else
-
- ft_reset = function()
- -- nothing
- end
-
- ft_analyze = function(object,prescript)
- if prescript.ft_stage == "trial" then
- local ft_category = tonumber(prescript.ft_category)
- if ft_category then
- newblob(ft_category,object.postscript) -- only for tracing
- context.MPLIBfollowtext(ft_category,object.postscript)
- metapost.getjobdata().multipass = true
- end
- end
- end
-
- ft_process = function(object,prescript,before,after)
- if prescript.ft_stage == "final" then
- object.path = false
- object.color = false
- object.grouped = true
- object.istext = true
- end
- end
+local mp_category = 0
+local mp_str = ""
+function mp.mf_inject_blob(category,str)
+ newblob(category,str) -- only for tracing
+ mp_category = category
+ mp_str = str
+ tex.runtoks("mpblobtext")
+end
+interfaces.implement {
+ name = "mpblobtext",
+ actions = function()
+ context.MPLIBfollowtext(mp_category,mp_str)
end
+}
+local process = function(object,prescript,before,after)
+ if prescript.ft_category then
+ object.path = false
+ object.color = false
+ object.grouped = true
+ object.istext = true
+ end
end
metapost.installplugin {
name = "followtext",
- reset = ft_reset,
- analyze = ft_analyze,
- process = ft_process,
+ process = process,
}
diff --git a/tex/context/base/mkiv/meta-fnt.lua b/tex/context/base/mkiv/meta-fnt.lua
index e1d8d86eb..d2d642902 100644
--- a/tex/context/base/mkiv/meta-fnt.lua
+++ b/tex/context/base/mkiv/meta-fnt.lua
@@ -110,10 +110,7 @@ local function process(mpxformat,name,instances,scalefactor)
descriptions = { }
metapost.process {
mpx = mpxformat,
- -- trialrun = false,
flusher = flusher,
- -- multipass = false,
- -- isextrapass = false,
askedfig = "all",
-- incontext = false,
data = {
diff --git a/tex/context/base/mkiv/meta-ini.mkiv b/tex/context/base/mkiv/meta-ini.mkiv
index e0aba5fc0..89c7699de 100644
--- a/tex/context/base/mkiv/meta-ini.mkiv
+++ b/tex/context/base/mkiv/meta-ini.mkiv
@@ -881,19 +881,6 @@
{\meta_prepare_instance_variable{#1}%
\edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}
-%D \macros
-%D {MPdatafile}
-%D
-%D We redefine a macro from \type {supp-mps.tex}:
-
-% This will change ...
-
-\def\MPdataMPYfile{\jobname-mpgraph.mpy}
-
-\startMPextensions
- def data_mpy_file = "\noexpand\MPdataMPYfile" enddef ;
-\stopMPextensions
-
\unexpanded\def\getMPdata {\clf_getMPdata}
\let\rawMPdata \clf_getMPdata
diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua
index 99ef6c813..89f2fa0ee 100644
--- a/tex/context/base/mkiv/mlib-ctx.lua
+++ b/tex/context/base/mkiv/mlib-ctx.lua
@@ -323,20 +323,14 @@ implement {
statistics.register("metapost", function()
local n = metapost.n
if n and n > 0 then
- local nofconverted = metapost.makempy.nofconverted
local elapsedtime = statistics.elapsedtime
- local elapsed = statistics.elapsed
- local instances, memory = metapost.getstatistics(true)
- local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M",
+ local elapsed = statistics.elapsed
+ local instances,
+ memory = metapost.getstatistics(true)
+ return format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M",
elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n,
elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n),
instances, metapost.nofscriptruns(),memory/(1024*1024))
- if nofconverted > 0 then
- return format("%s, external: %s (%s calls)",
- str, elapsedtime(metapost.makempy), nofconverted)
- else
- return str
- end
else
return nil
end
diff --git a/tex/context/base/mkiv/mlib-pdf.lua b/tex/context/base/mkiv/mlib-pdf.lua
index c3c8c00da..717bb1634 100644
--- a/tex/context/base/mkiv/mlib-pdf.lua
+++ b/tex/context/base/mkiv/mlib-pdf.lua
@@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
license = "see context related readme files",
}
--- maybe %s is better than %f
-
local gsub = string.gsub
local concat, insert, remove = table.concat, table.insert, table.remove
local abs, sqrt, round = math.abs, math.sqrt, math.round
@@ -42,11 +40,9 @@ local pdfflusher = { }
metapost.flushers.pdf = pdfflusher
metapost.n = 0
-metapost.optimize = true -- false
local experiment = true -- uses context(node) that already does delayed nodes
local savedliterals = nil -- needs checking
------ mpsliteral = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral))
local mpsliteral = nodes.pool.pdforiginliteral
local f_f = formatters["%.6F"]
@@ -87,65 +83,27 @@ trackers.register("metapost.forcestroke",function(v)
force_stroke = v
end)
--- local pdfliteral = function(pdfcode)
--- local literal = copy_node(mpsliteral)
--- literal.data = pdfcode
--- return literal
--- end
-
-- Because in MKiV we always have two passes, we save the objects. When an extra
-- mp run is done (due to for instance texts identifier in the parse pass), we
-- get a new result table and the stored objects are forgotten. Otherwise they
-- are reused.
local function getobjects(result,figure,index)
- if metapost.optimize then
- local robjects = result.objects
- if not robjects then
- robjects = { }
- result.objects = robjects
- end
- local fobjects = robjects[index or 1]
- if not fobjects then
- fobjects = figure:objects()
- robjects[index] = fobjects
- end
- return fobjects
- else
- return figure:objects()
- end
+ return figure:objects()
end
function metapost.convert(specification,result)
- local trialrun = specification.trialrun
- local flusher = specification.flusher
- local multipass = specification.multipass
- local askedfig = specification.askedfig
- local incontext = specification.incontext
- if trialrun then
- local multipassindeed = metapost.parse(result,askedfig)
- if multipass and not multipassindeed and metapost.optimize then
- if save_table then
- table.save(save_table,metapost.totable(result,1)) -- direct
- end
- metapost.flush(specification,result)
- else
- return false
- end
- else
- if save_table then
- table.save(save_table,metapost.totable(result,1)) -- direct
- end
- metapost.flush(specification,result)
+ local flusher = specification.flusher
+ local askedfig = specification.askedfig
+ if save_table then
+ table.save(save_table,metapost.totable(result,1)) -- direct
end
+ metapost.flush(specification,result)
return true -- done
end
function metapost.flushliteral(d)
if savedliterals then
--- local literal = copy_node(mpsliteral)
--- literal.data = savedliterals[d]
--- write_node(literal)
write_node(mpsliteral(savedliterals[d]))
else
report_metapost("problem flushing literal %a",d)
@@ -160,7 +118,6 @@ function pdfflusher.comment(message)
if message then
message = formatters["%% mps graphic %s: %s"](metapost.n,message)
if experiment then
- -- context(pdfliteral(message))
context(mpsliteral(message))
elseif savedliterals then
local last = #savedliterals + 1
@@ -190,7 +147,6 @@ function pdfflusher.flushfigure(pdfliterals) -- table
if #pdfliterals > 0 then
pdfliterals = concat(pdfliterals,"\n")
if experiment then
- -- context(pdfliteral(pdfliterals))
context(mpsliteral(pdfliterals))
else
if savedliterals then
@@ -342,15 +298,6 @@ local p_boolean = P("false") * Cc(false) + P("true") * Cc(true)
local p_set = Ct(number^1)
local p_path = Ct(Ct(number * number^-5)^1)
--- local variable =
--- P("1:") * key * p_number
--- + P("2:") * key * p_string
--- + P("3:") * key * p_boolean
--- + S("4568") * P(":") * key * p_set
--- + P("7:") * key * p_path
---
--- local pattern_key = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset)
-
local variable =
P("1:") * p_number
+ P("2:") * p_string
@@ -504,7 +451,6 @@ function metapost.flush(specification,result)
setmetatable(object, {
__index = original
})
- -- first we analyze
local before, after = processplugins(object)
local evenodd, collect, both = false, false, false
local postscript = object.postscript
@@ -689,35 +635,6 @@ function metapost.flush(specification,result)
end
end
-function metapost.parse(result,askedfig)
- if result then
- local figures = result.fig
- if figures then
- local multipass = false
- local analyzeplugins = metapost.analyzeplugins -- each object
- for index=1,#figures do
- local figure = figures[index]
- local properties = pushproperties(figure)
- if askedfig == "direct" or askedfig == "all" or askedfig == properties.number then
- local objects = getobjects(result,figure,index)
- if objects then
- for o=1,#objects do
- if analyzeplugins(objects[o]) then
- multipass = true
- end
- end
- end
- if askedfig ~= "all" then
- break
- end
- end
- popproperties()
- end
- return multipass
- end
- end
-end
-
-- tracing:
do
@@ -757,7 +674,6 @@ function metapost.totable(result,askedfig)
local figure = result and result.fig and result.fig[1]
if figure then
local results = { }
- -- local objects = figure:objects()
local objects = getobjects(result,figure,askedfig)
for o=1,#objects do
local object = objects[o]
diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua
index f6b142d46..5ee375982 100644
--- a/tex/context/base/mkiv/mlib-pps.lua
+++ b/tex/context/base/mkiv/mlib-pps.lua
@@ -23,7 +23,6 @@ local context = context
local implement = interfaces.implement
local setmacro = interfaces.setmacro
------ texgetbox = tex.getbox
local texsetbox = tex.setbox
local textakebox = tex.takebox -- or: nodes.takebox
local copy_list = node.copy_list
@@ -58,9 +57,6 @@ local cmyktorgb = colors.cmyktorgb -- or function() return 0,0,0 e
local rgbtogray = colors.rgbtogray -- or function() return 0 end
local cmyktogray = colors.cmyktogray -- or function() return 0 end
-metapost.makempy = metapost.makempy or { nofconverted = 0 }
-local makempy = metapost.makempy
-
local nooutercolor = "0 g 0 G"
local nooutertransparency = "/Tr0 gs" -- only when set
local outercolormode = 0
@@ -296,49 +292,23 @@ end
-- end of new
-local settext, gettext
-
-if metapost.use_one_pass then
-
- settext = function(box,slot,str)
- if top then
- -- if trace_textexts then
- -- report_textexts("getting text %s from box %s",slot,box)
- -- end
- top.textexts[slot] = textakebox(box)
- end
- end
-
- gettext = function(box,slot)
- if top then
- texsetbox(box,top.textexts[slot])
- top.textexts[slot] = false
- -- if trace_textexts then
- -- report_textexts("putting text %s in box %s",slot,box)
- -- end
- end
- end
-
-else
-
- settext = function(box,slot,str)
- if top then
- -- if trace_textexts then
- -- report_textexts("getting text %s from box %s",slot,box)
- -- end
- top.textexts[slot] = textakebox(box)
- end
+local settext = function(box,slot,str)
+ if top then
+ -- if trace_textexts then
+ -- report_textexts("getting text %s from box %s",slot,box)
+ -- end
+ top.textexts[slot] = textakebox(box)
end
+end
- gettext = function(box,slot)
- if top then
- texsetbox(box,copy_list(top.textexts[slot]))
- -- if trace_textexts then
- -- report_textexts("putting text %s in box %s",slot,box)
- -- end
- end
+local gettext = function(box,slot)
+ if top then
+ texsetbox(box,top.textexts[slot])
+ top.textexts[slot] = false
+ -- if trace_textexts then
+ -- report_textexts("putting text %s in box %s",slot,box)
+ -- end
end
-
end
metapost.settext = settext
@@ -495,76 +465,9 @@ setmetatableindex(models, function(t,k)
end)
local function colorconverter(cs)
- -- return models[colors.currentmodel()](cs)
return models[outercolormodel](cs)
end
-local btex = P("btex")
-local etex = P(" etex")
-local vtex = P("verbatimtex")
-local ttex = P("textext")
-local gtex = P("graphictext")
-local multipass = P("forcemultipass")
-local spacing = S(" \n\r\t\v")^0
-local dquote = P('"')
-
-local found, forced = false, false
-
-local function convert(str)
- found = true
- return "rawtextext(\"" .. str .. "\")" -- centered
-end
-local function ditto(str)
- return "\" & ditto & \""
-end
-local function register()
- found = true
-end
-local function force()
- forced = true
-end
-
-local texmess = (dquote/ditto + (1 - etex))^0
-
-local function ignore(s)
- report_metapost("ignoring verbatim tex: %s",s)
- return ""
-end
-
--- local parser = P {
--- [1] = Cs((V(2)/register + V(4)/ignore + V(3)/convert + V(5)/force + 1)^0),
--- [2] = ttex + gtex,
--- [3] = btex * spacing * Cs(texmess) * etex,
--- [4] = vtex * spacing * Cs(texmess) * etex,
--- [5] = multipass, -- experimental, only for testing
--- }
-
--- currently a a one-liner produces less code
-
--- textext.*(".*") can have "'s but tricky parsing as we can have concatenated strings
--- so this is something for a boring plane or train trip and we might assume proper mp
--- input anyway
-
-local parser = Cs((
- (ttex + gtex)/register
- + (btex * spacing * Cs(texmess) * etex)/convert
- + (vtex * spacing * Cs(texmess) * etex)/ignore
- + 1
-)^0)
-
-local checking_enabled = false directives.register("metapost.checktexts",function(v) checking_enabled = v end)
-
-local function checktexts(str)
- if checking_enabled then
- found, forced = false, false
- return lpegmatch(parser,str), found, forced
- else
- return str
- end
-end
-
-metapost.checktexts = checktexts
-
local factor = 65536*(7227/7200)
implement {
@@ -586,10 +489,6 @@ metapost.sxsy = sxsy
-- for stock mp we need to declare the booleans first
-local no_first_run = "boolean mfun_first_run ; mfun_first_run := false ;"
-local do_first_run = "boolean mfun_first_run ; mfun_first_run := true ;"
-local no_trial_run = "boolean mfun_trial_run ; mfun_trial_run := false ;"
-local do_trial_run = "boolean mfun_trial_run ; mfun_trial_run := true ;"
local do_begin_fig = "; beginfig(1) ; "
local do_end_fig = "; endfig ;"
local do_safeguard = ";"
@@ -611,20 +510,6 @@ function metapost.preparetextextsdata()
mp.mf_tt_initialize(collected)
end
-metapost.intermediate = metapost.intermediate or { }
-metapost.intermediate.actions = metapost.intermediate.actions or { }
-
-metapost.method = 1 -- 1:dumb 2:clever 3:nothing
-
-if metapost.use_one_pass then
-
- metapost.method = 3
- checking_enabled = false
-
-end
-
--- maybe we can latelua the texts some day
-
local runmetapost = metapost.run
local function checkaskedfig(askedfig) -- return askedfig, wrappit
@@ -651,7 +536,6 @@ local function extrapass()
metapost.preparetextextsdata()
runmetapost {
mpx = top.mpx,
- isextrapass = true,
askedfig = top.askedfig,
incontext = true,
data = {
@@ -684,107 +568,36 @@ function metapost.graphic_base_pass(specification)
top.wrappit = wrappit
top.nofruns = nofruns
metapost.namespace = specification.namespace or ""
- --
- local done_1, done_2, done_3, forced_1, forced_2, forced_3
- if checking_enabled then
- data, done_1, forced_1 = checktexts(data)
- if extensions == "" then
- extensions, done_2, forced_2 = "", false, false
- else
- extensions, done_2, forced_2 = checktexts(extensions)
- end
- if inclusions == "" then
- inclusions, done_3, forced_3 = "", false, false
- else
- inclusions, done_3, forced_3 = checktexts(inclusions)
- end
- end
- top.intermediate = false
- top.multipass = false -- no needed here
- top.mpx = mpx
- top.data = data
- top.initializations = initializations
- local method = metapost.method
+ top.mpx = mpx
+ top.data = data
+ top.initializations = initializations
if trace_runs then
- if method == 1 then
- report_metapost("forcing two runs due to library configuration")
- elseif method ~= 2 then
- report_metapost("ignoring extra run due to library configuration")
- elseif not (done_1 or done_2 or done_3) then
- report_metapost("forcing one run only due to analysis")
- elseif done_1 then
- report_metapost("forcing at max two runs due to main code")
- elseif done_2 then
- report_metapost("forcing at max two runs due to extensions")
- else
- report_metapost("forcing at max two runs due to inclusions")
- end
- end
- if method == 1 or (method == 2 and (done_1 or done_2 or done_3)) then
- if trace_runs then
- report_metapost("first run of job %s, asked figure %a",nofruns,askedfig)
- end
- local flushed = runmetapost {
- mpx = mpx,
- trialrun = true,
- multipass = not (forced_1 or forced_2 or forced_3),
- askedfig = askedfig,
- incontext = true,
- data = {
- inclusions,
- wrappit and do_begin_fig or "",
- do_first_run,
- do_trial_run,
- initializations,
- do_safeguard,
- data,
- wrappit and do_end_fig or "",
- },
- }
- if top.intermediate then
- for _, action in next, metapost.intermediate.actions do
- action()
- end
- end
- if not flushed or not metapost.optimize then
- -- This is tricky as we can only ask for objects once and therefore
- -- we really need a second run when we're not optimized.
- context(extrapass)
- end
- else
- if trace_runs then
- report_metapost("running job %s, asked figure %a",nofruns,askedfig)
- end
- runmetapost {
- mpx = mpx,
- askedfig = askedfig,
- incontext = true,
- data = {
- inclusions,
- wrappit and do_begin_fig or "",
- do_first_run,
- no_trial_run,
- initializations,
- do_safeguard,
- data,
- wrappit and do_end_fig or "",
- },
- }
+ report_metapost("running job %s, asked figure %a",nofruns,askedfig)
end
+ runmetapost {
+ mpx = mpx,
+ askedfig = askedfig,
+ incontext = true,
+ data = {
+ inclusions,
+ wrappit and do_begin_fig or "",
+ initializations,
+ do_safeguard,
+ data,
+ wrappit and do_end_fig or "",
+ },
+ }
context(stopjob)
end
-local function oldschool(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig, incontext)
+local function oldschool(mpx, data, trial_run, flusher, was_multi_pass, is_extra_pass, askedfig, incontext)
metapost.process {
- mpx = mpx,
- trialrun = trialrun,
- flusher = flusher,
- multipass = multipass,
- isextrapass = isextrapass,
- askedfig = askedfig,
- useplugins = incontext,
- incontext = incontext,
- data = data,
+ mpx = mpx,
+ flusher = flusher,
+ askedfig = askedfig,
+ useplugins = incontext,
+ incontext = incontext,
+ data = data,
}
end
@@ -798,83 +611,6 @@ function metapost.process(specification,...)
end
end
-local start = [[\starttext]]
-local preamble = [[\def\MPLIBgraphictext#1{\startTEXpage[scale=10000]#1\stopTEXpage}]]
-local stop = [[\stoptext]]
-
-local mpyfilename = nil
-
-function makempy.registerfile(filename)
- mpyfilename = filename
-end
-
-implement {
- name = "registermpyfile",
- actions = makempy.registerfile,
- arguments = "string"
-}
-
-local pdftompy = sandbox.registerrunner {
- name = "mpy:pstoedit",
- program = "pstoedit",
- template = "-ssp -dt -f mpost %pdffile% %mpyfile%",
- checkers = {
- pdffile = "writable",
- mpyfile = "readable",
- },
- reporter = report_metapost,
-}
-
-local textopdf = sandbox.registerrunner {
- name = "mpy:context",
- program = "context",
- template = "--once %runmode% %texfile%",
- checkers = {
- runmode = "string",
- texfile = "readable",
- },
- reporter = report_metapost,
-}
-
-function makempy.processgraphics(graphics)
- if #graphics == 0 then
- return
- end
- if mpyfilename and exists(mpyfilename) then
- report_metapost("using file: %s",mpyfilename)
- return
- end
- makempy.nofconverted = makempy.nofconverted + 1
- starttiming(makempy)
- local mpofile = tex.jobname .. "-mpgraph"
- local mpyfile = file.replacesuffix(mpofile,"mpy")
- local pdffile = file.replacesuffix(mpofile,"pdf")
- local texfile = file.replacesuffix(mpofile,"tex")
- savedata(texfile, { start, preamble, metapost.tex.get(), concat(graphics,"\n"), stop }, "\n")
- textopdf {
- runmode = tex.interactionmode == 0 and "--batchmode" or "",
- texfile = texfile,
- }
- if exists(pdffile) then
- pdftompy {
- pdffile = pdffile,
- mpyfile = mpyfile,
- }
- if exists(mpyfile) then
- local result, r = { }, 0
- local data = io.loaddata(mpyfile)
- if data and #data > 0 then
- for figure in gmatch(data,"beginfig(.-)endfig") do
- r = r + 1
- result[r] = formatters["begingraphictextfig%sendgraphictextfig ;\n"](figure)
- end
- savedata(mpyfile,concat(result,""))
- end
- end
- end
- stoptiming(makempy)
-end
-
-- -- the new plugin handler -- --
local sequencers = utilities.sequencers
@@ -882,11 +618,9 @@ local appendgroup = sequencers.appendgroup
local appendaction = sequencers.appendaction
local resetteractions = sequencers.new { arguments = "t" }
-local analyzeractions = sequencers.new { arguments = "object,prescript" }
local processoractions = sequencers.new { arguments = "object,prescript,before,after" }
appendgroup(resetteractions, "system")
-appendgroup(analyzeractions, "system")
appendgroup(processoractions,"system")
-- later entries come first
@@ -955,17 +689,6 @@ function metapost.resetplugins(t) -- intialize plugins, before figure
end
end
-function metapost.analyzeplugins(object) -- each object (first pass)
- if top.plugmode then
- local prescript = object.prescript -- specifications
- if prescript and #prescript > 0 then
- analyzeractions.runner(object,splitprescript(prescript) or {})
- return top.multipass
- end
- end
- return false
-end
-
function metapost.processplugins(object) -- each object (second pass)
if top.plugmode then
local prescript = object.prescript -- specifications
@@ -1014,7 +737,7 @@ end
-- text
-local tx_reset, tx_analyze, tx_process do
+local tx_reset, tx_process do
local eol = S("\n\r")^1
local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0)
@@ -1055,339 +778,174 @@ local tx_reset, tx_analyze, tx_process do
f_cmyk_nop = formatters["c=%.3N,m=%.3N,y=%.3N,k=%.3N"]
end)
- if metapost.use_one_pass then
-
- local ctx_MPLIBsetNtext = context.MPLIBsetNtextX
- local ctx_MPLIBsetCtext = context.MPLIBsetCtextX
- local ctx_MPLIBsettext = context.MPLIBsettextX
-
- local bp = number.dimenfactors.bp
-
- local mp_index = 0
- local mp_target = 0
- local mp_c = nil
- local mp_a = nil
- local mp_t = nil
-
- local function processtext()
- local mp_text = top.texstrings[mp_index]
- if not mp_text then
- report_textexts("missing text for index %a",mp_index)
- elseif not mp_c then
- ctx_MPLIBsetNtext(mp_target,mp_text)
- elseif #mp_c == 1 then
- if mp_a and mp_t then
- ctx_MPLIBsetCtext(mp_target,f_gray_yes(mp_c[1],mp_a,mp_t),mp_text)
- else
- ctx_MPLIBsetCtext(mp_target,f_gray_nop(mp_c[1]),mp_text)
- end
- elseif #mp_c == 3 then
- if mp_a and mp_t then
- ctx_MPLIBsetCtext(mp_target,f_rgb_nop(mp_c[1],mp_c[2],mp_c[3],mp_a,mp_t),mp_text)
- else
- ctx_MPLIBsetCtext(mp_target,f_rgb_nop(mp_c[1],mp_c[2],mp_c[3]),mp_text)
- end
- elseif #mp_c == 4 then
- if mp_a and mp_t then
- ctx_MPLIBsetCtext(mp_target,f_cmyk_yes(mp_c[1],mp_c[2],mp_c[3],mp_c[4],mp_a,mp_t),mp_text)
- else
- ctx_MPLIBsetCtext(mp_target,f_cmyk_nop(mp_c[1],mp_c[2],mp_c[3],mp_c[4]),mp_text)
- end
+ local ctx_MPLIBsetNtext = context.MPLIBsetNtextX
+ local ctx_MPLIBsetCtext = context.MPLIBsetCtextX
+ local ctx_MPLIBsettext = context.MPLIBsettextX
+
+ local bp = number.dimenfactors.bp
+
+ local mp_index = 0
+ local mp_target = 0
+ local mp_c = nil
+ local mp_a = nil
+ local mp_t = nil
+
+ local function processtext()
+ local mp_text = top.texstrings[mp_index]
+ if not mp_text then
+ report_textexts("missing text for index %a",mp_index)
+ elseif not mp_c then
+ ctx_MPLIBsetNtext(mp_target,mp_text)
+ elseif #mp_c == 1 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_gray_yes(mp_c[1],mp_a,mp_t),mp_text)
else
- -- can't happen
- ctx_MPLIBsetNtext(mp_target,mp_text)
+ ctx_MPLIBsetCtext(mp_target,f_gray_nop(mp_c[1]),mp_text)
end
- end
-
- function mp.mf_some_text(index,str)
- mp_target = index
- mp_index = index
- mp_c = nil
- mp_a = nil
- mp_t = nil
- top.texstrings[mp_index] = str
- tex.runtoks("mptexttoks")
- local box = textakebox("mptextbox")
- top.textexts[mp_target] = box
- mp.triplet(bp*box.width,bp*box.height,bp*box.depth)
- madetext = nil
- end
-
- local madetext = nil
-
- function mp.mf_made_text(index)
- mp.mf_some_text(index,madetext)
- end
-
- function metapost.maketext(s,mode)
- if mode and mode == 1 then
- if trace_btexetex then
- report_metapost("ignoring verbatimtex: [[%s]]",s)
- end
+ elseif #mp_c == 3 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_rgb_nop(mp_c[1],mp_c[2],mp_c[3],mp_a,mp_t),mp_text)
else
- if trace_btexetex then
- report_metapost("handling btex ... etex: [[%s]]",s)
- end
- -- madetext = utilities.strings.collapse(s)
- madetext = s
- return "rawmadetext"
+ ctx_MPLIBsetCtext(mp_target,f_rgb_nop(mp_c[1],mp_c[2],mp_c[3]),mp_text)
end
- end
-
- function mp.mf_formatted_text(index,fmt,...)
- local t = { }
- for i=1,select("#",...) do
- local ti = select(i,...)
- if type(ti) ~= "table" then
- t[#t+1] = ti
- end
+ elseif #mp_c == 4 then
+ if mp_a and mp_t then
+ ctx_MPLIBsetCtext(mp_target,f_cmyk_yes(mp_c[1],mp_c[2],mp_c[3],mp_c[4],mp_a,mp_t),mp_text)
+ else
+ ctx_MPLIBsetCtext(mp_target,f_cmyk_nop(mp_c[1],mp_c[2],mp_c[3],mp_c[4]),mp_text)
end
- local f = lpegmatch(cleaner,fmt)
- local s = formatters[f](unpack(t)) or ""
- mp.mf_some_text(index,s)
+ else
+ -- can't happen
+ ctx_MPLIBsetNtext(mp_target,mp_text)
end
+ end
- interfaces.implement {
- name = "mptexttoks",
- actions = processtext,
- }
+ function mp.mf_some_text(index,str)
+ mp_target = index
+ mp_index = index
+ mp_c = nil
+ mp_a = nil
+ mp_t = nil
+ top.texstrings[mp_index] = str
+ tex.runtoks("mptexttoks")
+ local box = textakebox("mptextbox")
+ top.textexts[mp_target] = box
+ mp.triplet(bp*box.width,bp*box.height,bp*box.depth)
+ madetext = nil
+ end
+
+ local madetext = nil
+
+ function mp.mf_made_text(index)
+ mp.mf_some_text(index,madetext)
+ end
- tx_reset = function()
- if top then
- top.texhash = { }
- top.texlast = 0
+ function metapost.maketext(s,mode)
+ if mode and mode == 1 then
+ if trace_btexetex then
+ report_metapost("ignoring verbatimtex: [[%s]]",s)
end
+ else
+ if trace_btexetex then
+ report_metapost("handling btex ... etex: [[%s]]",s)
+ end
+ -- madetext = utilities.strings.collapse(s)
+ madetext = s
+ return "rawmadetext"
end
+ end
- tx_process = function(object,prescript,before,after)
- local data = top.texdata[metapost.properties.number]
- local index = tonumber(prescript.tx_index)
- if index then
- if trace_textexts then
- report_textexts("using index %a",index)
- end
- --
- mp_c = object.color
- if #mp_c == 0 then
- local txc = prescript.tx_color
- if txc then
- mp_c = lpegmatch(pat,txc)
- end
- end
- mp_a = tonumber(prescript.tr_alternative)
- mp_t = tonumber(prescript.tr_transparency)
- --
- mp_index = index
- mp_target = top.texlast - 1
- top.texlast = mp_target
- --
- local mp_text = top.texstrings[mp_index]
- local box
- if prescript.tx_cache == "no" then
- tex.runtoks("mptexttoks")
- box = textakebox("mptextbox")
- else
- local hash = fmt(mp_text,mp_a or "-",mp_t or "-",mp_c or "-")
- box = data.texhash[hash]
- if box then
- box = copy_list(box)
- else
- tex.runtoks("mptexttoks")
- box = textakebox("mptextbox")
- data.texhash[hash] = box
- end
- end
- top.textexts[mp_target] = box
- --
- if box then
- -- we need to freeze the variables outside the function
- local sx, rx, ry, sy, tx, ty = cm(object)
- local target = mp_target
- before[#before+1] = function()
- context.MPLIBgettextscaledcm(target,
- f_f(sx), -- bah ... %s no longer checks
- f_f(rx), -- bah ... %s no longer checks
- f_f(ry), -- bah ... %s no longer checks
- f_f(sy), -- bah ... %s no longer checks
- f_f(tx), -- bah ... %s no longer checks
- f_f(ty), -- bah ... %s no longer checks
- sxsy(box.width,box.height,box.depth))
- end
- else
- before[#before+1] = function()
- report_textexts("unknown %s",index)
- end
- end
- if not trace_textexts then
- object.path = false -- else: keep it
- end
- object.color = false
- object.grouped = true
- object.istext = true
+ function mp.mf_formatted_text(index,fmt,...)
+ local t = { }
+ for i=1,select("#",...) do
+ local ti = select(i,...)
+ if type(ti) ~= "table" then
+ t[#t+1] = ti
end
end
+ local f = lpegmatch(cleaner,fmt)
+ local s = formatters[f](unpack(t)) or ""
+ mp.mf_some_text(index,s)
+ end
- else
-
- local ctx_MPLIBsetNtext = context.MPLIBsetNtext
- local ctx_MPLIBsetCtext = context.MPLIBsetCtext
- local ctx_MPLIBsettext = context.MPLIBsettext
+ interfaces.implement {
+ name = "mptexttoks",
+ actions = processtext,
+ }
- tx_reset = function()
- if top then
- top.texhash = { }
- top.texlast = 0
- end
+ tx_reset = function()
+ if top then
+ top.texhash = { }
+ top.texlast = 0
end
+ end
- -- we reuse content when possible
- -- we always create at least one instance (for dimensions)
- -- we make sure we don't do that when we use one (else counter issues with e.g. \definelabel)
-
- tx_analyze = function(object,prescript)
- local data = top.texdata[metapost.properties.number]
- local tx_stage = prescript.tx_stage
- if tx_stage == "trial" then
- local tx_trial = data.textrial + 1
- data.textrial = tx_trial
- local tx_number = tonumber(prescript.tx_number)
- local s = object.postscript or ""
- local c = object.color -- only simple ones, no transparency
- if #c == 0 then
- local txc = prescript.tx_color
- if txc then
- c = lpegmatch(pat,txc)
- end
- end
- if prescript.tx_type == "format" then
- s = applyformat(s)
- end
- local a = tonumber(prescript.tr_alternative)
- local t = tonumber(prescript.tr_transparency)
- local h = fmt(tx_number,a or "-",t or "-",c or "-")
- local n = data.texhash[h] -- todo: hashed variant with s (nicer for similar labels)
- if n then
- data.texslots[tx_trial] = n
- if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, %s %a, hash %a, text %a",tx_stage,tx_trial,tx_number,"old",n,h,s)
- end
- elseif prescript.tx_global == "yes" and data.texorder[tx_number] then
- -- we already have one flush and don't want it redone .. this needs checking
- if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, %s %a, hash %a, text %a",tx_stage,tx_trial,tx_number,"ignored",tx_last,h,s)
- end
- else
- local tx_last = top.texlast + 1
- top.texlast = tx_last
- -- report_textexts("tex string: %s",s)
- if not c then
- ctx_MPLIBsetNtext(tx_last,s)
- elseif #c == 1 then
- if a and t then
- ctx_MPLIBsetCtext(tx_last,f_gray_yes(c[1],a,t),s)
- else
- ctx_MPLIBsetCtext(tx_last,f_gray_nop(c[1]),s)
- end
- elseif #c == 3 then
- if a and t then
- ctx_MPLIBsetCtext(tx_last,f_rgb_nop(c[1],c[2],c[3],a,t),s)
- else
- ctx_MPLIBsetCtext(tx_last,f_rgb_nop(c[1],c[2],c[3]),s)
- end
- elseif #c == 4 then
- if a and t then
- ctx_MPLIBsetCtext(tx_last,f_cmyk_yes(c[1],c[2],c[3],c[4],a,t),s)
- else
- ctx_MPLIBsetCtext(tx_last,f_cmyk_nop(c[1],c[2],c[3],c[4]),s)
- end
- else
- ctx_MPLIBsetNtext(tx_last,s)
- end
- top.multipass = true
- data.texhash [h] = tx_last
- -- data.texhash [tx_number] = tx_last
- data.texslots[tx_trial] = tx_last
- data.texorder[tx_number] = tx_last
- if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, %s %a, hash %a, text %a",tx_stage,tx_trial,tx_number,"new",tx_last,h,s)
- end
- end
- elseif tx_stage == "extra" then
- local tx_trial = data.textrial + 1
- data.textrial = tx_trial
- local tx_number = tonumber(prescript.tx_number)
- if not data.texorder[tx_number] then
- local s = object.postscript or ""
- local tx_last = top.texlast + 1
- top.texlast = tx_last
- ctx_MPLIBsettext(tx_last,s)
- top.multipass = true
- data.texslots[tx_trial] = tx_last
- data.texorder[tx_number] = tx_last
- if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, extra %a, text %a",tx_stage,tx_trial,tx_number,tx_last,s)
- end
+ tx_process = function(object,prescript,before,after)
+ local data = top.texdata[metapost.properties.number]
+ local index = tonumber(prescript.tx_index)
+ if index then
+ if trace_textexts then
+ report_textexts("using index %a",index)
+ end
+ --
+ mp_c = object.color
+ if #mp_c == 0 then
+ local txc = prescript.tx_color
+ if txc then
+ mp_c = lpegmatch(pat,txc)
end
end
- end
-
- tx_process = function(object,prescript,before,after)
- local data = top.texdata[metapost.properties.number]
- local tx_number = tonumber(prescript.tx_number)
- if tx_number then
- local tx_stage = prescript.tx_stage
- if tx_stage == "final" then
- local tx_final = data.texfinal + 1
- data.texfinal = tx_final
- local n = data.texslots[tx_final]
- if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, use %a",tx_stage,tx_final,tx_number,n)
- end
- local sx, rx, ry, sy, tx, ty = cm(object) -- needs to be frozen outside the function
- local box = top.textexts[n]
- if box then
- before[#before+1] = function()
- -- flush always happens, we can have a special flush function injected before
- context.MPLIBgettextscaledcm(n,
- f_f(sx), -- bah ... %s no longer checks
- f_f(rx), -- bah ... %s no longer checks
- f_f(ry), -- bah ... %s no longer checks
- f_f(sy), -- bah ... %s no longer checks
- f_f(tx), -- bah ... %s no longer checks
- f_f(ty), -- bah ... %s no longer checks
- sxsy(box.width,box.height,box.depth))
- end
- else
- before[#before+1] = function()
- report_textexts("unknown %s",tx_number)
- end
- end
- if not trace_textexts then
- object.path = false -- else: keep it
- end
- object.color = false
- object.grouped = true
- object.istext = true
+ mp_a = tonumber(prescript.tr_alternative)
+ mp_t = tonumber(prescript.tr_transparency)
+ --
+ mp_index = index
+ mp_target = top.texlast - 1
+ top.texlast = mp_target
+ --
+ local mp_text = top.texstrings[mp_index]
+ local box
+ if prescript.tx_cache == "no" then
+ tex.runtoks("mptexttoks")
+ box = textakebox("mptextbox")
+ else
+ local hash = fmt(mp_text,mp_a or "-",mp_t or "-",mp_c or "-")
+ box = data.texhash[hash]
+ if box then
+ box = copy_list(box)
+ else
+ tex.runtoks("mptexttoks")
+ box = textakebox("mptextbox")
+ data.texhash[hash] = box
end
end
- end
-
- local f_textext = formatters[ [[rawtextext("%s")]] ]
-
- function metapost.maketext(s,mode)
- if mode and mode == 1 then
- if trace_btexetex then
- report_metapost("ignoring verbatimtex: [[%s]]",s)
+ top.textexts[mp_target] = box
+ --
+ if box then
+ -- we need to freeze the variables outside the function
+ local sx, rx, ry, sy, tx, ty = cm(object)
+ local target = mp_target
+ before[#before+1] = function()
+ context.MPLIBgettextscaledcm(target,
+ f_f(sx), -- bah ... %s no longer checks
+ f_f(rx), -- bah ... %s no longer checks
+ f_f(ry), -- bah ... %s no longer checks
+ f_f(sy), -- bah ... %s no longer checks
+ f_f(tx), -- bah ... %s no longer checks
+ f_f(ty), -- bah ... %s no longer checks
+ sxsy(box.width,box.height,box.depth))
end
else
- if trace_btexetex then
- report_metapost("handling btex ... etex: [[%s]]",s)
+ before[#before+1] = function()
+ report_textexts("unknown %s",index)
end
- s = gsub(s,'"','"&ditto&"')
- return f_textext(s)
end
+ if not trace_textexts then
+ object.path = false -- else: keep it
+ end
+ object.color = false
+ object.grouped = true
+ object.istext = true
end
-
end
end
@@ -1426,61 +984,29 @@ end
-- graphics (we use the given index because pictures can be reused)
-local gt_reset, gt_analyze, gt_process do
+local gt_reset, gt_process do
local graphics = { }
- if metapost.use_one_pass then
- local mp_index = 0
- local mp_str = ""
+ local mp_index = 0
+ local mp_str = ""
- function metapost.intermediate.actions.makempy()
- end
-
- function mp.mf_graphic_text(index,str)
- if not graphics[index] then
- mp_index = index
- mp_str = str
- tex.runtoks("mpgraphictexttoks")
- end
+ function mp.mf_graphic_text(index,str)
+ if not graphics[index] then
+ mp_index = index
+ mp_str = str
+ tex.runtoks("mpgraphictexttoks")
end
-
- interfaces.implement {
- name = "mpgraphictexttoks",
- actions = function()
- context.MPLIBgraphictext(mp_index,mp_str)
- end,
- }
-
-
- else
-
- function metapost.intermediate.actions.makempy()
- if #graphics > 0 then
- makempy.processgraphics(graphics)
- graphics = { } -- ? could be gt_reset
- end
- end
-
- local function gt_analyze(object,prescript)
- local gt_stage = prescript.gt_stage
- local gt_index = tonumber(prescript.gt_index)
- if gt_stage == "trial" and not graphics[gt_index] then
- graphics[gt_index] = formatters["\\MPLIBgraphictext{%s}"](object.postscript or "")
- top.intermediate = true
- top.multipass = true
- end
- end
-
- -- local function gt_process(object,prescript,before,after)
- -- local gt_stage = prescript.gt_stage
- -- if gt_stage == "final" then
- -- end
- -- end
-
end
+ interfaces.implement {
+ name = "mpgraphictexttoks",
+ actions = function()
+ context.MPLIBgraphictext(mp_index,mp_str)
+ end,
+ }
+
end
-- shades
@@ -1868,7 +1394,7 @@ end
-- outlines
-local ot_reset, ot_analyze, ot_process do
+local ot_reset, ot_process do
local outlinetexts = { } -- also in top data
@@ -1876,43 +1402,26 @@ local ot_reset, ot_analyze, ot_process do
outlinetexts = { }
end
- if metapost.use_one_pass then
-
- local mp_index = 0
- local mp_kind = ""
- local mp_str = ""
+ local mp_index = 0
+ local mp_kind = ""
+ local mp_str = ""
- function mp.mf_outline_text(index,str,kind)
- if not outlinetexts[index] then
- mp_index = index
- mp_kind = kind
- mp_str = str
- tex.runtoks("mpoutlinetoks")
- end
+ function mp.mf_outline_text(index,str,kind)
+ if not outlinetexts[index] then
+ mp_index = index
+ mp_kind = kind
+ mp_str = str
+ tex.runtoks("mpoutlinetoks")
end
-
- interfaces.implement {
- name = "mpoutlinetoks",
- actions = function()
- context.MPLIBoutlinetext(mp_index,mp_kind,mp_str)
- end,
- }
-
- else
-
- ot_analyze = function(object,prescript)
- local ot_stage = prescript.ot_stage
- local ot_index = tonumber(prescript.ot_index)
- if ot_index and ot_stage == "trial" and not outlinetexts[ot_index] then
- local ot_kind = prescript.ot_kind or ""
- top.intermediate = true
- top.multipass = true
- context.MPLIBoutlinetext(ot_index,ot_kind,object.postscript)
- end
- end
-
end
+ interfaces.implement {
+ name = "mpoutlinetoks",
+ actions = function()
+ context.MPLIBoutlinetext(mp_index,mp_kind,mp_str)
+ end,
+ }
+
implement {
name = "MPLIBconvertoutlinetext",
arguments = { "integer", "string", "integer" },
@@ -1944,15 +1453,11 @@ end
local function installplugin(specification)
local reset = specification.reset
- local analyze = specification.analyze
local process = specification.process
local object = specification.object
if reset then
appendaction(resetteractions,"system",reset)
end
- if analyze then
- appendaction(analyzeractions,"system",analyze)
- end
if process then
appendaction(processoractions,"system",process)
end
@@ -1962,15 +1467,15 @@ metapost.installplugin = installplugin
-- definitions
-installplugin { name = "outline", reset = ot_reset, analyze = ot_analyze, process = ot_process }
-installplugin { name = "color", reset = cl_reset, analyze = cl_analyze, process = cl_process }
-installplugin { name = "text", reset = tx_reset, analyze = tx_analyze, process = tx_process }
-installplugin { name = "group", reset = gr_reset, analyze = gr_analyze, process = gr_process }
-installplugin { name = "graphictext", reset = gt_reset, analyze = gt_analyze, process = gt_process }
-installplugin { name = "shade", reset = sh_reset, analyze = sh_analyze, process = sh_process }
-installplugin { name = "bitmap", reset = bm_reset, analyze = bm_analyze, process = bm_process }
-installplugin { name = "box", reset = bx_reset, analyze = bx_analyze, process = bx_process }
-installplugin { name = "position", reset = ps_reset, analyze = ps_analyze, process = ps_process }
-installplugin { name = "figure", reset = fg_reset, analyze = fg_analyze, process = fg_process }
-installplugin { name = "layer", reset = la_reset, analyze = la_analyze, process = la_process }
-installplugin { name = "transparency", reset = tr_reset, analyze = tr_analyze, process = tr_process }
+installplugin { name = "outline", reset = ot_reset, process = ot_process }
+installplugin { name = "color", reset = cl_reset, process = cl_process }
+installplugin { name = "text", reset = tx_reset, process = tx_process }
+installplugin { name = "group", reset = gr_reset, process = gr_process }
+installplugin { name = "graphictext", reset = gt_reset, process = gt_process }
+installplugin { name = "shade", reset = sh_reset, process = sh_process }
+installplugin { name = "bitmap", reset = bm_reset, process = bm_process }
+installplugin { name = "box", reset = bx_reset, process = bx_process }
+installplugin { name = "position", reset = ps_reset, process = ps_process }
+installplugin { name = "figure", reset = fg_reset, process = fg_process }
+installplugin { name = "layer", reset = la_reset, process = la_process }
+installplugin { name = "transparency", reset = tr_reset, process = tr_process }
diff --git a/tex/context/base/mkiv/mlib-run.lua b/tex/context/base/mkiv/mlib-run.lua
index 649d57c61..a3a833c4e 100644
--- a/tex/context/base/mkiv/mlib-run.lua
+++ b/tex/context/base/mkiv/mlib-run.lua
@@ -71,20 +71,6 @@ end
----- mpbasepath = lpeg.instringchecker(lpeg.append { "/metapost/context/", "/metapost/base/" })
local mpbasepath = lpeg.instringchecker(P("/metapost/") * (P("context") + P("base")) * P("/"))
--- local function i_finder(askedname,mode,ftype) -- fake message for mpost.map and metafun.mpvi
--- local foundname = file.is_qualified_path(askedname) and askedname or resolvers.findfile(askedname,ftype)
--- if not mpbasepath(foundname) then
--- -- we could use the via file but we don't have a complete io interface yet
--- local data, found, forced = metapost.checktexts(io.loaddata(foundname) or "")
--- if found then
--- local tempname = luatex.registertempfile(foundname,true)
--- io.savedata(tempname,data)
--- foundname = tempname
--- end
--- end
--- return foundname
--- end
-
-- mplib has no real io interface so we have a different mechanism than
-- tex (as soon as we have more control, we will use the normal code)
--
@@ -98,21 +84,6 @@ do
local new_instance = mplib.new
- local function preprocessed(name)
- if not mpbasepath(name) then
- -- we could use the via file but we don't have a complete io interface yet
- local data, found, forced = metapost.checktexts(io.loaddata(name) or "")
- if found then
- local temp = luatex.registertempfile(name,true)
- io.savedata(temp,data)
- return temp
- end
- end
- return name
- end
-
- mplib.preprocessed = preprocessed -- helper
-
local function validftype(ftype)
if ftype == "" then
-- whatever
@@ -124,14 +95,13 @@ do
end
finders.file = function(specification,name,mode,ftype)
- return preprocessed(resolvers.findfile(name,validftype(ftype)))
+ return resolvers.findfile(name,validftype(ftype))
end
local function i_finder(name,mode,ftype) -- fake message for mpost.map and metafun.mpvi
local specification = url.hashed(name)
local finder = finders[specification.scheme] or finders.file
local found = finder(specification,name,mode,validftype(ftype))
- -- print(found)
return found
end
@@ -308,8 +278,6 @@ local function prepareddata(data,collapse)
end
end
-metapost.use_one_pass = true -- Some day I will prune the code (still testing).
-
metapost.defaultformat = "metafun"
metapost.defaultinstance = "metafun"
metapost.defaultmethod = "default"
@@ -460,18 +428,13 @@ end
--
-- mpx string or mp object
-- data string or table of strings
--- trialrun boolean
-- flusher table with flush methods
--- multipass boolean
--- isextrapass boolean
-- askedfig string ("all" etc) or number
-- incontext boolean
-- plugmode boolean
local function makebeginbanner(specification)
- return formatters
- ["%% begin graphic: n=%s, trialrun=%l, multipass=%l, isextrapass=%l\n\n"]
- (metapost.n, specification.trialrun, specification.multipass, specification.isextrapass)
+ return formatters["%% begin graphic: n=%s\n\n"](metapost.n)
end
local function makeendbanner(specification)
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 05a5a0e47..d1c0f7bca 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index e5566d82b..e70941e70 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/task-ini.lua b/tex/context/base/mkiv/task-ini.lua
index 67bd26de6..cfff3625a 100644
--- a/tex/context/base/mkiv/task-ini.lua
+++ b/tex/context/base/mkiv/task-ini.lua
@@ -121,7 +121,7 @@ appendaction("math", "builders", "noads.handlers.align",
appendaction("finalizers", "lists", "typesetters.paragraphs.normalize", nil, "nut", "enabled" ) -- "disabled"
appendaction("finalizers", "lists", "typesetters.margins.localhandler", nil, "nut", "disabled" )
appendaction("finalizers", "lists", "builders.paragraphs.keeptogether", nil, "nut", "disabled" )
-appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize", nil, "nut", "disabled" )
+appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize", nil, "nonut", "disabled" )
appendaction("finalizers", "lists", "builders.paragraphs.tag", nil, "nut", "disabled" )
appendaction("finalizers", "lists", "nodes.linefillers.handler", nil, "nut", "disabled" )
diff --git a/tex/context/base/mkiv/util-tab.lua b/tex/context/base/mkiv/util-tab.lua
index f395f43de..ed4cef996 100644
--- a/tex/context/base/mkiv/util-tab.lua
+++ b/tex/context/base/mkiv/util-tab.lua
@@ -820,3 +820,53 @@ if setinspector then
end)
end
+-- ordered hashes (for now here but in the table namespace):
+
+-- local t = table.orderedhash()
+--
+-- t["1"] = { "a", "b" }
+-- t["2"] = { }
+-- t["2a"] = { "a", "c", "d" }
+--
+-- for k, v in table.ordered(t) do
+-- ...
+-- end
+
+local mt = {
+ __newindex = function(t,k,v)
+ local n = t.last + 1
+ t.last = n
+ t.list[n] = k
+ t.hash[k] = v
+ end,
+ __index = function(t,k)
+ return t.hash[k]
+ end,
+ __len = function(t)
+ return t.last
+ end,
+}
+
+function table.orderedhash()
+ return setmetatable({ list = { }, hash = { }, last = 0 }, mt)
+end
+
+function table.ordered(t)
+ local n = t.last
+ if n > 0 then
+ local l = t.list
+ local i = 1
+ local h = t.hash
+ local f = function()
+ if i <= n then
+ local k = i
+ local v = h[l[k]]
+ i = i + 1
+ return k, v
+ end
+ end
+ return f, 1, h[l[1]]
+ else
+ return function() end
+ end
+end
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index 744cc36a9..1809a7c91 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index aa4551920..367a76106 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-basics-nod.lua b/tex/generic/context/luatex/luatex-basics-nod.lua
index 4c9a13f9a..276c7efa5 100644
--- a/tex/generic/context/luatex/luatex-basics-nod.lua
+++ b/tex/generic/context/luatex/luatex-basics-nod.lua
@@ -234,6 +234,26 @@ nuts.traverse_char = direct.traverse_char
nuts.traverse_glyph = direct.traverse_glyph
nuts.traverse_id = direct.traverse_id
+-- for now
+
+if not nuts.getdirection then
+
+ local getdir = direct.getdir
+
+ function nuts.getdirection(n)
+ local d = getdir(n)
+ if d == "TLT" then return 0
+ elseif d == "TRT" then return 1
+ elseif d == "+TLT" then return 0, false
+ elseif d == "+TRT" then return 1, false
+ elseif d == "-TLT" then return 0, true
+ elseif d == "-TRT" then return 1, true
+ else return 0
+ end
+ end
+
+end
+
-- properties as used in the (new) injector:
local propertydata = direct.get_properties_table()
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 1cecf7d9c..109d123fb 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 01/07/19 16:10:23
+-- merge date : 01/17/19 22:10:09
do -- begin closure to overcome local limits and interference
@@ -4882,6 +4882,20 @@ nuts.traverse=direct.traverse
nuts.traverse_char=direct.traverse_char
nuts.traverse_glyph=direct.traverse_glyph
nuts.traverse_id=direct.traverse_id
+if not nuts.getdirection then
+ local getdir=direct.getdir
+ function nuts.getdirection(n)
+ local d=getdir(n)
+ if d=="TLT" then return 0
+ elseif d=="TRT" then return 1
+ elseif d=="+TLT" then return 0,false
+ elseif d=="+TRT" then return 1,false
+ elseif d=="-TLT" then return 0,true
+ elseif d=="-TRT" then return 1,true
+ else return 0
+ end
+ end
+end
local propertydata=direct.get_properties_table()
nodes.properties={ data=propertydata }
direct.set_properties_mode(true,true)