summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/documents/general/manuals/luametatex.pdfbin1211807 -> 1223189 bytes
-rw-r--r--doc/context/presentations/context/2020/context-2020-datatypes.pdfbin42978 -> 41356 bytes
-rw-r--r--doc/context/presentations/context/2020/context-2020-tokens.pdfbin45873 -> 43876 bytes
-rw-r--r--doc/context/sources/general/manuals/followingup/followingup-expressions.tex309
-rw-r--r--doc/context/sources/general/manuals/followingup/followingup.tex1
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex54
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex483
-rw-r--r--metapost/context/base/mpiv/mp-back.mpiv63
-rw-r--r--metapost/context/base/mpiv/mp-idea.mpiv44
-rw-r--r--metapost/context/base/mpiv/mp-xbox.mpiv5
-rw-r--r--metapost/context/base/mpxl/mp-tool.mpxl2
-rw-r--r--metapost/context/base/mpxl/mp-xbox.mpxl5
-rw-r--r--scripts/context/lua/mtxrun.lua6
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua6
-rw-r--r--scripts/context/stubs/unix/mtxrun6
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua6
-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/mkii/mult-fr.mkii1
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/lxml-lpt.lua4
-rw-r--r--tex/context/base/mkiv/page-lin.mkvi4
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin23617 -> 23616 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin248519 -> 248528 bytes
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/lpdf-tag.lmt50
-rw-r--r--tex/context/base/mkxl/page-lin.mklx12
-rw-r--r--tex/context/base/mkxl/strc-tag.mkxl2
-rw-r--r--tex/context/interface/mkii/keys-fr.xml1
-rw-r--r--tex/context/modules/mkiv/m-compatible.mkiv4
-rw-r--r--tex/context/modules/mkiv/m-mkii.mkiv2
-rw-r--r--tex/context/modules/mkiv/m-obsolete.mkiv2
-rw-r--r--tex/context/modules/mkiv/m-oldfun.mkiv2
-rw-r--r--tex/context/modules/mkiv/m-oldnum.mkiv2
-rw-r--r--tex/context/modules/mkiv/m-units.mkiv2
-rw-r--r--tex/context/modules/mkxl/m-openstreetmap.lmt906
-rw-r--r--tex/context/modules/mkxl/m-openstreetmap.mkxl461
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
40 files changed, 2171 insertions, 288 deletions
diff --git a/doc/context/documents/general/manuals/luametatex.pdf b/doc/context/documents/general/manuals/luametatex.pdf
index aa07db6da..2db4dc1df 100644
--- a/doc/context/documents/general/manuals/luametatex.pdf
+++ b/doc/context/documents/general/manuals/luametatex.pdf
Binary files differ
diff --git a/doc/context/presentations/context/2020/context-2020-datatypes.pdf b/doc/context/presentations/context/2020/context-2020-datatypes.pdf
index 906b1fe04..f7f7bd8b9 100644
--- a/doc/context/presentations/context/2020/context-2020-datatypes.pdf
+++ b/doc/context/presentations/context/2020/context-2020-datatypes.pdf
Binary files differ
diff --git a/doc/context/presentations/context/2020/context-2020-tokens.pdf b/doc/context/presentations/context/2020/context-2020-tokens.pdf
index c508d25ac..7139f0c53 100644
--- a/doc/context/presentations/context/2020/context-2020-tokens.pdf
+++ b/doc/context/presentations/context/2020/context-2020-tokens.pdf
Binary files differ
diff --git a/doc/context/sources/general/manuals/followingup/followingup-expressions.tex b/doc/context/sources/general/manuals/followingup/followingup-expressions.tex
new file mode 100644
index 000000000..9819f58c6
--- /dev/null
+++ b/doc/context/sources/general/manuals/followingup/followingup-expressions.tex
@@ -0,0 +1,309 @@
+% language=us
+
+\startcomponent followingup-expressions
+
+\environment followingup-style
+
+\startchapter[title={Expressions}]
+
+\startsection[title={Introduction}]
+
+Do we need bitwise expressions? Actually the answer is \quotation {no, although
+not until recently}. In \CONTEXT\ \MKII\ and \MKIV\ we just use integer addition
+because we only need to enable things but in \LMTX\ we want to control de
+detailed modes that some mechanisms in the engine provides and in order to not
+have tons of parameters these use bit sets. We manipulate these with the bitwise
+macros that actually are efficient \LUA\ function calls. But, as with some other
+extensions in \LUAMETATEX, one way to prevent tracing clutter is to have a few
+handy primitives. So let's see what we got.
+
+{\em I haven't checked all operators and combinations yet!}
+
+\stopsection
+
+\startsection[title={Exploration}]
+
+Already early in the \LUAMETATEX\ development (2019) the expression parser was
+extended with an integer division operator \type {:} that we actually use in
+\LMTX, and soon after that I added basic bitwise operators but these were never
+activated but kept as comment because I didn't want to impact the scanner (even
+if we can afford to loose some performance because the scanner has been
+optimized). But in the process of cleaning up \quote {todo} comments in the
+source code I eventually arrived at expressions again.
+
+The colon already makes the scanner incompatible because \type {\numexpr 1+2:}
+expects a number (which means that we cannot port back) and more operators only
+make that less likely. In \CONTEXT\ I nearly always use \type {\relax} as
+terminator unless we're sure that lookahead is no issue. \footnote {In the \ETEX\
+expression parser, the normal \type {/} rounds the result. Both the \type {*} and
+\type {/} operator have a dedicated code path that assures no loss of accuracy.
+The \type {:} operator just divides like \LUA's \type {//} which is an integer
+division operator. There are subtle differences between the division variants
+which can be noticeable when you go round trip. That is actually the main reason
+why this was one of the first things added to \LUAMETATEX\ as I wanted to get rid
+of some few scaled point rounding issues. The \ETEX\ expression parser is
+somewhat complicated because it can deal with a mix of integers, dimensions and
+even glue, but always brings the result back to its main operating model. Because
+we adopted some of these \ETEX\ rather early in \CONTEXT\ lookahead pitfalls are
+taken care of already.}
+
+When going over the code in 2021, mostly because I wanted to get rid of some
+commented experiments, I decided that the extension should not go into the
+normal scanner but that a dedicated, simple and integer only scanner made more
+sense, so during a rainy summer weekend I started playing with that. It eventually
+became a bit more than initially intended, although the amount of code is rather
+minimal. The performance was about twice that of the already available bitwise
+macros but operator precedence was not provided (apart from the multiplication
+and division operators). The final implementation was different, not that much
+faster on simple bitwise operations but could do more complex things in one go.
+Performance was not a real reason to provide this anyway because we're talking
+microseconds, it's more about less code and better readability.
+
+The initial primitive command was \type {\bitexpr} and it supported nesting with
+parenthesis as the other expressions do. Because there are many operators, also
+verbose ones, the non|-|optional \type {\relax} token finishes parsing. But
+soon we moved on to two dedicated primitives.
+
+\stopsection
+
+\startsection[title={Operators}]
+
+The set of operators that we have to support is the following. Most have
+alternatives so that we can get around catcode issues.
+
+\starttabulate[||cT|cT|]
+\BC add \NC + \NC \NC \NR
+\BC subtract \NC - \NC \NC \NR
+\BC multiply \NC * \NC \NC \NR
+\BC divide \NC / : \NC \NC \NR
+\BC mod \NC \letterpercent \NC mod \NC \NR
+\BC band \NC & \NC band \NC \NR
+\BC bxor \NC ^ \NC bxor \NC \NR
+\BC bor \NC \letterbar \space v \NC bor \NC \NR
+\BC and \NC && \NC and \NC \NR
+\BC or \NC \letterbar\letterbar \NC or \NC \NR
+\BC setbit \NC <undecided> \NC bset \NC \NR
+\BC resetbit \NC <undecided> \NC breset \NC \NR
+\BC left \NC << \NC \NC \NR
+\BC right \NC >> \NC \NC \NR
+\BC less \NC < \NC \NC \NR
+\BC lessequal \NC <= \NC \NC \NR
+\BC equal \NC = == \NC \NC \NR
+\BC moreequal \NC >= \NC \NC \NR
+\BC more \NC > \NC \NC \NR
+\BC unequal \NC <> != \lettertilde = \NC \NC \NR
+\BC not \NC ! \lettertilde \NC not \NC \NR
+\stoptabulate
+
+I considered using \type {++} and type {--} as the \type {bset} and \type
+{bunset} shortcuts but that leads to issues because in \TEX\ \type {-+-++--10} is
+a valid number and one never knows what sequence (without spaces) gets fed into
+an expression.
+
+Originally I'd added some \UNICODE\ characters but for some reason support of
+logical operators is suboptimal so I removed that feature. Because these special
+characters are multi|-|byte \UTF\ sequences they are not that much better than
+verbose words anyway.
+
+% 0x00AC ! ¬ lua: not
+% 0x00D7 * ×
+% 0x00F7 / ÷
+% 0x2227 && ∧ c: and lua: and
+% 0x2228 || ∨ c: or lua: or
+% 0x2229 & ∩ c: bitand lua: band
+% 0x222A | ∪ c: bitor lua: bor
+% ^ c: bitxor lua: bxor
+% 0x2260 != ≠
+% 0x2261 == ≡
+% 0x2264 <= ≤
+% 0x2265 >= ≥
+% 0x22BB xor ⊻
+% 0x22BC nand ⊼
+% 0x22BD nor ⊽
+% 0x22C0 and ⋀ n-arry logical and
+% 0x22C1 or ⋁ n-arry logical or
+% 0x2AA1 << ⪡
+% 0x2AA2 >> ⪢
+
+\stopsection
+
+\startsection[title={Integers and dimensions}]
+
+When I was playing a bit with this feature, I wondered if we could mix in some
+dimensions. It was actually not that hard to add this: only explicit (verbose)
+dimensions had to be intercepted because dimen registers and such are seen as
+integers by the integer scanner. Once we're able do handle that, a next step was
+to make sure that \typ {2 * 10pt} was permitted, something that the \ETEX\ \type
+{\dimexpr} primitives can't handle. So, a variant of the dimen parser has to be
+used that makes the unit optional: \type {\dimexpression} and \type
+{\numexpression} were born.
+
+The resulting parsers worked quite well but were about twice as slow as the
+normal expression scanners but that is no surprise because they do more. For
+instance we are case insensitive and need to handle letter and other (and in a
+few cases alignment and superscript) catcodes too. However, with a slightly tuned
+integer parser, also possible because the sentinel \type {\relax} makes parsing
+more predictable, and a dedicated unit scanner, in the end both the integer and
+dimension parser were performing well. It's not like we run them millions of
+times in a document.
+
+\startbuffer
+\scratchcounter = \numexpression
+ "00000 bor "00001 bor "00020 bor "00400 bor "08000 bor "F0000
+\relax
+\stopbuffer
+
+Here is an example that results in {0x\inlinebuffer\uchexnumber\scratchcounter}:
+
+\typebuffer
+
+\startbuffer
+\scratchcounter = \numexpression
+ "FFFFF bxor "10101
+\relax
+\stopbuffer
+
+And this gives {0x\inlinebuffer\uchexnumber\scratchcounter}:
+
+\typebuffer
+
+We can give numerous example but you get the picture. In the above table you can
+see that some operators have equivalents. The reason for this is that a macro
+package can change catcodes and some characters have special meanings. So, the
+scanner is rather tolerant.
+
+\startbuffer
+\scratchcounterone = 10
+\scratchcountertwo = 20
+\ifcase \numexpression
+ (\scratchcounterone > 5) && (\scratchcountertwo > 5)
+\relax yes\else nop\fi
+%
+\space
+%
+\scratchcounterone = 2
+\scratchcountertwo = 4
+\ifcase \numexpression
+ (\scratchcounterone > 5) and (\scratchcountertwo > 5)
+\relax nop\else yes\fi
+\stopbuffer
+
+And this gives \quote {\tttf \inlinebuffer}:
+
+\typebuffer
+
+The normal expansion rules apply, so one can use macros and other symbolic
+numbers. The only difference in handling dimensions is that we don't support
+\type {true} units but these are obsolete in \LUAMETATEX\ anyway.
+
+\stopsection
+
+\startsection[title={Tracing}]
+
+When \type {\tracingexpressions} is set to one or higher the intermediate \quote
+{reverse polish notation} stack that is used for the calculation is shown, for
+instance:
+
+\starttyping
+4:8: {numexpression rpn: 2 5 > 4 5 > and}
+\stoptyping
+
+When you want the output on your console, you need to say:
+
+\starttyping
+\tracingexpressions 1
+\tracingonline 1
+\stoptyping
+
+The fact that we process the expression in two phases makes it possible to provide this
+kind of tracing.
+
+\stopsection
+
+\startsection[title={Performance}]
+
+The following table shows the results of 100.000 evaluations (per line) so you'll
+notice that there is a difference. But keep in mind that the new variant can so
+more, so it might pay off when we have cases that otherwise demand multiple
+traditional expressions.
+
+\starttabulate[|l|c|]
+\NC \type {\dimexpr 4pt*2 + 6pt\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchdimen \dimexpr 4pt*2 + 6pt\relax} \elapsedtime\fi \NC \NR
+\NC \type {\dimexpression 4pt*2 + 6pt\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchdimen \dimexpression 4pt*2 + 6pt\relax} \elapsedtime\fi \NC \NR
+\NC \type {\dimexpression 2*4pt + 6pt\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchdimen \dimexpression 4pt*2 + 6pt\relax} \elapsedtime\fi \NC \NR
+\TB
+\NC \type {\numexpr 4 * 2 + 6\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpr 4 * 2 + 6\relax} \elapsedtime\fi \NC \NR
+\NC \type {\numexpression 2 * 4 + 6\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpression 2 * 4 + 6\relax} \elapsedtime\fi \NC \NR
+\TB
+\NC \type {\numexpr 4*2+6\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpr 4*2+6\relax} \elapsedtime\fi \NC \NR
+\NC \type {\numexpression 2*4+6\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpression 2*4+6\relax} \elapsedtime\fi \NC \NR
+\TB
+\NC \type {\numexpr (1+2)*(3+4)\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpr (1+2)*(3+4)\relax} \elapsedtime\fi \NC \NR
+\NC \type {\numexpression (1+2)*(3+4)\relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpression (1+2)*(3+4)\relax} \elapsedtime\fi \NC \NR
+\TB
+\NC \type {\numexpr (1 + 2) * (3 + 4) \relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpr (1 + 2) * (3 + 4) \relax} \elapsedtime\fi \NC \NR
+\NC \type {\numexpression (1 + 2) * (3 + 4) \relax} \EQ \iftrialtypesetting\else\testfeatureonce{100000}{\scratchcounter\numexpression (1 + 2) * (3 + 4) \relax} \elapsedtime\fi \NC \NR
+\stoptabulate
+
+As usual I'll probably find some way to improve performance a bit but that might
+than also concern the traditional one. When we compare them, the new numeric
+scanner suffers from more options while the new dimension parser gain on the
+units. Also, keep in mind than the \LUAMETATEX\ normal parsers are already
+somewhat faster than the ones in \LUATEX. The numbers above are calculated when
+this document is rendered, so they may change over time and per run. The two
+engines compare as follows (mid 2021):
+
+\starttabulate[|l|c|c|]
+\NC \BC \LUATEX \BC \LUAMETATEX \NC \NR
+\NC \type {\dimexpr 4pt*2 + 6pt\relax} \NC 0.073 \NC 0.045 \NC \NR
+\NC \type {\numexpr 4 * 2 + 6\relax} \NC 0.034 \NC 0.028 \NC \NR
+\NC \type {\numexpr 4*2+6\relax} \NC 0.035 \NC 0.032 \NC \NR
+\NC \type {\numexpr (1+2)*(3+4)\relax} \NC 0.050 \NC 0.047 \NC \NR
+\NC \type {\numexpr (1 + 2) * (3 + 4) \relax} \NC 0.052 \NC 0.048 \NC \NR
+\stoptabulate
+
+Of course tests like these are dubious because often \CPU\ cache will keep the
+current code accessible, but who knows.
+
+It will probably take a while before I will use this in the source code because
+first I need to make sure that all works as expected and while doing that I might
+adapt some of this. But the basic framework is there.
+
+\stopsection
+
+% \start
+% \nologbuffering
+% \scratchdimen 100pt
+% \scratchdimenone 65.536pt
+% \scratchdimentwo 65.536bp
+
+% \tracingonline1
+% \tracingexpressions1
+% \scratchcounter\bitexpr \scratchdimen / 2 \relax\the\scratchcounter\par
+
+% \scratchcounter\numexpression \scratchdimen / 2sp \relax \the\scratchcounter\par
+% \scratchcounter\numexpression \scratchdimen / 1pt \relax \the\scratchcounter\par
+% \scratchcounter\numexpression \scratchdimenone / 65.536pt \relax \the\scratchcounter\par
+% \scratchcounter\numexpression \scratchdimentwo / 2 \relax \the\scratchcounter\par
+
+% \scratchcounter\numexpression \scratchcounterone / 4 \relax \the\scratchcounter\par
+% \scratchdimen \dimexpression \scratchcounterone / 4 \relax \the\scratchdimen\par
+
+% \scratchdimen \dimexpression 2 * 4pt \relax \the\scratchdimen\par
+
+% \tracingexpressions0
+% \tracingonline0
+
+% \startTEXpage
+% \tracingonline1
+% \tracingexpressions1
+% \the\dimexpr -10pt\relax\quad
+% \the\dimexpr 10pt\relax\quad
+% \the\dimexpr 10.12 pt\relax\quad
+% \the\dimexpression -10pt\relax\quad
+% \the\dimexpression 10pt\relax\quad
+% \stopTEXpage
+
+\stopchapter
+
+\stopcomponent
diff --git a/doc/context/sources/general/manuals/followingup/followingup.tex b/doc/context/sources/general/manuals/followingup/followingup.tex
index 417cafcbd..d5be61eea 100644
--- a/doc/context/sources/general/manuals/followingup/followingup.tex
+++ b/doc/context/sources/general/manuals/followingup/followingup.tex
@@ -30,6 +30,7 @@
\component followingup-retrospect
\component followingup-fonts
\component followingup-memory
+ \component followingup-expressions
\component followingup-formats
\stopbodymatter
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
index 573511f32..56523e224 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
@@ -38,27 +38,36 @@ For the engine to work well, the following information has to be present at
the font level:
\starttabulate[|l|l|pl|]
-\DB key \BC value type \BC description \NC \NR
+\DB key \BC value type \BC description \NC \NR
\TB
-\NC \type {name} \NC string \NC metric (file) name \NC \NR
-\NC \type {characters} \NC table \NC the defined glyphs of this font \NC \NR
-\NC \type {designsize} \NC number \NC expected size (default: 655360 == 10pt) \NC \NR
-\NC \type {fonts} \NC table \NC locally used fonts \NC \NR
-\NC \type {hyphenchar} \NC number \NC default: \TEX's \prm {hyphenchar} \NC \NR
-\NC \type {parameters} \NC hash \NC default: 7 parameters, all zero \NC \NR
-\NC \type {size} \NC number \NC the required scaling (by default the same as designsize) \NC \NR
-\NC \type {skewchar} \NC number \NC default: \TEX's \prm {skewchar} \NC \NR
-\NC \type {stretch} \NC number \NC the \quote {stretch} \NC \NR
-\NC \type {shrink} \NC number \NC the \quote {shrink} \NC \NR
-\NC \type {step} \NC number \NC the \quote {step} \NC \NR
-\NC \type {nomath} \NC boolean \NC this key allows a minor speedup for text fonts; if it
- is present and true, then \LUATEX\ will not check the
- character entries for math|-|specific keys \NC \NR
-\NC \type {oldmath} \NC boolean \NC this key flags a font as representing an old school \TEX\
- math font and disables the \OPENTYPE\ code path \NC \NR
-\NC \type {mathcontrol} \NC bitset \NC this controls various code paths in the math engine,
- like enforcing the traditional code path \NC \NR
-\NC \type {textcontrol} \NC bitset \NC this controls various code paths in the text engine \NC \NR
+\NC \type {name} \NC string \NC metric (file) name \NC \NR
+\NC \type {original} \NC string \NC the name used in logging and feedback \NC \NR
+\NC \type {designsize} \NC number \NC expected size (default: 655360 == 10pt) \NC \NR
+\NC \type {size} \NC number \NC the required scaling (by default the same as designsize) \NC \NR
+\HL
+\NC \type {characters} \NC table \NC the defined glyphs of this font \NC \NR
+\NC \type {fonts} \NC table \NC locally used fonts \NC \NR
+\NC \type {parameters} \NC hash \NC default: 7 parameters, all zero \NC \NR
+\HL
+\NC \type {stretch} \NC number \NC the \quote {stretch} \NC \NR
+\NC \type {shrink} \NC number \NC the \quote {shrink} \NC \NR
+\NC \type {step} \NC number \NC the \quote {step} \NC \NR
+\HL
+\NC \type {textcontrol} \NC bitset \NC this controls various code paths in the text engine \NC \NR
+\NC \type {hyphenchar} \NC number \NC default: \TEX's \prm {hyphenchar} \NC \NR
+\HL
+\NC \type {skewchar} \NC number \NC default: \TEX's \prm {skewchar} \NC \NR
+\NC \type {nomath} \NC boolean \NC this key allows a minor speedup for text fonts; if it
+ is present and true, then \LUATEX\ will not check the
+ character entries for math|-|specific keys \NC \NR
+\NC \type {oldmath} \NC boolean \NC this key flags a font as representing an old school \TEX\
+ math font and disables the \OPENTYPE\ code path \NC \NR
+\NC \type {mathcontrol} \NC bitset \NC this controls various code paths in the math engine,
+ like enforcing the traditional code path \NC \NR
+\NC \type {compactmath} \NC boolean \NC experimental: use the smaller chain to locate a character \NC \NR
+\NC \type {textscale} \NC number \NC scale applied to math text \NC \NR
+\NC \type {scriptscale} \NC number \NC scale applied to math script \NC \NR
+\NC \type {scriptscriptscale} \NC number \NC scale applied to math script script \NC \NR
\LL
\stoptabulate
@@ -248,6 +257,11 @@ the possible flags:
context.stoptabulate()
\stopluacode
+Compact math is an experimental feature. The smaller field in a character
+definition of a text character can point to a script character that itself can
+point to a scriptscript one. When set the \type {textscale}, \type {scriptscale}
+and \type {scriptscriptscale} is applied to those.
+
The \type {textcontrol} field is used to control some aspects of text processing.
More options might be added in the future.
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex b/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex
index 646894dbd..31abe2229 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex
@@ -1,13 +1,38 @@
% language=uk
-% lua.newtable
-
\environment luametatex-style
\startcomponent luametatex-metapost
+\startluacode
+ function document.showmpcodes(what)
+ context.type("mplib."..what.."()")
+ context(": ")
+ local t = mplib[what]()
+ for i=0,#t do
+ if i > 0 then
+ context(", ")
+ end
+ context("%i: %s",i,t[i])
+ end
+ end
+\stopluacode
+
\startchapter[reference=metapost,title={The \METAPOST\ library \type {mplib}}]
+\startsection[title={Introduction}][library=mplib]
+
+The library used in \LUAMETATEX\ differs from the one used in \LUATEX. There are
+for instance no backends and the binary number model is not available. There is
+also no textual output. There are scanners and injectors that make it possible to
+enhance the language and efficiently feed back into \METAPOST. File handling is
+now completely delegated to \LUA, so there are more callbacks.
+
+{\em Some functionality is experimental and therefore documentation is limited.
+Also, details are discussed in articles.}
+
+\stopsection
+
\startsection[title={Process management}][library=mplib]
\topicindex {\METAPOST}
@@ -18,12 +43,15 @@
\libindex{version}
The \METAPOST\ library interface registers itself in the table \type {mplib}. It
-is based on \MPLIB\ version \ctxlua {context(mplib.version())}.
+is based on \MPLIB\ version \ctxlua {context(mplib.version())} (\LUATEX\ used
+version 2+). Not all functionality is described here. Once we're out of the
+experimental stage some more information will be added. Using the library boils
+down to initializing an instance, executing statements and picking up assembled
+figures in the form of \LUA\ user data objects (and from there on \LUA\ variables
+like tables).
-Not all functionality is described here. Once we're out of the experimental stage
-some more information will be added.
-\subsection{\type {new}}
+\startsubsection[title={\type {new}}]
\libindex{new}
@@ -37,59 +65,97 @@ This creates the \type {mp} instance object. The argument is a hash table that
can have a number of different fields, as follows:
\starttabulate[|l|l|pl|pl|]
-\DB name \BC type \BC description \BC default \NC \NR
+\DB name \BC type \BC description \BC default \NC \NR
\TB
-\NC \type{error_line} \NC number \NC error line width \NC 79 \NC \NR
-\NC \type{print_line} \NC number \NC line length in ps output \NC 100 \NC \NR
-\NC \type{random_seed} \NC number \NC the initial random seed \NC variable \NC \NR
-\NC \type{math_mode} \NC string \NC the number system to use:
- \type {scaled},
- \type {double} or
- % \type {binary} or
- \type {decimal} \NC \type {scaled} \NC \NR
-\NC \type{interaction} \NC string \NC the interaction mode:
- \type {batch},
- \type {nonstop},
- \type {scroll} or
- \type {errorstop} \NC \type {errorstop} \NC \NR
-\NC \type{job_name} \NC string \NC a compatibility value \NC \NC \NR
-\NC \type{find_file} \NC function \NC a function to find files \NC only local files \NC \NR
-\NC \type{utf8_mode} \NC boolean \NC permit characters in the
- range 128 upto 255 to be
- part of names \NC \type {false} \NC \NR
-\NC \type{text_mode} \NC boolean \NC permit characters 2 and 3
- as fencing string literals \NC \type {false} \NC \NR
+\NC \type {error_line} \NC number \NC error line width \NC 79 \NC \NR
+\NC \type {print_line} \NC number \NC line length in ps output \NC 100 \NC \NR
+\NC \type {random_seed} \NC number \NC the initial random seed \NC variable \NC \NR
+\NC \type {math_mode} \NC string \NC the number system to use:
+ \type {scaled},
+ \type {double} or
+ % \type {binary} or
+ \type {decimal} \NC \type {scaled} \NC \NR
+\NC \type {interaction} \NC string \NC the interaction mode:
+ \type {batch},
+ \type {nonstop},
+ \type {scroll} or
+ \type {errorstop} \NC \type {errorstop} \NC \NR
+\NC \type {job_name} \NC string \NC a compatibility value \NC \NC \NR
+\NC \type {utf8_mode} \NC boolean \NC permit characters in the
+ range 128 upto 255 to be
+ part of names \NC \type {false} \NC \NR
+\NC \type {text_mode} \NC boolean \NC permit characters 2 and 3
+ as fencing string literals \NC \type {false} \NC \NR
+\NC \type {tolerance} \NC number \NC the value used as criterium
+ for straight lines \NC \type {131/65536} \NC \NR
+\NC \type {extensions} \NC boolean \NC enable all extensions \NC (might go) \NC \NR
\LL
\stoptabulate
-The binary mode is no longer available in the \LUATEX\ version of \MPLIB. It
+The binary mode is no longer available in the \LUAMETATEX\ version of \MPLIB. It
offers no real advantage and brings a ton of extra libraries with platform
specific properties that we can now avoid. We might introduce a high resolution
scaled variant at some point but only when it pays of performance wise.
-The \type {find_file} function should be of this form:
-
-\starttyping
-<string> found = finder (<string> name, <string> mode, <string> type)
-\stoptyping
+In addition to the above we need to provide functions that helps \METAPOST\
+communicate to the outside world.
-with:
-
-\starttabulate[|l|p|]
-\DB name \BC the requested file \NC \NR
+\starttabulate[|l|l|pl|pl|]
+\DB name \BC type \BC argument(s) \BC result \NC \NR
\TB
-\NC \type{mode} \NC the file mode: \type {r} or \type {w} \NC \NR
-\NC \type{type} \NC the kind of file, one of: \type {mp}, \type {tfm}, \type {map},
- \type {pfb}, \type {enc} \NC \NR
+\NC \type {find_file} \NC function \NC string, string, string \NC string \NC \NR
+\NC \NC function \NC string, string, number \NC string \NC \NR
+\NC \type {open_file} \NC function \NC string, string, string \NC table \NC \NR
+\NC \NC function \NC string, string, number \NC table \NC \NR
+\NC \type {run_logger} \NC function \NC number, string \NC \NC \NR
+\NC \type {run_script} \NC function \NC string \NC whatever [, boolean] \NC \NR
+\NC \NC function \NC number \NC whatever [, boolean] \NC \NR
+\NC \type {make_text} \NC function \NC string, number \NC string \NC \NR
+\NC \type {run_internal} \NC function \NC number, number, number, string \NC \NC \NR
+\NC \type {run_overload} \NC function \NC number, string, number \NC boolean \NC \NR
+\NC \type {run_error} \NC function \NC string, string, number \NC \NC \NR
\LL
\stoptabulate
-Return either the full path name of the found file, or \type {nil} if the file
-cannot be found.
+The \type {find_file} and \type {open_file} functions should be of this form:
+
+\starttyping
+<string> found = find_file (<string> name, <string> mode, <string> type)
+<table> actions = open_file (<string> name, <string> mode, <string> type)
+\stoptyping
-Note that the new version of \MPLIB\ no longer uses binary mem files, so the way
-to preload a set of macros is simply to start off with an \type {input} command
-in the first \type {execute} call.
+where the mode is \type {r} or \type {w} and the type is \type {mp}, \type
+{data}, \type {terminal} or a number, The finder is supposed to return the full
+path name of the found file, or \type {nil} if the file cannot be found. The
+\type {open_file} is supposed to return a table with a \type {close} and \type
+{read} function. This is similar to the way we do it in \TEX. The special name
+\type {terminal} is used for interactive input. A numeric type indicates a
+specific read or write channel.
+
+The \type {run_logger} callback gets a target and a string. A target \type {1}
+means log, a value \type {2} means and \type {3} means both.
+
+The \type {run_script} function gets either a number or a string. The string
+represents a script, the number can be used as reference to something stored. The
+return value can be a boolean, number, string or table. Booleans and numbers are
+injected directly, strings and concatenated tables are fed into scantokens. When
+the second argument is true, the strings are also injected directly and tables
+are injected as pairs, colors, paths, transforms, depending on how many elements
+there are.
+
+The \type {run_internal} function triggers when internal \METAPOST\ variables
+flagged with \type {runscript} are initialized, saved or restored. The first
+argument is an index, the second the action. When initialized a third and fourth
+argument are passed. This is an experimental feature.
+
+The experimental \type {run_overload} callback kicks in when a variable (or
+macro) with a property other than zero is redefined. It gets a property, name and
+the value of \type {overloadmode} passed and when the function returns \type
+{true} redefinition is permitted.
+
+The \type {run_error} callback gets the error message, help text and current
+interaction mode passed. Normally it's best to just quit and let the user fix
+the code.
When you are processing a snippet of text starting with \type {btex} or \type
{verbatimtex} and ending with \type {etex}, the \METAPOST\ \type {texscriptmode}
@@ -109,29 +175,39 @@ Possible values are:
That way the \LUA\ handler (assigned to \type {make_text}) can do what it likes.
An \type {etex} has to be followed by a space or \type {;} or be at the end of a
-line and preceded by a space or at the beginning of a line.
+line and preceded by a space or at the beginning of a line. The \type {make_text}
+function can return a string that gets fed into scantokens.
-\subsection{\type {statistics}}
+\stopsubsection
+
+\startsubsection[title={\type {getstatistics}}]
\libindex{statistics}
You can request statistics with:
\startfunctioncall
-<table> stats = mp:statistics()
+<table> stats = mp:getstatistics()
\stopfunctioncall
-This function returns the vital statistics for an \MPLIB\ instance. There are
-four fields, giving the maximum number of used items in each of four allocated
-object classes:
+This function returns the vital statistics for an \MPLIB\ instance. Some are
+useful, others make more sense when debugging.
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
\TB
-\NC \type{main_memory} \NC number \NC memory size \NC \NR
-\NC \type{hash_size} \NC number \NC hash size\NC \NR
-\NC \type{param_size} \NC number \NC simultaneous macro parameters\NC \NR
-\NC \type{max_in_open} \NC number \NC input file nesting levels\NC \NR
+\NC \type {memory} \NC number \NC bytes of node memory \NC \NR
+\NC \type {hash} \NC number \NC size of the hash \NC \NR
+\NC \type {parameters} \NC number \NC allocated parameter stack \NC \NR
+\NC \type {input} \NC number \NC allocated input stack \NC \NR
+\NC \type {tokens} \NC number \NC number of token nodes \NC \NR
+\NC \type {pairs} \NC number \NC number of pair nodes \NC \NR
+\NC \type {knots} \NC number \NC number of knot nodes \NC \NR
+\NC \type {nodes} \NC number \NC number of value nodes \NC \NR
+\NC \type {symbols} \NC number \NC number of symbolic nodes \NC \NR
+\NC \type {characters} \NC number \NC number of string bytes \NC \NR
+\NC \type {strings} \NC number \NC number of strings \NC \NR
+\NC \type {internals} \NC number \NC number of internals \NC \NR
\LL
\stoptabulate
@@ -139,7 +215,9 @@ Note that in the new version of \MPLIB, this is informational only. The objects
are all allocated dynamically, so there is no chance of running out of space
unless the available system memory is exhausted.
-\subsection{\type {execute}}
+\stopsubsection
+
+\startsubsection[title={\type {execute}}]
\libindex{execute}
@@ -157,28 +235,93 @@ Generally speaking, it is best to keep your chunks small, but beware that all
chunks have to obey proper syntax, like each of them is a small file. For
instance, you cannot split a single statement over multiple chunks.
-In contrast with the normal stand alone \type {mpost} command, there is
-\notabene {no} implied \quote{input} at the start of the first chunk.
+In contrast with the normal stand alone \type {mpost} command, there is \notabene
+{no} implied \quote{input} at the start of the first chunk. When no string is
+passed to the execute function, there will still be one triggered because it then
+expects input from the terminal and you can emulate that channel with the
+callback you provide.
+
+\stopsubsection
-\subsection{\type {finish}}
+\startsubsection[title={\type {finish}}]
\libindex{finish}
+Once you create an instance it is likely that you will keep it open for
+successive processing, if only because you want to avoid loading a format each
+time. If for some reason you want to stop using an \MPLIB\ instance while
+processing is not yet actually done, you can call \type {finish}.
+
\startfunctioncall
<table> rettable = finish(mp)
\stopfunctioncall
-If for some reason you want to stop using an \MPLIB\ instance while processing is
-not yet actually done, you can call \type {finish}. Eventually, used memory
+Eventually, used memory
will be freed and open files will be closed by the \LUA\ garbage collector, but
an explicit \type {finish} is the only way to capture the final part of the
output streams.
+\stopsubsection
+
+\startsubsection[title={\type {settolerance} and \type {gettolerance}}]
+
+\libindex{gettolerance}
+\libindex{settolerance}
+
+These two functions relate to the bend tolerance, a value that is used when the
+export determines if a path has straight lines (like a rectangle has).
+
+\stopsubsection
+
+\startsubsection[title={Errors}]
+
+\libindex{showcontext}
+
+In case of an error you can get the context where it happened with \type
+{showcontext}.
+
+\stopsubsection
+
+\startsubsection[title={The scanner status}]
+
+\libindex {getstatus}
+\libindex {getstates}
+
+When processing a graphic an instance is in a specific state and again we have a
+getter for the (internal) values \ctxlua {document.showmpcodes ("getstates")}.
+The current status can be queried with \type {getstatus}.
+
+\stopsubsection
+
+\startsubsection[title={The hash}]
+
+\libindex {gethashentries}
+\libindex {gethashentry}
+
+Macro names and variable names are stored in a hash table. You can get a list
+with entries with \type {gethashentries}, which takes an instance as first
+argument. When the second argument is \type {true} more details will be provided.
+With \type {gethashentry} you get info about the given macro or variable.
+
+\stopsubsection
+
+\startsubsection[title={Callbacks}]
+
+\libindex{getcallbackstate}
+
+Some statistics about the number of calls to the callbacks can be queried with
+\type {getcallbackstate}, This function expects a valid instance.
+
+\stopsubsection
+
\stopsection
\startsection[title={The end result}]
+\startsubsection[title={The figure}]
+
\libindex {fields}
+\libindex {stacking}
The return value of \type {execute} and \type {finish} is a table with a
few possible keys (only \type {status} is always guaranteed to be present).
@@ -186,10 +329,6 @@ few possible keys (only \type {status} is always guaranteed to be present).
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
\TB
-\NC \type{log} \NC string \NC output to the \quote {log} stream \NC \NR
-\NC \type{term} \NC string \NC output to the \quote {term} stream \NC \NR
-\NC \type{error} \NC string \NC output to the \quote {error} stream
- (only used for \quote {out of memory}) \NC \NR
\NC \type{status} \NC number \NC the return value:
\type {0} = good,
\type {1} = warning,
@@ -206,20 +345,16 @@ If it is present, each of the entries in the \type {fig} array is a userdata
representing a figure object, and each of those has a number of object methods
you can call:
+You can check if a figure uses stacking with the \type {stacking} function. When
+objects are fetched, memory gets freed so no information about stacking is
+available then. You can get the used bend tolerance of an object with \type
+{tolerance}.
+
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
\TB
\NC \type{boundingbox} \NC function \NC returns the bounding box, as an array of 4
values \NC \NR
-\NC \type{postscript} \NC function \NC returns a string that is the ps output of the
- \type {fig}. this function accepts two optional
- integer arguments for specifying the values of
- \type {prologues} (first argument) and \type
- {procset} (second argument) \NC \NR
-\NC \type{svg} \NC function \NC returns a string that is the svg output of the
- \type {fig}. This function accepts an optional
- integer argument for specifying the value of
- \type {prologues} \NC \NR
\NC \type{objects} \NC function \NC returns the actual array of graphic objects in
this \type {fig} \NC \NR
\NC \type{filename} \NC function \NC the filename this \type {fig}'s \POSTSCRIPT\
@@ -230,19 +365,22 @@ you can call:
\NC \type{depth} \NC function \NC the \type {fontchardp} value \NC \NR
\NC \type{italic} \NC function \NC the \type {fontcharit} value \NC \NR
\NC \type{charcode} \NC function \NC the (rounded) \type {charcode} value \NC \NR
+\NC \type{stacking} \NC function \NC is there a non|-|zero stacking \NC \NR
\LL
\stoptabulate
Note: you can call \type {fig:objects()} only once for any one \type {fig}
-object!
+object! Some information, like stacking, can only be queried when the complete
+figure is still present and calling up objects will free elements in the original
+once they are transferred.
When the boundingbox represents a \quote {negated rectangle}, i.e.\ when the
first set of coordinates is larger than the second set, the picture is empty.
Graphical objects come in various types: \type {fill}, \type {outline}, \type
{text}, \type {start_clip}, \type {stop_clip}, \type {start_bounds}, \type
-{stop_bounds}, \type {special}. Each type has a different list of accessible
-values.
+{stop_bounds}, \type {start_group} and \type {stop_group}. Each type has a
+different list of accessible values.
There is a helper function (\type {mplib.fields(obj)}) to get the list of
accessible values for a particular object, but you can just as easily use the
@@ -250,11 +388,13 @@ tables given below.
All graphical objects have a field \type {type} that gives the object type as a
string value; it is not explicit mentioned in the following tables. In the
-following, \type {number}s are \POSTSCRIPT\ points represented as a floating
-point number, unless stated otherwise. Field values that are of type \type
-{table} are explained in the next section.
+following, \type {number}s are \POSTSCRIPT\ points (base points in \TEX\ speak)
+represented as a floating point number, unless stated otherwise. Field values
+that are of type \type {table} are explained in the next section.
+
+\stopsubsection
-\subsection{fill}
+\startsubsection[title={fill}]
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
@@ -267,12 +407,15 @@ point number, unless stated otherwise. Field values that are of type \type
\NC \type{miterlimit} \NC number \NC miterlimit\NC \NR
\NC \type{prescript} \NC string \NC the prescript text \NC \NR
\NC \type{postscript} \NC string \NC the postscript text \NC \NR
+\NC \type{stacking} \NC number \NC the stacking (level) \NC \NR
\LL
\stoptabulate
The entries \type {htap} and \type {pen} are optional.
-\subsection{outline}
+\stopsubsection
+
+\startsubsection[title={outline}]
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
@@ -286,56 +429,44 @@ The entries \type {htap} and \type {pen} are optional.
\NC \type{dash} \NC table \NC representation of a dash list \NC \NR
\NC \type{prescript} \NC string \NC the prescript text \NC \NR
\NC \type{postscript} \NC string \NC the postscript text \NC \NR
+\NC \type{stacking} \NC number \NC the stacking (level) \NC \NR
\LL
\stoptabulate
The entry \type {dash} is optional.
-\subsection{text}
+\stopsubsection
+
+\startsubsection[title={start_bounds, start_clip, start_group}]
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
\TB
-\NC \type{text} \NC string \NC the text \NC \NR
-\NC \type{font} \NC string \NC font tfm name \NC \NR
-\NC \type{dsize} \NC number \NC font size \NC \NR
-\NC \type{color} \NC table \NC the object's color \NC \NR
-\NC \type{width} \NC number \NC \NC \NR
-\NC \type{height} \NC number \NC \NC \NR
-\NC \type{depth} \NC number \NC \NC \NR
-\NC \type{transform} \NC table \NC a text transformation \NC \NR
-\NC \type{prescript} \NC string \NC the prescript text \NC \NR
-\NC \type{postscript} \NC string \NC the postscript text \NC \NR
+\NC \type{path} \NC table \NC the list of knots \NC \NR
+\NC \type{stacking} \NC number \NC the stacking (level) \NC \NR
\LL
\stoptabulate
-\subsection{special}
+\stopsubsection
-\starttabulate[|l|l|p|]
-\DB field \BC type \BC explanation \NC \NR
-\TB
-\NC \type{prescript} \NC string \NC special text \NC \NR
-\LL
-\stoptabulate
+\startsubsection[title={stop_bounds, stop_clip, stop_group}]
-\subsection{start_bounds, start_clip}
+Here we have only one key:
\starttabulate[|l|l|p|]
\DB field \BC type \BC explanation \NC \NR
\TB
-\NC \type{path} \NC table \NC the list of knots \NC \NR
+\NC \type{stacking} \NC number \NC the stacking (level) \NC \NR
\LL
\stoptabulate
-\subsubsection{stop_bounds, stop_clip}
-
-Here are no fields available.
+\stopsubsection
\stopsection
\startsection[title={Subsidiary table formats}]
-\subsection{Paths and pens}
+\startsubsection[title={Paths and pens}]
Paths and pens (that are really just a special type of paths as far as \MPLIB\ is
concerned) are represented by an array where each entry is a table that
@@ -359,7 +490,9 @@ There is one special case: pens that are (possibly transformed) ellipses have an
extra key \type {type} with value \type {elliptical} besides the array part
containing the knot list.
-\subsection{Colors}
+\stopsubsection
+
+\startsubsection[title={Colors}]
A color is an integer array with 0, 1, 3 or 4 values:
@@ -377,7 +510,9 @@ If the color model of the internal object was \type {uninitialized}, then it was
initialized to the values representing \quote {black} in the colorspace \type
{defaultcolormodel} that was in effect at the time of the \type {shipout}.
-\subsection{Transforms}
+\stopsubsection
+
+\startsubsection[title={Transforms}]
Each transform is a six|-|item array.
@@ -396,7 +531,9 @@ Each transform is a six|-|item array.
Note that the translation (index 1 and 2) comes first. This differs from the
ordering in \POSTSCRIPT, where the translation comes last.
-\subsection{Dashes}
+\stopsubsection
+
+\startsubsection[title={Dashes}]
Each \type {dash} is a hash with two items. We use the same model as \POSTSCRIPT\
for the representation of the dashlist. \type {dashes} is an array of \quote {on}
@@ -410,7 +547,9 @@ and \quote {off}, values, and \type {offset} is the phase of the pattern.
\LL
\stoptabulate
-\subsection{Pens and \type {peninfo}}
+\stopsubsection
+
+\startsubsection[title={Pens and \type {peninfo}}]
\libindex{peninfo}
@@ -430,7 +569,9 @@ a bunch of vital characteristics of the used pen (all values are floats):
\LL
\stoptabulate
-\subsection[title={Character size information}]
+\stopsubsection
+
+\startsubsection[title={Character size information}]
\libindex{char_width}
\libindex{char_height}
@@ -446,6 +587,8 @@ id in the range 0 to 255; the returned \type {w} is in AFM units.
<number> d = char_depth(mp,<string> fontname, <number> char)
\stopfunctioncall
+\stopsubsection
+
\stopsection
\startsection[title=Scanners]
@@ -472,34 +615,16 @@ still preliminary and mostly provided as reminder.
\NC \type{scantransform} \NC instance, hashed, type \NC table or six numbers \NC \NR
\NC \type{scanpath} \NC instance, hashed, type \NC table with hashes or arrays \NC \NR
\NC \type{scanpen} \NC instance, hashed, type \NC table with hashes or arrays \NC \NR
+\NC \type{scanproperty} \NC {\em todo} \NC \NC \NR
+\HL
+\NC \type{skiptoken} \NC {\em todo} \NC \NC \NR
\LL
\stoptabulate
The types and token codes are numbers but they actually depend on the
implementation (although changes are unlikely). The types of data structures can
-be queried with \type {mplib.gettypes()}:
-
-\dontleavehmode \startluacode
- local t = mplib.gettypes()
- for i=0,#t do
- if i > 0 then
- context(", ")
- end
- context("%i: %s",i,t[i])
- end
-\stopluacode .
-
-The command codes are available with \type {mplib.getcodes()}:
-
-\dontleavehmode \startluacode
- local t = mplib.getcodes()
- for i=0,#t do
- if i > 0 then
- context(", ")
- end
- context("%i: %s",i,t[i])
- end
-\stopluacode .
+be queried with \ctxlua {document.showmpcodes ("gettypes")}, and command codes
+with \ctxlua {document.showmpcodes ("getcodes")}
Now, if you really want to use these, keep in mind that the internals of
\METAPOST\ are not trivial, especially because expression scanning can be
@@ -508,6 +633,38 @@ hidden below an abstraction layer so users are not bothered by all these
look|-|ahead and push|-|back issues that originate in the way \METAPOST\ scans
its input.
+The supported color models are: \ctxlua {document.showmpcodes ("getcolormodels")}.
+
+If you want the internal codes of the possible fields in a graphic object use
+\ctxlua {document.showmpcodes ("getobjecttypes")}. You can query the id of a
+graphic object with the \type {gettype} function.
+
+\startluacode
+local t = mplib.getobjecttypes()
+local f = mplib.getfields()
+context.starttabulate { "|T|T|Tpl|" }
+ context.DB()
+ context("id")
+ context.BC()
+ context("object")
+ context.BC()
+ context("fields")
+ context.NC()
+ context.NR()
+ for i=1,#t do
+ context.NC()
+ context(i)
+ context.NC()
+ context(t[i])
+ context.NC()
+ context("% t",f[i])
+ context.NC()
+ context.NR()
+ end
+ context.LL()
+context.stoptabulate()
+\stopluacode
+
\stopsection
\startsection[title=Injectors]
@@ -531,6 +688,7 @@ optimized. The other data structures were then added for completeness.}
\NC \type{injectcmykcolor} \NC instance, (table with) four numbers \NC \NR
\NC \type{injecttransform} \NC instance, (table with) six numbers \NC \NR
\NC \type{injectpath} \NC instance, table with hashes or arrays, cycle, variant \NC \NR
+\NC \type{injectwhatever} \NC instance, ont of the above depending on type and size \NC \NR
\LL
\stoptabulate
@@ -541,6 +699,63 @@ the value \type {true} the path is closed. When the fourth argument is \type
setting the \type {curl} values to~1 automatically. \footnote {This is all
experimental so future versions might provide more control.}
+This is the simplest path definition:
+
+\starttyping
+{
+ { x, y },
+ ...,
+ cycle = true
+}
+\stoptyping
+
+and this one also has the control points:
+
+\starttyping
+{
+ { x0, y0, x1, y1, x2, y2 },
+ ...,
+ cycle = true
+}
+\stoptyping
+
+A very detailed specification is this but you have to make sure that the
+parameters make sense.
+
+\starttyping
+{
+ {
+ x_coord = ...,
+ y_coord = ...,
+ left_x = ...,
+ left_y = ...,
+ right_x = ...,
+ right_y = ...,
+ left_tension = ...,
+ right_tension = ...,
+ left_curl = ...,
+ right_curl = ...,
+ direction_x = ...,
+ direction_y = ...,
+ left_type = ...,
+ right_type = ...,
+ },
+ ...,
+ cycle = true
+}
+\stoptyping
+
+Instead of the optional keyword \type {cycle} you can use \type {close}.
+
+\stopsection
+
+\startsection[title={To be checked}]
+
+\starttyping
+% solvepath
+% expandtex
+\stoptyping
+
\stopsection
\stopchapter
diff --git a/metapost/context/base/mpiv/mp-back.mpiv b/metapost/context/base/mpiv/mp-back.mpiv
index e77b3f0d9..dccae92e8 100644
--- a/metapost/context/base/mpiv/mp-back.mpiv
+++ b/metapost/context/base/mpiv/mp-back.mpiv
@@ -33,6 +33,23 @@ def some_hash ( expr hash_width ,
endgroup ;
enddef ;
+% \starttext
+%
+% \startMPpage
+% input "mp-back"
+%
+% some_double_back (1, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, .6white, .7white, .6white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (2, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, .6white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (3, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (4, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (5, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (6, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (7, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white) currentpicture := currentpicture shifted (0,-3cm) ;
+% some_double_back (8, 4.5cm, 1.5cm, .25cm, 1mm, .5white, .8white, .7white, white, white, white)
+% \stopMPpage
+
+% \stoptext
+
def some_double_back (expr back_type ,
back_width ,
back_height ,
@@ -163,49 +180,3 @@ def some_double_back (expr back_type ,
endgroup;
enddef ;
-
-% endinput ;
-%
-% beginfig (1) ;
-%
-% some_double_back (1, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, .6white, .7white, .6white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (2, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, .6white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (3, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (4, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (5, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (6, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (7, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% currentpicture := currentpicture shifted (0,-3cm) ;
-%
-% some_double_back (8, 4.5cm, 1.5cm, .25cm, 1mm,
-% .5white, .8white, .7white, white, white, white)
-%
-% endfig ;
-%
-% end .
diff --git a/metapost/context/base/mpiv/mp-idea.mpiv b/metapost/context/base/mpiv/mp-idea.mpiv
deleted file mode 100644
index d417ab51f..000000000
--- a/metapost/context/base/mpiv/mp-idea.mpiv
+++ /dev/null
@@ -1,44 +0,0 @@
-% redpart (1,1,0,0) crashes
-
-% let normalredpart = redpart ;
-% let normalgreenpart = greenpart ;
-% let normalbluepart = bluepart ;
-% let normalcyanpart = cyanpart ;
-% let normalmagentapart = magentapart ;
-% let normalyellowpart = yellowpart ;
-% let normalblackpart = blackpart ;
-
-% vardef redpart expr p = if cmykcolor p : 1 - normalcyanpart p elseif rgbcolor p : normalredpart p else : p fi enddef ;
-% vardef greenpart expr p = if cmykcolor p : 1 - normalmagentapart p elseif rgbcolor p : normalgreenpart p else : p fi enddef ;
-% vardef bluepart expr p = if cmykcolor p : 1 - normalyellowpart p elseif rgbcolor p : normalbluepart p else : p fi enddef ;
-% vardef cyanpart expr p = if cmykcolor p : normalcyanpart p elseif rgbcolor p : 1 - normalredpart p else : p fi enddef ;
-% vardef magentapart expr p = if cmykcolor p : normalmagentapart p elseif rgbcolor p : 1 - normalgreenpart p else : p fi enddef ;
-% vardef yellowpart expr p = if cmykcolor p : normalyellowpart p elseif rgbcolor p : 1 - normalbluepart p else : p fi enddef ;
-% vardef blackpart expr p = if cmykcolor p : normalblackpart p elseif rgbcolor p : 0 else : p fi enddef ;
-
-vardef rcomponent expr p = if rgbcolor p : redpart p elseif cmykcolor p : 1 - cyanpart p else : p fi enddef ;
-vardef gcomponent expr p = if rgbcolor p : greenpart p elseif cmykcolor p : 1 - magentapart p else : p fi enddef ;
-vardef bcomponent expr p = if rgbcolor p : bluepart p elseif cmykcolor p : 1 - yellowpart p else : p fi enddef ;
-vardef ccomponent expr p = if cmykcolor p : cyanpart p elseif rgbcolor p : 1 - redpart p else : p fi enddef ;
-vardef mcomponent expr p = if cmykcolor p : magentapart p elseif rgbcolor p : 1 - greenpart p else : p fi enddef ;
-vardef ycomponent expr p = if cmykcolor p : yellowpart p elseif rgbcolor p : 1 - bluepart p else : p fi enddef ;
-vardef bcomponent expr p = if cmykcolor p : blackpart p elseif rgbcolor p : 0 else : p fi enddef ;
-
-vardef somecolor = (1,1,0,0) enddef ;
-
-fill OverlayBox withcolor (rcomponent somecolor,gcomponent somecolor,bcomponent somecolor) ;
-fill OverlayBox withcolor (ccomponent somecolor,mcomponent somecolor,ycomponent somecolor,bcomponent somecolor) ;
-
-% def newcolor text v = forsuffixes i=v : save i ; color i ; endfor ; enddef ;
-% def newnumeric text v = forsuffixes i=v : save i ; numeric i ; endfor ; enddef ;
-% def newboolean text v = forsuffixes i=v : save i ; boolean i ; endfor ; enddef ;
-% def newtransform text v = forsuffixes i=v : save i ; transform i ; endfor ; enddef ;
-% def newpath text v = forsuffixes i=v : save i ; path i ; endfor ; enddef ;
-% def newpicture text v = forsuffixes i=v : save i ; picture i ; endfor ; enddef ;
-% def newstring text v = forsuffixes i=v : save i ; string i ; endfor ; enddef ;
-
-% width := 10 ;
-% beginfig(1) ;
-% newpath width, height ; width := origin -- cycle ;
-% endfig ;
-% width := 10 ;
diff --git a/metapost/context/base/mpiv/mp-xbox.mpiv b/metapost/context/base/mpiv/mp-xbox.mpiv
index 4b4c4c3cd..be5630a5e 100644
--- a/metapost/context/base/mpiv/mp-xbox.mpiv
+++ b/metapost/context/base/mpiv/mp-xbox.mpiv
@@ -284,6 +284,11 @@ def boxes_init_all =
def boxes_clear_all = enddef;
enddef ;
+def boxjoin(text t) =
+ def boxes_prevbox = _ enddef;
+ def boxes_dojoin(suffix a,b) = t enddef;
+enddef;
+
extra_beginfig := extra_beginfig & "boxes_init_all;";
extra_endfig := "boxes_clear_all;" & extra_endfig;
diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl
index a6f931fbd..05302493b 100644
--- a/metapost/context/base/mpxl/mp-tool.mpxl
+++ b/metapost/context/base/mpxl/mp-tool.mpxl
@@ -32,7 +32,7 @@ if not known mpversion : string mpversion ; mpversion := "0.641" ; fi ;
% newinternal metapostversion ; metapostversion := scantokens(mpversion) ;
-newinternal metapostversion ; metapostversion := 2.0 ; permanent metapostversion ;
+newinternal metapostversion ; metapostversion := 3.0 ; permanent metapostversion ;
%D We always want \EPS\ conforming output, so we say:
diff --git a/metapost/context/base/mpxl/mp-xbox.mpxl b/metapost/context/base/mpxl/mp-xbox.mpxl
index 65a3da775..2b8b94c27 100644
--- a/metapost/context/base/mpxl/mp-xbox.mpxl
+++ b/metapost/context/base/mpxl/mp-xbox.mpxl
@@ -283,6 +283,11 @@ def boxes_init_all =
def boxes_clear_all = enddef;
enddef ;
+def boxjoin(text t) =
+ def boxes_prevbox = _ enddef;
+ def boxes_dojoin(suffix a,b) = t enddef;
+enddef;
+
extra_beginfig := extra_beginfig & "boxes_init_all;";
extra_endfig := "boxes_clear_all;" & extra_endfig;
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 997e26845..7a00e7ffa 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -17729,7 +17729,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54667, stripped down to: 31258
+-- original size: 54733, stripped down to: 31258
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -25895,8 +25895,8 @@ end -- of closure
-- used libraries : l-bit32.lua 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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1024620
--- stripped bytes : 402087
+-- original bytes : 1024686
+-- stripped bytes : 402153
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 997e26845..7a00e7ffa 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -17729,7 +17729,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54667, stripped down to: 31258
+-- original size: 54733, stripped down to: 31258
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -25895,8 +25895,8 @@ end -- of closure
-- used libraries : l-bit32.lua 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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1024620
--- stripped bytes : 402087
+-- original bytes : 1024686
+-- stripped bytes : 402153
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 997e26845..7a00e7ffa 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -17729,7 +17729,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54667, stripped down to: 31258
+-- original size: 54733, stripped down to: 31258
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -25895,8 +25895,8 @@ end -- of closure
-- used libraries : l-bit32.lua 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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1024620
--- stripped bytes : 402087
+-- original bytes : 1024686
+-- stripped bytes : 402153
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 997e26845..7a00e7ffa 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -17729,7 +17729,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54667, stripped down to: 31258
+-- original size: 54733, stripped down to: 31258
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -25895,8 +25895,8 @@ end -- of closure
-- used libraries : l-bit32.lua 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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1024620
--- stripped bytes : 402087
+-- original bytes : 1024686
+-- stripped bytes : 402153
-- end library merge
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index 5f88118e5..ddc6e4c94 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{2021.07.16 21:58}
+\newcontextversion{2021.07.21 19:51}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index f82269d66..f51879ef6 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{2021.07.16 21:58}
+\edef\contextversion{2021.07.21 19:51}
%D For those who want to use this:
diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii
index de20eb6f0..0390fcdbc 100644
--- a/tex/context/base/mkii/mult-fr.mkii
+++ b/tex/context/base/mkii/mult-fr.mkii
@@ -1236,6 +1236,7 @@
\setinterfaceconstant{splitoffset}{decalagepartage}
\setinterfaceconstant{spot}{tondirect}
\setinterfaceconstant{stack}{pile}
+\setinterfaceconstant{stacking}{stacking}
\setinterfaceconstant{stackname}{nompile}
\setinterfaceconstant{start}{début}
\setinterfaceconstant{starter}{demarreur}
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index f805e1f8d..668a2bb71 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.07.16 21:58}
+\newcontextversion{2021.07.21 19:51}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 11f827ce2..c49efc796 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -45,7 +45,7 @@
%D {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2021.07.16 21:58}
+\edef\contextversion{2021.07.21 19:51}
%D Kind of special:
diff --git a/tex/context/base/mkiv/lxml-lpt.lua b/tex/context/base/mkiv/lxml-lpt.lua
index 9e4b475fb..78a9fca2e 100644
--- a/tex/context/base/mkiv/lxml-lpt.lua
+++ b/tex/context/base/mkiv/lxml-lpt.lua
@@ -635,7 +635,9 @@ local builtin = {
match = "(ll.mi or 1)",
namespace = "ll.ns",
ns = "ll.ns",
-
+ -- new
+ -- attribute = "ll.at",
+ -- at = "ll.at",
}
local lp_builtin = lpeg.utfchartabletopattern(builtin)/builtin * ((spaces * P("(") * spaces * P(")"))/"")
diff --git a/tex/context/base/mkiv/page-lin.mkvi b/tex/context/base/mkiv/page-lin.mkvi
index e355e3e60..3a54d1ef5 100644
--- a/tex/context/base/mkiv/page-lin.mkvi
+++ b/tex/context/base/mkiv/page-lin.mkvi
@@ -352,7 +352,9 @@
\def\page_lines_add_numbers_to_box#box#column#max#nesting%
{\bgroup
- \strc_tags_enable_indeed
+ \ifconditional\c_strc_tags_enabled
+ \strc_tags_enable_indeed
+ \fi
\b_page_lines_number #box\relax
\c_page_lines_column #column\relax
\c_page_lines_last_column#max\relax
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 751c819da..82fa2f6a3 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 0737a3f55..26b23cda0 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/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index 8c029b2e4..70b47d75d 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.07.16 21:58}
+\newcontextversion{2021.07.21 19:51}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index 9b1e70180..67ecc671c 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2021.07.16 21:58}
+\immutable\edef\contextversion{2021.07.21 19:51}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/lpdf-tag.lmt b/tex/context/base/mkxl/lpdf-tag.lmt
index 21f5b246d..8c76ca694 100644
--- a/tex/context/base/mkxl/lpdf-tag.lmt
+++ b/tex/context/base/mkxl/lpdf-tag.lmt
@@ -81,6 +81,8 @@ local parent_ref -- delayed
local root -- delayed
local names = { }
local tree = { }
+local firstintree = false
+local lastintree = false
local elements = { }
local structurestags = structures.tags
@@ -137,9 +139,14 @@ local function finishstructure()
if root and #structure_kids > 0 then
local nums = pdfarray()
local n = 0
- for i=1,#tree do
- n = n + 1 ; nums[n] = i - 1
- n = n + 1 ; nums[n] = pdfreference(pdfflushobject(tree[i]))
+ for i=firstintree,lastintree do
+ local ti = tree[i]
+ if ti then
+ n = n + 1 ; nums[n] = i - 1
+ n = n + 1 ; nums[n] = pdfreference(pdfflushobject(ti))
+ else
+ report_tags("beware: missing page %i in tree", i)
+ end
end
local parenttree = pdfdictionary {
Nums = nums
@@ -191,6 +198,19 @@ local function initializepage()
pagenum = texgetcount("realpageno")
pageref = pdfreference(pdfpagereference(pagenum))
list = pdfarray()
+ -- hm, can be later than 1
+ if not firstintree then
+ if pagenum > 1 then
+ report_tags("beware: first page in tree is %i", pagenum)
+ end
+ firstintree = pagenum
+ lastintree = pagenum
+ end
+ if pagenum > lastintree then
+ lastintree = pagenum
+ else
+ report_tags("beware: page order problem in tree at page %i", pagenum)
+ end
tree[pagenum] = list -- we can flush after done, todo
end
@@ -382,19 +402,19 @@ function nodeinjections.addtags(head)
for n, id in nextnode, head do
if id == glyph_code then
-- maybe also disc
-if getchar(n) ~= 0 then
- local at = getattr(n,a_tagged) or false -- false: pagebody or so, so artifact
- -- if not at then
- -- range = nil
- -- elseif ...
- if last ~= at then
- range = { at, "glyph", n, n, list } -- attr id start stop list
- ranges[#ranges+1] = range
- last = at
- elseif range then
- range[4] = n -- stop
+ if getchar(n) ~= 0 then
+ local at = getattr(n,a_tagged) or false -- false: pagebody or so, so artifact
+ -- if not at then
+ -- range = nil
+ -- elseif ...
+ if last ~= at then
+ range = { at, "glyph", n, n, list } -- attr id start stop list
+ ranges[#ranges+1] = range
+ last = at
+ elseif range then
+ range[4] = n -- stop
+ end
end
-end
elseif id == hlist_code or id == vlist_code then
local at = getattr(n,a_image)
if at then
diff --git a/tex/context/base/mkxl/page-lin.mklx b/tex/context/base/mkxl/page-lin.mklx
index 3b3a3d71b..5a1dc2e60 100644
--- a/tex/context/base/mkxl/page-lin.mklx
+++ b/tex/context/base/mkxl/page-lin.mklx
@@ -344,7 +344,9 @@
\def\page_lines_add_numbers_to_box#box#column#max#nesting%
{\bgroup
- \strc_tags_enable_indeed
+ \ifconditional\c_strc_tags_enabled
+ \strc_tags_enable_indeed
+ \fi
\b_page_lines_number #box\relax
\c_page_lines_column #column\relax
\c_page_lines_last_column#max\relax
@@ -466,13 +468,13 @@
\dostoptagged}%
\dostoptagged}
-\setuvalue{\??linenumberinghandler\v!left}%
+\protected\defcsname\??linenumberinghandler\v!left\endcsname
{\page_line_handle_left\p_align\leftmarginwidth\leftmargindistance}
-\setuvalue{\??linenumberinghandler\v!right}%
+\protected\defcsname\??linenumberinghandler\v!right\endcsname
{\page_line_handle_right\p_align\rightmarginwidth\rightmargindistance}
-\setuvalue{\??linenumberinghandler\v!inner}%
+\protected\defcsname\??linenumberinghandler\v!inner\endcsname
{\ifodd\realpageno
\ifx\p_align\v!inner
\page_line_handle_left\v!flushleft\leftmarginwidth\leftmargindistance
@@ -491,7 +493,7 @@
\fi
\fi}
-\setuvalue{\??linenumberinghandler\v!outer}%
+\protected\defcsname\??linenumberinghandler\v!outer\endcsname
{\ifodd\realpageno
\ifx\p_align\v!inner
\page_line_handle_right\v!flushleft\leftmarginwidth\leftmargindistance
diff --git a/tex/context/base/mkxl/strc-tag.mkxl b/tex/context/base/mkxl/strc-tag.mkxl
index 96371b6b5..55f8125f8 100644
--- a/tex/context/base/mkxl/strc-tag.mkxl
+++ b/tex/context/base/mkxl/strc-tag.mkxl
@@ -335,6 +335,8 @@
{\enforced\let\getelementtag \donothing
\enforced\let\setupelementuserproperties\gobbletwooptionals}
+\strc_tags_disable
+
%D The triggers:
\newtoks\everyenableelements
diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml
index 3093727aa..beaf78112 100644
--- a/tex/context/interface/mkii/keys-fr.xml
+++ b/tex/context/interface/mkii/keys-fr.xml
@@ -1242,6 +1242,7 @@
<cd:constant name='splitoffset' value='decalagepartage'/>
<cd:constant name='spot' value='tondirect'/>
<cd:constant name='stack' value='pile'/>
+ <cd:constant name='stacking' value='stacking'/>
<cd:constant name='stackname' value='nompile'/>
<cd:constant name='start' value='début'/>
<cd:constant name='starter' value='demarreur'/>
diff --git a/tex/context/modules/mkiv/m-compatible.mkiv b/tex/context/modules/mkiv/m-compatible.mkiv
index 0e056180a..7e6e733ec 100644
--- a/tex/context/modules/mkiv/m-compatible.mkiv
+++ b/tex/context/modules/mkiv/m-compatible.mkiv
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\ifcase\contextlmtxmode\else\endinput\fi
+
%D I fear that I will not keep up in this file so feel free to contribute to the
%D following. The idea is nto to load this file but more to have some insight in
%D how to control compatibility (to some extent).
@@ -58,6 +60,4 @@
% \input page-cst.mkiv
-
-
\endinput
diff --git a/tex/context/modules/mkiv/m-mkii.mkiv b/tex/context/modules/mkiv/m-mkii.mkiv
index dcfd29d20..4961b7380 100644
--- a/tex/context/modules/mkiv/m-mkii.mkiv
+++ b/tex/context/modules/mkiv/m-mkii.mkiv
@@ -1,5 +1,7 @@
% todo
+\ifcase\contextlmtxmode\else\endinput\fi
+
\unprotect
\writestatus\m!system{loading some mkii compatibility hacks}
diff --git a/tex/context/modules/mkiv/m-obsolete.mkiv b/tex/context/modules/mkiv/m-obsolete.mkiv
index 2d4518181..73fb1c167 100644
--- a/tex/context/modules/mkiv/m-obsolete.mkiv
+++ b/tex/context/modules/mkiv/m-obsolete.mkiv
@@ -1,3 +1,5 @@
+\ifcase\contextlmtxmode\else\endinput\fi
+
\unprotect
\writestatus\m!system{skipping obsolete module}
diff --git a/tex/context/modules/mkiv/m-oldfun.mkiv b/tex/context/modules/mkiv/m-oldfun.mkiv
index f20d7d8e9..9530aa065 100644
--- a/tex/context/modules/mkiv/m-oldfun.mkiv
+++ b/tex/context/modules/mkiv/m-oldfun.mkiv
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\ifcase\contextlmtxmode\else\endinput\fi
+
\unprotect
%D Beware, these macros wil be replaced and at some point this
diff --git a/tex/context/modules/mkiv/m-oldnum.mkiv b/tex/context/modules/mkiv/m-oldnum.mkiv
index 5109cca12..63ac15085 100644
--- a/tex/context/modules/mkiv/m-oldnum.mkiv
+++ b/tex/context/modules/mkiv/m-oldnum.mkiv
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\ifcase\contextlmtxmode\else\endinput\fi
+
% See end for transition to mkiv.
\writestatus{loading}{ConTeXt Support Macros / Numbers}
diff --git a/tex/context/modules/mkiv/m-units.mkiv b/tex/context/modules/mkiv/m-units.mkiv
index 4f25fffc6..02d1b6aa7 100644
--- a/tex/context/modules/mkiv/m-units.mkiv
+++ b/tex/context/modules/mkiv/m-units.mkiv
@@ -11,6 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
+\ifcase\contextlmtxmode\else\endinput\fi
+
%D Best use the built in unit handle!
%D Scientific units can be typeset in math mode pretty well,
diff --git a/tex/context/modules/mkxl/m-openstreetmap.lmt b/tex/context/modules/mkxl/m-openstreetmap.lmt
new file mode 100644
index 000000000..2116ae236
--- /dev/null
+++ b/tex/context/modules/mkxl/m-openstreetmap.lmt
@@ -0,0 +1,906 @@
+if not modules then modules = { } end modules ['m-openstreetmap'] = {
+ version = 1.001,
+ comment = "companion to m-openstreetmap.mkxl",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local sin, cos, floor, ceil = math.sin, math.cos, math.floor, math.ceil
+local formatters = string.formatters
+local concat, tohash, sortedhash, setmetatableindex, insert = table.concat, table.tohash, table.sortedhash, table.setmetatableindex, table.insert
+local xmlcollected, xmlparent, xmlfirst, xmlfilter = xml.collected, xml.parent, xml.first, xml.filter
+local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg, lpeg.match
+
+local openstreetmap = { }
+moduledata.openstreetmap = openstreetmap
+
+local report = logs.reporter("openstreetmap")
+
+-- At one of the bachotex meetings Mojca and I sat down to render the bachotek camp site
+-- as available in openstreetmap. Of course that was a limited setup and after figuring
+-- out some details it went well. Of course we used metapost.
+--
+-- Years later in 2021 on the mailing list there was some discussion on country outlines
+-- and disappointed by the quality of what was referred to I remembered the openstreetmap
+-- adventure. I found that I could export my hometown from the web page so I started from
+-- that: just stepwise seeing what 'ways' passed and assigning them colors. Just as with
+-- the bachotex drawing.
+--
+-- Then I went searching for what tags actually were available and ran into:
+--
+-- https://github.com/openstreetmap/osm2pgsql/blob/master/docs/lua.md
+--
+-- I'm not sure where the script is used, and there are dead linsk on these pages but some
+-- information can be found in that file so I could combine our findings with these. There
+-- is a whole infrastructure out there with impressive machinery, style sheet generation
+-- etc. but we don't need that here. Also, we don't need to play routes.
+--
+-- Colors are one thing (not too hard with a k/v mapping), but a nest hurdle is to decide
+-- what is a polygon. Actually I found that just checking on something being closed is
+-- rather ok. There are a few extra ones. But we can also use the list in the file mentioned.
+-- We probably need to check it occasionally with the original, although it looks quite
+-- stable.
+
+local polygons = tohash {
+ "abandoned:aeroway", "abandoned:amenity", "abandoned:building",
+ "abandoned:landuse", "abandoned:power", "aeroway", "allotments",
+ "amenity", "area:highway", "craft", "building", "building:part", "club",
+ "golf", "emergency", "harbour", "healthcare", "historic", "landuse",
+ "leisure", "man_made", "military", "natural", "office", "place", "power",
+ "public_transport", "shop", "tourism", "water", "waterway", "wetland",
+
+ -- "bridge",
+}
+
+-- The amenity tag is sort of overloading the main tag so we put it in the main
+-- hash. This might change.
+--
+-- The stacking order is important and we just started with processing the tags
+-- in a certain order. However, in \LUAMETATEX\ we can now use stacking so that
+-- makes for a nice test. At the cost of a bit more metapost code and conversion
+-- time we can use that. Anyway, this is the list we use and it's an adaption
+-- from the bachitex one.
+
+local order = {
+ "landuse",
+ "leisure",
+ "natural",
+ -- "geological",
+
+ "water",
+ "amenity",
+ "building",
+ "barrier",
+ "man_made",
+ "bridge",
+
+ "historic",
+ "military",
+
+ -- "office",
+ -- "craft",
+
+ -- "emergency",
+ -- "healthcare",
+ -- "place",
+ -- "power",
+ -- "shop",
+ -- "sport",
+ -- "telecom",
+
+ -- "publictransport",
+
+ "waterway",
+ "highway",
+ "railway",
+ "aeroway",
+ "aerialway",
+
+ -- "tourism",
+ "boundary", -- overlaps ! not okay for hasselt.osm
+ -- "route",
+}
+
+-- From the mentioned lua file we get the stacking (funny numbers are used):
+
+-- In Hasselt we have a combination, highway should win :
+--
+-- <tag k="bridge" v="yes"/>
+-- <tag k="highway" v="footway"/>
+
+local stacking = {
+ highway = {
+ motorway = 180,
+ trunk = 170,
+ primary = 160,
+ secondary = 150,
+ tertiary = 140,
+ residential = 130,
+ unclassified = 130,
+ road = 130,
+ living_street = 120,
+ pedestrian = 110,
+ raceway = 100,
+ motorway_link = 140,
+ trunk_link = 130,
+ primary_link = 120,
+ secondary_link = 110,
+ tertiary_link = 100,
+ service = 150,
+ track = 110,
+ path = 100,
+ footway = 100,
+ bridleway = 100,
+ cycleway = 100,
+ steps = 190,
+ platform = 190,
+ },
+ railway = {
+ rail = 140,
+ subway = 120,
+ narrow_gauge = 120,
+ light_rail = 120,
+ funicular = 120,
+ preserved = 120,
+ monorail = 120,
+ miniature = 120,
+ turntable = 120,
+ tram = 110,
+ disused = 100,
+ construction = 100,
+ platform = 190,
+ },
+ aeroway = {
+ runway = 160,
+ taxiway = 150,
+ },
+ boundary = {
+ administrative = 0,
+ },
+
+ -- bridge = {
+ -- yes = 103,
+ -- movable = 102,
+ -- viaduct = 103,
+ -- },
+}
+
+setmetatableindex(stacking,function(t,k)
+ local v = setmetatableindex(function(t,k)
+ t[k] = false return false
+ end)
+ t[k] = v
+ return v
+end)
+
+-- reservoir_covered: @ bachotex
+
+local colors = {
+
+ -- these concern details:
+
+ amenity = {
+ arts_centre = true,
+ bar = true,
+ bicycle_parking = true,
+ college = true,
+ courthouse = true,
+ fountain = true,
+ hospital = true,
+ kindergarten = true,
+ marketplace = true,
+ parking = true,
+ parking_space = true,
+ pharmacy = true,
+ place_of_worship = true,
+ police = true,
+ restaurant = true,
+ school = true,
+ shower = true,
+ social_facility = true,
+ toilets = true,
+ townhall = true,
+ university = true,
+ },
+
+ -- these are basic:
+
+ boundary = {
+ aboriginal_lands = true,
+ national_park = true,
+ protected_area = true,
+ administrative = true,
+ },
+ building = {
+ apartments = true,
+ bandstand = true,
+ cathedral = true,
+ civic = true,
+ commercial = true,
+ construction = true, -- no roadtrip
+ garage = true,
+ government = true,
+ hospital = true,
+ house = true,
+ houseboat = true,
+ hut = true,
+ industrial = true,
+ kiosk = true,
+ public = true,
+ residential = true,
+ retail = true,
+ roof = true,
+ school = true,
+ shed = true,
+ townhall = true,
+ yes = true,
+ },
+ emergency = {
+ designated = true,
+ destination = true,
+ no = true,
+ official = true,
+ yes = true,
+ },
+ man_made = {
+ breakwater = true,
+ bridge = true,
+ instrument = true,
+ pier = true,
+ quay = true,
+ tower = true,
+ windmill = true,
+ cutline = true,
+ embankment = true,
+ groyne = true,
+ pipeline = true,
+ },
+ natural = {
+ arete = true,
+ cliff = true,
+ earth_bank = true,
+ ridge = true,
+ sand = true,
+ scrub = true,
+ tree_row = true,
+ water = true,
+ wetland = true,
+ wood = true,
+ },
+ barrier = {
+ chain = true,
+ city_wall = true,
+ fence = true,
+ gate = true,
+ guard_rail = true,
+ hedge = true,
+ retaining_wall = true,
+ wall = true,
+ yes = true,
+ },
+ leisure = {
+ garden = true,
+ ice_rink = true,
+ marina = true,
+ park = true,
+ pitch = true,
+ playground = true,
+ slipway = true,
+ sports_centre = true,
+ track = true,
+ beach = true,
+ },
+ boat = {
+ yes = true,
+ },
+ landuse = {
+ allotments = true,
+ cemetery = true,
+ commercial = true,
+ construction = true,
+ forest = true,
+ grass = true,
+ industrial = true,
+ meadow = true,
+ residential = true,
+ static_building = true,
+ village_green = true,
+ },
+ ["bridge:support"] = {
+ pier = true,
+ },
+ golf = { -- funny, this category
+ cartpath = true,
+ hole = true,
+ path = true,
+ },
+ area = {
+ yes = true,
+ },
+ bridge = {
+ yes = true,
+ movable = true,
+ viaduct = true,
+ },
+ agricultural = {
+ yes = true,
+ no = true,
+ },
+ historic = {
+ citywalls = true,
+ },
+ tourism = {
+ yes = true,
+ },
+ power = {
+ cable = true,
+ line = true,
+ minor_line = true,
+ },
+ junction = {
+ yes = true,
+ },
+ water = {
+ river = true,
+ basin = true,
+ },
+
+ -- these indicate routes:
+
+ highway = {
+ corridor = true,
+ bridleway = true,
+ cycleway = true,
+ footway = true,
+ living_street = true,
+ motorway = true,
+ motorway_link = true,
+ path = true,
+ pedestrian = true,
+ platform = true,
+ primary = true,
+ primary_link = true,
+ raceway = true,
+ residential = true,
+ rest_area = true,
+ road = true,
+ -- secondary = true,
+ secondary_link = true,
+ service = true,
+ services = true,
+ steps = true,
+ tertiary = true,
+ tertiary_link = true,
+ track = true,
+ trunk = true,
+ trunk_link = true,
+ unclassified = true,
+ },
+ waterway = {
+ canal = true,
+ derelict_canal = true,
+ ditch = true,
+ drain = true,
+ river = true,
+ stream = true,
+ tidal_channel = true,
+ wadi = true,
+ weir = true,
+ },
+ railway = {
+ construction = true,
+ disused = true,
+ funicular = true,
+ light_rail = true,
+ miniature = true,
+ monorail = true,
+ narrow_gauge = true,
+ platform = true,
+ preserved = true,
+ rail = true,
+ station = true,
+ subway = true,
+ tram = true,
+ turntable = true,
+ },
+
+ aeroway = {
+ runway = true,
+ taxiway = true,
+ },
+ aerialway = {
+ station = true,
+ },
+}
+
+-- We use this 'inside' knowledge encoded in the mentioned script to avoid bad fills
+-- (for instance polygons can be unconnected and unordered). We define the table a bit
+-- different.
+
+local forcedlines = {
+ golf = { "cartpath", "hole", "path" },
+ emergency = { "designated", "destination", "no", "official", "yes" },
+ historic = { "citywalls" },
+ leisure = { "track", "slipway" },
+ man_made = { "breakwater", "cutline", "embankment", "groyne", "pipeline" },
+ natural = { "cliff", "earth_bank", "tree_row", "ridge", "arete" },
+ power = { "cable", "line", "minor_line" },
+ tourism = { "yes"},
+ waterway = { "canal", "derelict_canal", "ditch", "drain", "river", "stream", "tidal_channel", "wadi", "weir" },
+}
+
+do
+
+ local function never(t,k) t[k] = false return false end
+
+ for k, v in next, forcedlines do
+ forcedlines[k] = setmetatableindex(tohash(v),never)
+ end
+
+ setmetatableindex(forcedlines,function(t,k)
+ local v = setmetatableindex(never)
+ t[k] = v
+ return v
+ end)
+
+end
+
+-- For fast checking we apply the usual context tricks:
+
+
+for k, v in next, colors do
+ for kk, vv in next, v do
+ v[kk] = "osm:" .. k .. ":" .. kk
+ end
+end
+
+-- We draw and fill but sometimes we do both:
+
+local lines = {
+ amenity = true,
+ building = true,
+ man_made = true,
+ boat = true,
+}
+
+-- When checking labels for a while I had a blacklist of tags (keys) but
+-- dropped that when most was done. So, we're now ready for the real deal:
+
+-- this only works for positive numbers
+
+local f_f_degree_to_str = formatters["%d°%d’%.0f”"]
+
+local function f_degree_to_str(num)
+ local deg = floor(num)
+ num = (num - deg) * 60
+ local min = floor(num)
+ num = (num - min) * 60
+ local sec = num
+ return f_f_degree_to_str(deg,min,sec)
+end
+
+-- local f_pattern = formatters["/osm/(way|relation)[@visible='true']/tag[@k='%s']"]
+local f_pattern = formatters["/osm/(way|relation)[@visible!='false']/tag[@k='%s']"]
+local f_way = formatters["/osm/way[@id='%s']"]
+local f_relation = formatters["/osm/relation[@id='%s']"]
+
+-- We could reuse paths and concat 0,n in the call but when testing it the gain was
+-- not much so I went for readability.
+
+local f_draw = formatters['D %--t W "%s";']
+local f_fill = formatters['F %--t--C W "%s";']
+local f_both = formatters['P := %--t--C; F P W "%s"; D P W "white" L 2;']
+local f_draw_s = formatters['D %--t W "%s" L %s;']
+local f_fill_s = formatters['F %--t--C W "%s" L %s;']
+local f_both_s = formatters['P := %--t--C; F P W "%s"; D P W "white" L %s;']
+
+local f_nodraw = formatters['ND %--t;']
+local f_nofill = formatters['NF %--t--C;']
+local f_nodraw_s = formatters['ND %--t;']
+local f_nofill_s = formatters['NF %--t--C;']
+
+local f_background = formatters['F %--t -- C W "osm:background";']
+local f_bounds = formatters['setbounds currentpicture to %--t--C ;']
+
+-- For now no labels are printed, also because that's now what we use this for. At
+-- some point I will provide some hooks to put text at coordinates.
+
+-- local f_draw_p = formatters["path p ; p := %--t ; D p W %s;"]
+-- local f_fill_p = formatters["path p ; p := %--t -- C ; F p W %s;"]
+-- local f_textext = formatters['draw (textext("\\bf %s") scaled 0.35) shifted center p withcolor white;']
+
+-- Grids were also part of the original code, so I kept that. It's done a bit more
+-- efficient by using a single path.
+
+local f_draw_grid_b = formatters['nodraw %--t L 100;']
+local f_draw_grid_e = formatters['dodraw origin dashed %s withcolor "osm:grid" withpen pencircle scaled %N L 100;']
+local f_label_lat = formatters['label.urt((textext("\\infofont\\strut %s")), %s shifted (3,0)) withcolor white L 100;']
+local f_label_lon = formatters['label.top((textext("\\infofont\\strut %s")), %s shifted (0,3)) withcolor white L 100;']
+
+local beginmp = [[
+ begingroup ;
+ pickup pencircle scaled 1 ;
+ save P ; path P ;
+ save D ; let D = draw ;
+ save F ; let F = fill ;
+ save C ; let C = cycle ;
+ save W ; let W = withcolor ;
+ save L ; let L = withstacking ;
+ save ND ; let ND = nodraw ;
+ save DD ; let DD = dodraw ;
+ save NF ; let NF = nofill ;
+ save DF ; let DF = dofill ;
+]]
+
+local endmp = [[
+ endgroup;
+]]
+
+local p_strip = lpeg.Cs( (
+ (
+ ( P("version") + P("changeset") + P("timestamp") + P("user") + P("uid") )
+ * P('="') * (1-P('"'))^0 * P('"')
+ ) / ""
+ + P(">") * (S("\n\r\t\f ")^1 / "") * P("<")
+ + P('visible="true"') / ""
+ + P(1)
+)^1 )
+
+function openstreetmap.convert(specification)
+
+ local starttime = os.clock()
+ local filename = specification.filename
+
+ if not io.exists(filename) then
+ return
+ end
+
+ report("processing file %a",filename)
+
+ -- we can consider stripping crap first
+
+ -- local root = xml.load(filename)
+
+ local root = io.loaddata(filename)
+ local olds = #root
+ root = lpegmatch(p_strip,root)
+ local news = #root
+
+ report("original size %i bytes, stripped down to %i bytes",olds,news)
+
+ root = xml.convert(root)
+
+ if root.error then
+ report("error in xml",olds,news)
+ return
+ else
+ report("xml data loaded")
+ end
+
+ local bounds = xmlfirst(root,"/osm/bounds")
+ if not bounds then
+ return
+ end
+
+ local usercolors = specification.used
+ local usedcolors = table.copy(colors)
+
+ if usercolors then
+ for k, v in next, usercolors do
+ local u = usedcolors[k]
+ if not u then
+ -- error
+ elseif v == false then
+ usedcolors[k] = false
+ -- for k in next, u do
+ -- u[k] = false
+ -- end
+ elseif type(v) == "string" then
+ for k in next, u do
+ u[k] = v
+ end
+ elseif type(v) == "table" then
+ for kk, vv in next, v do
+ if vv == false then
+ u[kk] = false
+ elseif type(vv) == "string" then
+ u[kk] = vv
+ end
+ end
+ end
+ end
+ end
+
+ -- inspect(usedcolors)
+
+ local minlat = bounds.at.minlat
+ local minlon = bounds.at.minlon
+ local maxlat = bounds.at.maxlat
+ local maxlon = bounds.at.maxlon
+ local midlat = 0.5 * (minlat + maxlat)
+ local deg_to_rad = math.pi / 180.0
+ local scale = 3600 -- vertical scale: 1" = 1cm
+
+ local function f_pair(lon, lat)
+ return formatters("(%.3Ncm,%.3Ncm)", (lon - minlon) * scale * cos(midlat * deg_to_rad), (lat-minlat) * scale)
+ end
+
+ local rendering = table.tohash(order)
+ local coordinates = { }
+ local ways = { }
+ local result = { }
+ local r = 0
+ local done = { }
+ local missing = false -- setmetatableindex("table")
+ local layers = { }
+ local areas = { }
+
+ for c in xmlcollected(root,"/osm/node") do
+ local a = c.at
+ coordinates[a.id] = a
+ end
+
+ for c in xmlcollected(root,"/osm/way") do
+ ways[c.at.id] = c
+ end
+
+ for c in xml.collected(root,"tag[@k='area']") do
+ areas[c] = c.at.v
+ end
+
+ for c in xml.collected(root,"tag[@k='layer']") do
+ layers[c] = c.at.v
+ end
+
+ -- Collecting is more a private option. It doesn't save much on the output
+ -- but looks better with transparency, which makes no sense using anyway.
+
+ local collected = specification.collect and setmetatableindex(function(t,k)
+ local v = setmetatableindex(function(t,k)
+ local v = {
+ draw = setmetatableindex("table"),
+ fill = setmetatableindex("table"),
+ }
+ t[k] = v
+ return v
+ end)
+ t[k] = v
+ return v
+ end) or false
+
+ local function drawshapes(what,order)
+
+ -- see bachotex rendering for an example
+ -- also layer and polygon
+
+ function xml.expressions.osm(k)
+ return usedcolors[k]
+ end
+
+ local function getcolor(r)
+ local t = xmlfirst(r,"/tag[osm(@k)]")
+ if t then
+ local at = t.at
+ local v = at.v
+ if v ~= "no" then
+ local k = at.k
+ local col = usedcolors[k][v]
+ -- we need an example: if layers[r] then print(layers[r]) end
+ if col then
+ -- todo : trace colors and stacking
+ return k, col, lines[k], stacking[k][v], forcedlines[k][v]
+ elseif missing then
+ missing[k][v] = (missing[k][v] or 0) + 1
+ end
+ end
+ end
+ end
+
+ local function addpath(r, p, n)
+ -- if done[r] then
+ -- print("AGAIN")
+ -- else
+ for c in xmlcollected(r,"/nd") do
+ local coordinate = coordinates[c.at.ref]
+ if coordinate then
+ n = n + 1 p[n] = f_pair(coordinate.lon, coordinate.lat)
+ end
+ end
+ -- done[r] = true
+ -- end
+ return p, n
+ end
+
+ local checkpath = collected and
+
+ function(parent,p,n)
+ local what, color, both, stacking, forced = getcolor(parent)
+ if what and rendering[what] then
+ local where = collected[stacking or order]
+ if not polygons[what] or forced or areas[parent] == "no" then
+ insert(where[color] .draw, f_nodraw(p))
+ elseif both then
+ insert(where[color] .fill, f_nofill(p))
+ insert(where["white"].draw, f_nodraw(p))
+ else
+ insert(where[color] .fill, f_nofill(p))
+ end
+ end
+ end
+
+ or
+
+ function(parent,p,n)
+ local what, color, both, stacking, forced = getcolor(parent)
+ if what and rendering[what] then
+ r = r + 1
+ -- if not stacking then
+ -- stacking = order
+ -- end
+ if not polygons[what] or forced or areas[parent] == "no" then
+ result[r] = stacking and f_draw_s(p,color,stacking) or f_draw(p,color)
+ elseif both then
+ result[r] = stacking and f_both_s(p,color,stacking) or f_both(p,color)
+ else
+ result[r] = stacking and f_fill_s(p,color,stacking) or f_fill(p,color)
+ end
+ end
+ end
+
+ -- There are ways and relations. Relations can have members that poitn to
+ -- ways but also relations. My impression is that we can stick to way members
+ -- but I'll deal with that when needed.
+
+ for c in xmlcollected(root,f_pattern(what)) do
+ local parent = xmlparent(c)
+ local tag = parent.tg
+ if tag == "way" then
+ local p, n = addpath(parent, { }, 0)
+ if n > 1 then
+ checkpath(parent,p,n)
+ end
+ elseif tag == "relation" then
+ if xmlfilter(parent,"xml://tag[@k='type' and (@v='multipolygon' or @v='boundary' or @v='route')]") then
+ local what, color, both, stacking, forced = getcolor(parent)
+ if rendering[what] then
+ local p, n = { }, 0
+ for m in xmlcollected(parent,"/member[(@type='way') and (@role='outer')]") do
+ -- local f = xmlfirst(root,f_way(m.at.ref))
+ local f = ways[m.at.ref]
+ if f then
+ p, n = addpath(f,p,n)
+ end
+ end
+ if n > 1 then
+ checkpath(parent,p,n)
+ end
+ end
+ else
+ for m in xmlcollected(parent,"/member[@type='way']") do
+ -- local f = xmlfirst(root,f_way(m.at.ref))
+ local f = ways[m.at.ref]
+ if f then
+ local p, n = addpath(f, { }, 0)
+ if n > 1 then
+ checkpath(parent,p,n)
+ end
+ end
+ end
+ end
+ end
+ end
+
+ end
+
+ -- As with the other latitude and longitude mapping calculations the next magick
+ -- comes from Mojca.
+
+ local function drawgrid()
+ local lat0 = ceil (3600*minlat)
+ local lat1 = floor(3600*maxlat)
+ local pen = tonumber(specification.griddot) or 1.5
+ local lat
+ local labels = { }
+ for i=lat0,lat1 do
+ lat = i/3600
+ local p = {
+ f_pair(minlon,lat),
+ f_pair(maxlon,lat),
+ }
+ r = r + 1 result[r] = f_draw_grid_b(p)
+ if i ~= lat0 and i ~= lat1 then
+ labels[#labels+1] = f_label_lat(f_degree_to_str(lat),p[1])
+ end
+ end
+
+ local lon0 = ceil (1800*minlon)*2
+ local lon1 = floor(1800*maxlon)*2
+ local lon
+ for i=lon0,lon1,2 do
+ lon=i/3600
+ local p = {
+ f_pair(lon, minlat),
+ f_pair(lon, maxlat),
+ }
+ r = r + 1 result[r] = f_draw_grid_b(p)
+ if i ~= lon0 and i ~= lon1 then
+ labels[#labels+1] = f_label_lon(f_degree_to_str(lon),p[1])
+ end
+ end
+ r = r + 1 result[r] = f_draw_grid_e("withdots", pen)
+ r = r + 1 result[r] = concat(labels)
+ end
+
+ -- We add a background first and clip later. Beware: There can be substantial bits
+ -- outside the clip path (like rivers) but because paths are not that detailed we
+ -- don't wast time on building a cycle. We could check if points are ouside the
+ -- boundingbox and then use the metapost buildpath macro .. some day.
+
+ local boundary = {
+ f_pair(minlon,minlat),
+ f_pair(maxlon,minlat),
+ f_pair(maxlon,maxlat),
+ f_pair(minlon,maxlat),
+ }
+
+ r = r + 1 result[r] = beginmp
+ r = r + 1 result[r] = f_background(boundary)
+
+ -- r = r + 1 result[r] = "drawoptions (withtransparency (1,.5)) ;"
+
+ -- use stacking instead
+
+ for i=1,#order do
+ local o = order[i]
+ if usedcolors[o] then
+ drawshapes(o,i)
+ end
+ end
+
+ if specification.grid == "dots" then
+ drawgrid()
+ end
+
+ if collected then
+
+ for stacking, colors in sortedhash(collected) do
+ for color, bunch in next, colors do
+ local draw = bunch.draw
+ local fill = bunch.fill
+ if fill and #fill > 0 then
+ r = r + 1 result[r] = "draw image ("
+ r = r + 1 result[r] = concat(fill)
+ r = r + 1 result[r] = 'DF origin--cycle;'
+ r = r + 1 result[r] = formatters[') W "%s" L %s;'](color,stacking) ;
+ end
+ if draw and #draw > 0 then
+ r = r + 1 result[r] = "draw image ("
+ r = r + 1 result[r] = concat(draw)
+ r = r + 1 result[r] = 'DD origin;'
+ r = r + 1 result[r] = formatters[') W "%s" L %s;'](color,stacking+1) ;
+ end
+ end
+ end
+
+ end
+
+ r = r + 1 result[r] = f_bounds(boundary)
+ r = r + 1 result[r] = endmp
+
+ if missing then
+ inspect(missing)
+ end
+
+ result = concat(result)
+
+ report("%s characters metapost code, preprocessing time %0.3f seconds",#result,os.clock()-starttime)
+
+ return result
+
+end
+
+function mp.lmt_do_openstreetmap()
+ local specification = metapost.getparameterset("openstreetmap")
+ return openstreetmap.convert(specification)
+end
diff --git a/tex/context/modules/mkxl/m-openstreetmap.mkxl b/tex/context/modules/mkxl/m-openstreetmap.mkxl
new file mode 100644
index 000000000..677a5a04d
--- /dev/null
+++ b/tex/context/modules/mkxl/m-openstreetmap.mkxl
@@ -0,0 +1,461 @@
+%D \module
+%D [ file=m-database,
+%D version=2020.07.18,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Rendering Openstreetmap,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is a follow up on something that Mojca and I did at at bachotex
+%D meeting. Some attendants had made up that map during a few years. The
+%D \CONTEXT\ group donated a map that could be mounted outside drawn by
+%D Duane and after that we decided to see if we could keep up by rendering
+%D the openstreetmap variant with \METAPOST.
+%D
+%D There are some comments in the \LUA\ file and that one might evolve over
+%D time as there is some trial and error involved. The \typ {osm} file is
+%D read in, stripped a bit, the \XML\ is analyzed and \METAPOST\ code is
+%D generated. The level of detail can be influenced.
+
+% This will change ... users are invited to come with variants.
+
+\definecolor [osm:special] [s=.25]
+
+\definecolor [osm:building:special] [r=.75]
+\definecolor [osm:building] [r=.50]
+
+\definecolor [osm:parking] [s=.25]
+\definecolor [osm:bridge] [s=.50]
+\definecolor [osm:quay] [s=.25]
+\definecolor [osm:barrier] [s=.25]
+\definecolor [osm:industrial] [s=.70]
+\definecolor [osm:residential] [s=.75]
+\definecolor [osm:cemetery] [s=.50]
+
+\definecolor [osm:boat] [b=.25]
+
+\definecolor [osm:water] [b=.75]
+\definecolor [osm:waterway] [r=.75,g=.75]
+
+\definecolor [osm:wetland] [g=.25]
+\definecolor [osm:grass] [g=.50]
+\definecolor [osm:park] [g=.60]
+\definecolor [osm:forest] [g=.75]
+
+\definecolor [osm:sand] [y=.75]
+
+\definecolor [osm:footway] [b=.3]
+\definecolor [osm:cycleway] [b=.5]
+\definecolor [osm:path] [b=.7]
+\definecolor [osm:track] [s=.4]
+
+\definecolor [osm:bridge] [s=.25]
+\definecolor [osm:bridge:special] [s=.50]
+
+\definecolor [osm:unknown] [s=0]
+
+\definecolor [osm:background] [s=.8]
+\definecolor [osm:grid] [s=1]
+
+% We can define them global, in which case we can check for actually
+% used colors.
+
+\definecolor[osm:aerialway:station] [osm:unknown]
+
+\definecolor[osm:aeroway:runway] [osm:unknown]
+\definecolor[osm:aeroway:taxiway] [osm:unknown]
+
+\definecolor[osm:agricultural:no] [osm:unknown]
+\definecolor[osm:agricultural:yes] [osm:unknown]
+
+\definecolor[osm:amenity:arts_centre] [osm:building:special]
+\definecolor[osm:amenity:bar] [osm:building:special]
+\definecolor[osm:amenity:bicycle_parking] [osm:parking]
+\definecolor[osm:amenity:college] [osm:building:special]
+\definecolor[osm:amenity:courthouse] [osm:building:special]
+\definecolor[osm:amenity:fountain] [osm:building:special]
+\definecolor[osm:amenity:hospital] [osm:building:special]
+\definecolor[osm:amenity:kindergarten] [osm:building:special]
+\definecolor[osm:amenity:marketplace] [osm:parking]
+\definecolor[osm:amenity:parking] [osm:parking]
+\definecolor[osm:amenity:parking_space] [osm:parking]
+\definecolor[osm:amenity:pharmacy] [osm:building:special]
+\definecolor[osm:amenity:place_of_worship] [osm:building:special]
+\definecolor[osm:amenity:police] [osm:building:special]
+\definecolor[osm:amenity:restaurant] [osm:building:special]
+\definecolor[osm:amenity:school] [osm:building:special]
+\definecolor[osm:amenity:shower] [osm:building:special]
+\definecolor[osm:amenity:social_facility] [osm:building:special]
+\definecolor[osm:amenity:toilets] [osm:building:special]
+\definecolor[osm:amenity:townhall] [osm:building:special]
+\definecolor[osm:amenity:university] [osm:building:special]
+
+\definecolor[osm:area:yes] [osm:unknown]
+
+\definecolor[osm:barrier:chain] [osm:barrier]
+\definecolor[osm:barrier:city_wall] [osm:barrier]
+\definecolor[osm:barrier:fence] [osm:barrier]
+\definecolor[osm:barrier:gate] [osm:barrier]
+\definecolor[osm:barrier:guard_rail] [osm:barrier]
+\definecolor[osm:barrier:hedge] [osm:barrier]
+\definecolor[osm:barrier:retaining_wall] [osm:barrier]
+\definecolor[osm:barrier:wall] [osm:barrier]
+\definecolor[osm:barrier:yes] [osm:barrier]
+
+\definecolor[osm:boat:yes] [osm:boat]
+
+\definecolor[osm:boundary:aboriginal_lands] [osm:unknown]
+\definecolor[osm:boundary:administrative] [osm:unknown]
+\definecolor[osm:boundary:national_park] [osm:unknown]
+\definecolor[osm:boundary:protected_area] [osm:unknown]
+
+\definecolor[osm:bridge:movable] [osm:bridge:special]
+\definecolor[osm:bridge:viaduct] [osm:bridge]
+\definecolor[osm:bridge:yes] [osm:footway]
+
+\definecolor[osm:bridge:support:pier] [osm:special]
+
+\definecolor[osm:building:apartments] [osm:building]
+\definecolor[osm:building:bandstand] [osm:building:special]
+\definecolor[osm:building:cathedral] [osm:building]
+\definecolor[osm:building:civic] [osm:building]
+\definecolor[osm:building:commercial] [osm:building:special]
+\definecolor[osm:building:construction] [osm:building:special]
+\definecolor[osm:building:garage] [osm:building]
+\definecolor[osm:building:government] [osm:building]
+\definecolor[osm:building:hospital] [osm:building]
+\definecolor[osm:building:house] [osm:building]
+\definecolor[osm:building:houseboat] [osm:boat]
+\definecolor[osm:building:hut] [osm:building]
+\definecolor[osm:building:industrial] [osm:building:special]
+\definecolor[osm:building:kiosk] [osm:building:special]
+\definecolor[osm:building:public] [osm:building]
+\definecolor[osm:building:residential] [osm:building]
+\definecolor[osm:building:retail] [osm:building:special]
+\definecolor[osm:building:roof] [osm:building]
+\definecolor[osm:building:school] [osm:building:special]
+\definecolor[osm:building:shed] [osm:building]
+\definecolor[osm:building:townhall] [osm:building]
+\definecolor[osm:building:yes] [osm:building]
+
+\definecolor[osm:emergency:designated] [osm:unknown]
+\definecolor[osm:emergency:destination] [osm:unknown]
+\definecolor[osm:emergency:no] [osm:unknown]
+\definecolor[osm:emergency:official] [osm:unknown]
+\definecolor[osm:emergency:yes] [osm:unknown]
+
+\definecolor[osm:golf:cartpath] [osm:unknown]
+\definecolor[osm:golf:hole] [osm:unknown]
+\definecolor[osm:golf:path] [osm:unknown]
+
+\definecolor[osm:highway:bridleway] [osm:unknown]
+\definecolor[osm:highway:corridor] [osm:track]
+\definecolor[osm:highway:cycleway] [osm:cycleway]
+\definecolor[osm:highway:footway] [osm:footway]
+\definecolor[osm:highway:living_street] [osm:track]
+\definecolor[osm:highway:motorway] [osm:unknown]
+\definecolor[osm:highway:motorway_link] [osm:unknown]
+\definecolor[osm:highway:path] [osm:path]
+\definecolor[osm:highway:pedestrian] [osm:track]
+\definecolor[osm:highway:platform] [osm:unknown]
+\definecolor[osm:highway:primary] [osm:track]
+\definecolor[osm:highway:primary_link] [osm:unknown]
+\definecolor[osm:highway:raceway] [osm:unknown]
+\definecolor[osm:highway:residential] [osm:track]
+\definecolor[osm:highway:rest_area] [osm:unknown]
+\definecolor[osm:highway:road] [osm:unknown]
+\definecolor[osm:highway:secondary_link] [osm:unknown]
+\definecolor[osm:highway:service] [osm:track]
+\definecolor[osm:highway:services] [osm:unknown]
+\definecolor[osm:highway:steps] [osm:track]
+\definecolor[osm:highway:tertiary] [osm:track]
+\definecolor[osm:highway:tertiary_link] [osm:unknown]
+\definecolor[osm:highway:track] [osm:track]
+\definecolor[osm:highway:trunk] [osm:unknown]
+\definecolor[osm:highway:trunk_link] [osm:unknown]
+\definecolor[osm:highway:unclassified] [osm:track]
+
+\definecolor[osm:historic:citywalls] [osm:unknown]
+
+\definecolor[osm:junction:yes] [osm:unknown]
+
+\definecolor[osm:landuse:allotments] [osm:grass]
+\definecolor[osm:landuse:cemetery] [osm:cemetery]
+\definecolor[osm:landuse:commercial] [osm:industrial]
+\definecolor[osm:landuse:construction] [osm:industrial]
+\definecolor[osm:landuse:forest] [osm:forest]
+\definecolor[osm:landuse:grass] [osm:grass]
+\definecolor[osm:landuse:industrial] [osm:industrial]
+\definecolor[osm:landuse:meadow] [osm:grass]
+\definecolor[osm:landuse:residential] [osm:residential]
+\definecolor[osm:landuse:static_building] [osm:special]
+\definecolor[osm:landuse:village_green] [osm:forest]
+
+\definecolor[osm:leisure:beach] [osm:sand]
+\definecolor[osm:leisure:garden] [osm:park]
+\definecolor[osm:leisure:ice_rink] [osm:water]
+\definecolor[osm:leisure:marina] [osm:quay]
+\definecolor[osm:leisure:park] [osm:park]
+\definecolor[osm:leisure:pitch] [osm:special]
+\definecolor[osm:leisure:playground] [osm:special]
+\definecolor[osm:leisure:slipway] [osm:unknown]
+\definecolor[osm:leisure:sports_centre] [osm:special]
+\definecolor[osm:leisure:track] [osm:track]
+
+\definecolor[osm:man_made:breakwater] [osm:water]
+\definecolor[osm:man_made:bridge] [osm:bridge]
+\definecolor[osm:man_made:cutline] [osm:unknown]
+\definecolor[osm:man_made:embankment] [osm:unknown]
+\definecolor[osm:man_made:groyne] [osm:unknown]
+\definecolor[osm:man_made:instrument] [osm:special]
+\definecolor[osm:man_made:pier] [osm:quay]
+\definecolor[osm:man_made:pipeline] [osm:unknown]
+\definecolor[osm:man_made:quay] [osm:quay]
+\definecolor[osm:man_made:tower] [osm:special]
+\definecolor[osm:man_made:windmill] [osm:special]
+
+\definecolor[osm:natural:arete] [osm:unknown]
+\definecolor[osm:natural:cliff] [osm:unknown]
+\definecolor[osm:natural:earth_bank] [osm:unknown]
+\definecolor[osm:natural:ridge] [osm:unknown]
+\definecolor[osm:natural:sand] [osm:sand]
+\definecolor[osm:natural:scrub] [osm:forest]
+\definecolor[osm:natural:tree_row] [osm:forest]
+\definecolor[osm:natural:water] [osm:water]
+\definecolor[osm:natural:wetland] [osm:wetland]
+\definecolor[osm:natural:wood] [osm:forest]
+
+\definecolor[osm:power:cable] [osm:unknown]
+\definecolor[osm:power:line] [osm:unknown]
+\definecolor[osm:power:minor_line] [osm:unknown]
+
+\definecolor[osm:railway:construction] [osm:unknown]
+\definecolor[osm:railway:disused] [osm:unknown]
+\definecolor[osm:railway:funicular] [osm:unknown]
+\definecolor[osm:railway:light_rail] [osm:unknown]
+\definecolor[osm:railway:miniature] [osm:unknown]
+\definecolor[osm:railway:monorail] [osm:unknown]
+\definecolor[osm:railway:narrow_gauge] [osm:unknown]
+\definecolor[osm:railway:platform] [osm:unknown]
+\definecolor[osm:railway:preserved] [osm:unknown]
+\definecolor[osm:railway:rail] [osm:unknown]
+\definecolor[osm:railway:subway] [osm:unknown]
+\definecolor[osm:railway:tram] [osm:unknown]
+\definecolor[osm:railway:turntable] [osm:unknown]
+
+\definecolor[osm:tourism:yes] [osm:unknown]
+
+\definecolor[osm:water:basin] [osm:water]
+\definecolor[osm:water:river] [osm:water]
+
+\definecolor[osm:waterway:canal] [osm:waterway]
+\definecolor[osm:waterway:derelict_canal] [osm:waterway]
+\definecolor[osm:waterway:ditch] [osm:waterway]
+\definecolor[osm:waterway:drain] [osm:waterway]
+\definecolor[osm:waterway:river] [osm:waterway]
+\definecolor[osm:waterway:stream] [osm:waterway]
+\definecolor[osm:waterway:tidal_channel] [osm:waterway]
+\definecolor[osm:waterway:wadi] [osm:waterway]
+\definecolor[osm:waterway:weir] [osm:waterway]
+
+\registerctxluafile{m-openstreetmap}{autosuffix}
+
+\startMPdefinitions
+
+ presetparameters "openstreetmap" [
+ filename = "test.osm",
+ % grid = "dots",
+ griddot = 1.5,
+ ] ;
+
+ def lmt_openstreetmap = applyparameters "openstreetmap" "lmt_do_openstreetmap" enddef ;
+
+ vardef lmt_do_openstreetmap =
+ image (
+ lua.mp.lmt_do_openstreetmap() ;
+ )
+ enddef ;
+
+\stopMPdefinitions
+
+\continueifinputfile{m-openstreetmap.mkxl}
+
+\startMPpage
+ draw lmt_openstreetmap [
+ filename = "hasselt.osm"
+ used = [
+ boundary = false,
+ ],
+ ] ;
+\stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "e:/tmp/hulshorst.osm"
+% used = [
+% boundary = false,
+% ],
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "hasselt.osm"
+% used = [
+% boundary = false,
+% emergency = false,
+% boat = false,
+% golf = false,
+% area = false,
+% agricultural = false,
+% historic = false,
+% tourism = false,
+% power = false,
+% junction = false,
+% water = false,
+% highway = false,
+% waterway = false,
+% railway = false,
+% aeroway = false,
+% aerialway = false,
+% ]
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "hasselt.osm"
+% used = [
+% amenity = false,
+% boundary = false,
+% building = false,
+% emergency = false,
+% man_made = false,
+% natural = "magenta",
+% barrier = false,
+% leisure = "cyan",
+% bridge = false,
+% boat = false,
+% landuse = "green",
+% golf = false,
+% area = false,
+% bridge = false,
+% agricultural = false,
+% historic = false,
+% tourism = false,
+% power = false,
+% junction = false,
+% water = false,
+% highway = false,
+% waterway = false,
+% railway = false,
+% aeroway = false,
+% aerialway = false,
+% ]
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "hasselt-large.osm"
+% grid = "dots",
+% % collect = true,
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "e:/tmp/map.osm"
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "e:/tmp/map-x.osm"
+% grid = "dots",
+% griddot = 1,
+% ] ;
+% \stopMPpage
+
+% \startMPpage
+% draw lmt_openstreetmap [
+% filename = "e:/temporary/ford-collins.osm"
+% ] ;
+% \stopMPpage
+
+\stoptext
+
+% -- -- The original approaches:
+% --
+% -- local colors = {
+% -- amenity = {
+% -- arts_centre = "osm:special",
+% -- ...
+% -- }
+% -- }
+% --
+% -- local function getcolor(r)
+% -- local what, color, both
+% -- for t in xmlcollected(r,"/tag") do
+% -- local at = t.at
+% -- local k = at.k
+% -- local all = usedcolors[k]
+% -- if all then
+% -- local v = at.v
+% -- local col = all[v]
+% -- if col then
+% -- what = k
+% -- color = col
+% -- both = lines[k]
+% -- elseif missing then
+% -- missing[k][v] = (missing[k][v] or 0) + 1
+% -- end
+% -- end
+% -- if k == "amenity" then
+% -- break
+% -- end
+% -- end
+% -- return what, color, both
+% -- end
+%
+% -- -- maybe nested:
+%
+% -- for m in xmlcollected(parent,"/member[@type='relation']") do
+% -- local f = xmlfirst(root,f_relation(m.at.ref))
+% -- if f then
+% -- for m in xmlcollected(f,"/member[@type='way']") do
+% -- -- local f = xmlfirst(root,f_way(m.at.ref))
+% -- local f = ways[m.at.ref]
+% -- if f then
+% -- local p, n = addpath(f, { }, 0)
+% -- if n > 1 then
+% -- local what, color = getcolor(parent)
+% -- if what and rendering[what] then
+% -- r = r + 1
+% -- if p[1] == p[n] then
+% -- result[r] = f_fill(p,color)
+% -- else
+% -- result[r] = f_draw(p,color)
+% -- end
+% -- end
+% -- end
+% -- end
+% -- end
+% -- end
+% -- end
+%
+% -- local filename = resolvers.savers.virtual("foo",result,"mp")
+% -- context([[input "%s" ;]],filename)
+% -- context([[runscript "resolvers.cleaners.virtual('%s')" ;]],filename)
+%
+% -- context.startTEXpage()
+% -- context.startMPcode("doublefun")
+% -- context("lua.mp.fetchresult();")
+% -- context.stopMPcode()
+% -- context.stopTEXpage()
+
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 85fbc6b48..d1462e4b4 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 : 2021-07-16 21:58
+-- merge date : 2021-07-21 19:51
do -- begin closure to overcome local limits and interference