summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-03-01 15:56:41 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-03-01 15:56:41 +0100
commitd07afd7261f4bb5486cc016d8c90d532ba7fc0e4 (patch)
tree19f6b457352c70aa6dd74830fb268d6f42b6cee3
parent4f7f67101a808c6b6c89d64ad5ee1f1701d8f632 (diff)
downloadcontext-d07afd7261f4bb5486cc016d8c90d532ba7fc0e4.tar.gz
2021-03-01 15:36:00
-rw-r--r--doc/context/documents/general/manuals/lowlevel-paragraphs.pdfbin140547 -> 192854 bytes
-rw-r--r--doc/context/sources/general/manuals/lowlevel/lowlevel-paragraphs.tex602
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-text.tex96
-rw-r--r--metapost/context/base/mpxl/metafun.mpxl1
-rw-r--r--metapost/context/base/mpxl/mp-lmtx.mpxl2
-rw-r--r--metapost/context/base/mpxl/mp-text.mpxl103
-rw-r--r--metapost/context/base/mpxl/mp-tool.mpxl8
-rw-r--r--scripts/context/lua/mtxrun.lua10
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua10
-rw-r--r--scripts/context/stubs/unix/mtxrun10
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua10
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/data-env.lua4
-rw-r--r--tex/context/base/mkiv/publ-ini.mkiv6
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin25335 -> 25363 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin256139 -> 256166 bytes
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl4
-rw-r--r--tex/context/base/mkxl/meta-imp-txt.lmt86
-rw-r--r--tex/context/base/mkxl/meta-imp-txt.mkxl66
-rw-r--r--tex/context/base/mkxl/mlib-ctx.lmt2
-rw-r--r--tex/context/base/mkxl/mlib-fio.lmt2
-rw-r--r--tex/context/base/mkxl/mlib-lua.lmt2
-rw-r--r--tex/context/base/mkxl/mlib-mpf.lmt12
-rw-r--r--tex/context/base/mkxl/mlib-run.lmt2
-rw-r--r--tex/context/base/mkxl/node-par.lmt21
-rw-r--r--tex/context/base/mkxl/publ-ini.mkxl12
-rw-r--r--tex/context/base/mkxl/spac-par.lmt1
-rw-r--r--tex/context/base/mkxl/spac-par.mkxl55
-rw-r--r--tex/context/base/mkxl/typo-par.lmt40
-rw-r--r--tex/context/base/mkxl/typo-shp.lmt117
-rw-r--r--tex/context/base/mkxl/typo-shp.mkxl125
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
36 files changed, 1017 insertions, 404 deletions
diff --git a/doc/context/documents/general/manuals/lowlevel-paragraphs.pdf b/doc/context/documents/general/manuals/lowlevel-paragraphs.pdf
index 95888d64e..b36f25dd0 100644
--- a/doc/context/documents/general/manuals/lowlevel-paragraphs.pdf
+++ b/doc/context/documents/general/manuals/lowlevel-paragraphs.pdf
Binary files differ
diff --git a/doc/context/sources/general/manuals/lowlevel/lowlevel-paragraphs.tex b/doc/context/sources/general/manuals/lowlevel/lowlevel-paragraphs.tex
index a7a7fddf3..dad9b2e4e 100644
--- a/doc/context/sources/general/manuals/lowlevel/lowlevel-paragraphs.tex
+++ b/doc/context/sources/general/manuals/lowlevel/lowlevel-paragraphs.tex
@@ -8,11 +8,197 @@
\startsection[title=Introduction]
-This manual is mostly discussing a few wrappers around low level \TEX\ features.
-Its writing is triggered by an update to the \METAFUN\ and \LUAMETAFUN\ manuals
-where we mess a bit with shapes. It gave a good reason to also cover some more
-paragraph related topics but it might take a while to complete. Remind me if you
-feel that takes too much time.
+This manual is mostly discussing a few low level wrappers around low level \TEX\
+features. Its writing is triggered by an update to the \METAFUN\ and \LUAMETAFUN\
+manuals where we mess a bit with shapes. It gave a good reason to also cover some
+more paragraph related topics but it might take a while to complete. Remind me if
+you feel that takes too much time.
+
+Because paragraphs and their construction are rather central to \TEX, you can
+imagine that the engine exposes dealing with them. This happens via commands
+(primitives) but only when it's robust. Then there are callbacks, and some
+provide detailed information about what we're dealing with. However, intercepting
+node lists can already be hairy and we do that a lot in \CONTEXT. Intercepting
+and tweaking paragraph properties is even more tricky, which is why we try to
+avoid that in the core. But \unknown\ in the following sections you will see that
+there are actually a couple of mechanism that do so. Often new features like this
+are built in stepwise and enabled locally for a while and when they seem okay
+they get enabled by default. \footnote {For this we have \type
+{\enableexperiments} which one can use in \type {cont-loc.mkxl} or \type
+{cont-exp.mkxl}, files that are loaded runtime when on the system. When you use
+them, make sure they don't interfere; they are not part of the updates, contrary
+to \type {cont-new.mkxl}.}
+
+\stopsection
+
+\startsection[title=Paragraphs]
+
+Before we demonstrate some trickery, let's see what a paragraph is. Normally a
+document source is formatted like this:
+
+\starttyping[option=TEX]
+some text (line 1)
+some text (line 2)
+
+some more test (line 1)
+some more test (line 2)
+\stoptyping
+
+There are two blocks of text here separated by an empty line and they become two
+paragraphs. Unless configured otherwise an empty line is an indication that we
+end a paragraph. You can also explicitly do that:
+
+\starttyping[option=TEX]
+some text (line 1)
+some text (line 2)
+\par
+some more test (line 1)
+some more test (line 2)
+\stoptyping
+
+When \TEX\ starts a paragraph, it actually also does something think of:
+
+\starttyping[option=TEX]
+[\the\everypar]some text (line 1) some text (line 2) \par
+[\the\everypar]some more test (line 1) some more test (line 2) \par
+\stoptyping
+
+or more accurate:
+
+\starttyping[option=TEX]
+[\the\everypar]some text some text \par
+[\the\everypar]some more test some more test \par
+\stoptyping
+
+because the end|-|of|-|line character has become a space. As mentioned,
+an empty line is actually the end of a paragraph. But in \LUAMETATEX\
+we can cheat a bit. If we have this:
+
+\startbuffer
+line 1
+
+line 2
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+We can do this (watch how we need to permit overloading a primitive when we have
+enabled \type {\overloadmode}):
+
+\startbuffer
+\pushoverloadmode
+\def\linepar{\removeunwantedspaces !\ignorespaces}
+\popoverloadmode
+line 1
+
+line 2
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+This comes out as:
+
+\start \getbuffer \stop
+
+I admit that since it got added (as part of some cleanup halfway the overhaul of
+the engine) I never saw a reason to use it, but it is a cheap feature. The \type
+{\linepar} primitive is undefined (\type {\undefined}) by default so no user sees
+it anyway. Just don't use it unless maybe for some pseudo database trickery (I
+considered using it for the database module but it is not needed). In a similar
+fashion, just don't redefine \type {\par}: it's asking for troubles and \quote
+{not done} in \CONTEXT\ anyway.
+
+Back to reality. In \LUATEX\ we get a node list that starts with a so called
+\type {localpar} node and ends with a \type {\parfillskip}. The first node is
+prepended automatically. That list travels through the system: hyphenation,
+applying font properties, break the effectively one line into lines, wrap them
+and add them to a vertical list, etc. Each stage can be intercepted via
+callbacks.
+
+When the paragraph is broken into lines hanging indentation or a so called par
+shape can be applied, and we will see more of that later, here we talk \type
+{\par} and show another \LUAMETATEX\ trick:
+
+\startbuffer
+\def\foo{{\bf test:} \ignorepars}
+
+\foo
+
+line
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+The macro typesets some text and then skips to the next paragraph:
+
+\start \getbuffer \stop
+
+Think of this primitive as being a more powerful variant of \type
+{\ignorespaces}. This leaves one aspect: how do we start a paragraph. Technically
+we need to force \TEX\ into so called horizontal mode. When you look at plain
+\TEX\ documents you will notice commands like \type {\noindent} and \type
+{\indent}. In \CONTEXT\ we have more high level variants, for instance we have
+\type {\noindentation}.
+
+A robust way to make sure that you get in horizontal mode is using \type
+{\dontleavehmode} which is a wink to \type {\leavevmode}, a command that you
+should never use in \CONTEXT, so when you come from plain or \LATEX, it's one of
+the commands you should wipe from your memory.
+
+When \TEX\ starts with a paragraph the \type {\everypar} token list is expanded
+and again this is a primitive you should not mess with yourself unless in very
+controlled situations. If you change its content, you're on your own with respect
+to interferences and side effects.
+
+One of the things that \TEX\ does in injecting the indentation. Even when there
+is none, it gets added, not as skip but as an empty horizontal box of a certain
+width. This is easier on the engine when it constructs the paragraph from the one
+liner: starting with a skip demands a bit more testing in the process (a nice
+trick so to say). However, in \CONTEXT\ we enable the \LUAMETATEX\ feature that
+does use a skip instead of a box. It's part of the normalization that is
+discussed later. Instead of checking for a box with property indent, we check for
+a skip with such property. This is often easier and cleaner.
+
+A bit off topic is the fact that in traditional \TEX\ empty lines or \type {\par}
+primitives can trigger an error. This has to do with the fact that the program
+evolved in a time where paper terminals were used and runtime could be excessive.
+So, in order to catch a possible missing brace, a concept of \type {\long}
+macros, permitting \type {\par} or equivalents in arguments, was introduced as
+well as not permitting them in for instance display math. In \CONTEXT\ \MKII\
+most macros that could be sensitive for this were defined as \type {\long} so
+that users never had to bother about it and probably were not even aware of it.
+Right from the start in \LUATEX\ these error|-|triggers could be disabled which
+of course we enable in \CONTEXT\ and in \LUAMETATEX\ these features have been
+removed altogether. I don't think users will complain about this.
+
+If you want to enforce a newline but not a new paragraph you can use the \type
+{\crlf} command. When used on its own it will produce an empty line. Don't use
+this to create whitespace between lines.
+
+If you want to do something after so called par tokens are seen you can do this:
+
+\startbuffer
+\def\foo{{\bf >>>> }}
+\expandafterpars\foo
+
+this is a new paragraph ...
+
+\expandafterpars\foo
+\par\par\par\par
+this is a new paragraph ...
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+This not to be confused with \type {\everypar} which is a token list that \TEX\
+itself injects before each paragraph (also nested ones).
+
+\getbuffer
+
+This is typically a primitive that will only be used in macros. You can actually
+program it using macros: pickup a token, check and push it back when it's not a
+par equivalent token. The primitive is is just nicer (and easier on the log when
+tracing is enabled).
\stopsection
@@ -29,59 +215,67 @@ However, in \LUAMETATEX\ we can optionally store them with the paragraph. When
that happens the values current at the start are frozen. You can still overload
them but that has to be done explicitly then. The advantage is that grouping no
longer interferes with the line break algorithm. The magic primitive is \type
-{\snapshotpar}.
-
-\starttabulate
-\NC \type {\hsize} \NC \NC \NR
-\NC \type {\leftskip} \NC \NC \NR
-\NC \type {\rightskip} \NC \NC \NR
-\NC \type {\hangindent} \NC \NC \NR
-\NC \type {\hangafter} \NC \NC \NR
-\NC \type {\parindent} \NC \NC \NR
-\NC \type {\parfillleftskip} \NC \NC \NR
-\NC \type {\parfillrightskip} \NC \NC \NR
-\NC \type {\adjustspacing} \NC \NC \NR
-\NC \type {\protrudechars} \NC \NC \NR
-\NC \type {\pretolerance} \NC \NC \NR
-\NC \type {\tolerance} \NC \NC \NR
-\NC \type {\emergencystretch} \NC \NC \NR
-\NC \type {\looseness} \NC \NC \NR
-\NC \type {\lastlinefit} \NC \NC \NR
-\NC \type {\linepenalty} \NC \NC \NR
-\NC \type {\interlinepenalty} \NC \NC \NR
-\NC \type {\clubpenalty} \NC \NC \NR
-\NC \type {\widowpenalty} \NC \NC \NR
-\NC \type {\displaywidowpenalty} \NC \NC \NR
-\NC \type {\brokenpenalty} \NC \NC \NR
-\NC \type {\adjdemerits} \NC \NC \NR
-\NC \type {\doublehyphendemerits} \NC \NC \NR
-\NC \type {\finalhyphendemerits} \NC \NC \NR
-\NC \type {\parshape} \NC \NC \NR
-\NC \type {\interlinepenalties} \NC \NC \NR
-\NC \type {\clubpenalties} \NC \NC \NR
-\NC \type {\widowpenalties} \NC \NC \NR
-\NC \type {\displaywidowpenalties} \NC \NC \NR
-\NC \type {\baselineskip} \NC \NC \NR
-\NC \type {\lineskip} \NC \NC \NR
-\NC \type {\lineskiplimit} \NC \NC \NR
-\NC \type {\adjustspacingstep} \NC \NC \NR
-\NC \type {\adjustspacingshrink} \NC \NC \NR
-\NC \type {\adjustspacingstretch} \NC \NC \NR
-\NC \type {\hyphenationmode} \NC \NC \NR
+{\snapshotpar} which takes a number made from categories mentioned below:
+
+\starttabulate[|l|l|r|]
+\BC variable \BC category \BC code \NC \NR
+\NC \type {\hsize} \NC hsize \NC 0x\uchexnumbers\frozenhsizecode \NC \NR
+\NC \type {\leftskip} \NC skip \NC 0x\uchexnumbers\frozenskipcode \NC \NR
+\NC \type {\rightskip} \NC skip \NC 0x\uchexnumbers\frozenskipcode \NC \NR
+\NC \type {\hangindent} \NC hang \NC 0x\uchexnumbers\frozenhangcode \NC \NR
+\NC \type {\hangafter} \NC hang \NC 0x\uchexnumbers\frozenhangcode \NC \NR
+\NC \type {\parindent} \NC indent \NC 0x\uchexnumbers\frozenindentcode \NC \NR
+\NC \type {\parfillleftskip} \NC par fill \NC 0x\uchexnumbers\frozenparfillcode \NC \NR
+\NC \type {\parfillrightskip} \NC par fill \NC 0x\uchexnumbers\frozenparfillcode \NC \NR
+\NC \type {\adjustspacing} \NC adjust \NC 0x\uchexnumbers\frozenadjustcode \NC \NR
+\NC \type {\adjustspacingstep} \NC adjust \NC 0x\uchexnumbers\frozenadjustcode \NC \NR
+\NC \type {\adjustspacingshrink} \NC adjust \NC 0x\uchexnumbers\frozenadjustcode \NC \NR
+\NC \type {\adjustspacingstretch} \NC adjust \NC 0x\uchexnumbers\frozenadjustcode \NC \NR
+\NC \type {\protrudechars} \NC protrude \NC 0x\uchexnumbers\frozenprotrudecode \NC \NR
+\NC \type {\pretolerance} \NC tolerance \NC 0x\uchexnumbers\frozentolerancecode \NC \NR
+\NC \type {\tolerance} \NC tolerance \NC 0x\uchexnumbers\frozentolerancecode \NC \NR
+\NC \type {\emergencystretch} \NC stretch \NC 0x\uchexnumbers\frozenstretchcode \NC \NR
+\NC \type {\looseness} \NC looseness \NC 0x\uchexnumbers\frozenloosenesscode \NC \NR
+\NC \type {\lastlinefit} \NC last line \NC 0x\uchexnumbers\frozenlastlinecode \NC \NR
+\NC \type {\linepenalty} \NC line penalty \NC 0x\uchexnumbers\frozenlinepenaltycode \NC \NR
+\NC \type {\interlinepenalty} \NC line penalty \NC 0x\uchexnumbers\frozenlinepenaltycode \NC \NR
+\NC \type {\interlinepenalties} \NC line penalty \NC 0x\uchexnumbers\frozenlinepenaltycode \NC \NR
+\NC \type {\clubpenalty} \NC club penalty \NC 0x\uchexnumbers\frozenclubpenaltycode \NC \NR
+\NC \type {\clubpenalties} \NC club penalty \NC 0x\uchexnumbers\frozenclubpenaltycode \NC \NR
+\NC \type {\widowpenalty} \NC widow penalty \NC 0x\uchexnumbers\frozenwidowpenaltycode \NC \NR
+\NC \type {\widowpenalties} \NC widow penalty \NC 0x\uchexnumbers\frozenwidowpenaltycode \NC \NR
+\NC \type {\displaywidowpenalty} \NC display penalty \NC 0x\uchexnumbers\frozendisplaypenaltycode \NC \NR
+\NC \type {\displaywidowpenalties} \NC display penalty \NC 0x\uchexnumbers\frozendisplaypenaltycode \NC \NR
+\NC \type {\brokenpenalty} \NC broken penalty \NC 0x\uchexnumbers\frozenbrokenpenaltycode \NC \NR
+\NC \type {\adjdemerits} \NC demerits \NC 0x\uchexnumbers\frozendemeritscode \NC \NR
+\NC \type {\doublehyphendemerits} \NC demerits \NC 0x\uchexnumbers\frozendemeritscode \NC \NR
+\NC \type {\finalhyphendemerits} \NC demerits \NC 0x\uchexnumbers\frozendemeritscode \NC \NR
+\NC \type {\parshape} \NC shape \NC 0x\uchexnumbers\frozenshapecode \NC \NR
+\NC \type {\baselineskip} \NC line \NC 0x\uchexnumbers\frozenlinecode \NC \NR
+\NC \type {\lineskip} \NC line \NC 0x\uchexnumbers\frozenlinecode \NC \NR
+\NC \type {\lineskiplimit} \NC line \NC 0x\uchexnumbers\frozenlinecode \NC \NR
+\NC \type {\hyphenationmode} \NC hyphenation \NC 0x\uchexnumbers\frozenhyphenationcode \NC \NR
\stoptabulate
-There are more paragraph related parameters than in for instance \PDFTEX\ and
-\LUATEX\ and these are (to be) explained in the \LUAMETATEX\ manual. You can
-imagine that keeping this around with the paragraph adds some extra overhead to
-the machinery but most users won't notice that because is is compensated by gains
-elsewhere.
+
+As you can see here, there are more paragraph related parameters than in for
+instance \PDFTEX\ and \LUATEX\ and these are (to be) explained in the
+\LUAMETATEX\ manual. You can imagine that keeping this around with the paragraph
+adds some extra overhead to the machinery but most users won't notice that
+because is is compensated by gains elsewhere.
+
+This is pretty low level and there are a bunch of helpers that support this but
+these are not really user level macros. As with everything \TEX\ you can mess
+around as much as you like, and the code gives plenty of examples but when you do
+this, you're on your own because it can interfere with \CONTEXT\ core
+functionality.
In \LMTX\ taking these snapshots is turned on by default and because it thereby
fundamentally influences the par builder, users can run into compatibility issues
but in practice there has been no complaints (and this feature has been in use
quite a while before this document was written). One reason for users not
-noticing is that one of the big benefits is probably handled by tricks mentioned on the
-mailing list. Imagine that you have this:
+noticing is that one of the big benefits is probably handled by tricks mentioned
+on the mailing list. Imagine that you have this:
\starttyping[option=TEX]
{\bf watch out:} here is some text
@@ -122,14 +316,12 @@ where we had to explicitly end the paragraph inside the group in order to retain
the skip. I suppose that users normally use the high level environments so they
never had to worry about this. It's also why users probably won't notice that
this new mechanism has been active for a while. Actually, when you now change a
-parameter inside the paragraph will not be applied (unless you prefix it with
-\type {\frozen}) but no one did that anyway.
-
-{\em todo: freeze categories, overloading, turning on and off, etc}
+parameter inside the paragraph its new value will not be applied (unless you
+prefix it with \type {\frozen} or snapshot it) but no one did that anyway.
\stopsection
-\startsection[title=Wraping up]
+\startsection[title=Wrapping up]
In \CONTEXT\ \LMTX\ we have a mechanism to exercise macros (or content) before a
paragraph ends. This is implemented using the \type {\wrapuppar} primitive. The
@@ -153,26 +345,59 @@ question is: where do we apply it in old mechanisms and where not.
\stopsection
+\startsection[title=Hanging]
+
+There are two mechanisms for getting a specific paragraph shape: rectangular
+hanging and arbitrary shapes. Both mechanisms work top|-|down. The first
+mechanism uses a combination of \type {\hangafter} and \type {\hangindent}, and
+the second one depends on \type {\parshape}. In this section we discuss the
+rectangular one.
+
+\startbuffer[hang]
+\hangafter 4 \hangindent 4cm \samplefile{tufte} \page
+\hangafter -4 \hangindent 4cm \samplefile{tufte} \page
+\hangafter 4 \hangindent -4cm \samplefile{tufte} \page
+\hangafter -4 \hangindent -4cm \samplefile{tufte} \page
+\stopbuffer
+
+\typebuffer[hang][option=TEX]
+
+As you can see in \in {figure} [fig:hang], the four cases are driven by the sign
+of the values. If you want to hang into the margin you need to use different
+tricks, like messing with the \type {\leftskip}, \type {\rightskip} or \type
+{\parindent} parameters (which then of course can interfere with other mechanisms
+uses at the same time).
+
+\startplacefigure[title=Hanging indentation,reference=fig:hang]
+\startcombination[nx=2,ny=2]
+ {\typesetbuffer[hang][page=1,width=.4\textwidth,frame=on]} {\type{\hangafter +4 \hangindent +4cm}}
+ {\typesetbuffer[hang][page=2,width=.4\textwidth,frame=on]} {\type{\hangafter -4 \hangindent +4cm}}
+ {\typesetbuffer[hang][page=3,width=.4\textwidth,frame=on]} {\type{\hangafter +4 \hangindent -4cm}}
+ {\typesetbuffer[hang][page=4,width=.4\textwidth,frame=on]} {\type{\hangafter -4 \hangindent -4cm}}
+\stopcombination
+\stopplacefigure
+
+\stopsection
+
\startsection[title=Shapes]
In \CONTEXT\ we don't use \type {\parshape} a lot. It is used in for instance
-side floats but even then not in all cases. It's more meant for special
+side floats but even there not in all cases. It's more meant for special
applications. This means that in \MKII\ and \MKIV\ we don't have some high level
interface. However, when \METAFUN\ got upgraded to \LUAMETAFUN, and the manual
also needed an update, one of the examples in that manual that used shapes also
-got done differently (read: nicer). And that triggered the arrival of a new high
+got done differently (read: nicer). And that triggered the arrival of a new low
level shape mechanism.
One important property of the \type {\parshape} mechanism is that it works per
paragraph. You define a shape in terms of a left margin and width of a line. The
-shape has a fixed number of such pairs and when there is more content, the last one
-is used for the rest of the lines. When the paragraph is finished, the shape is
-forgotten.
-
-{\em Not discussed here is a variant that will end up in \LUAMETATEX\ that works
-with the progression, i.e.\ takes the height of the content so far into account.
-This is somewhat tricky because for that to work vertical skips need to be
-frozen, which is no real big deal but has to be done careful in the code.}
+shape has a fixed number of such pairs and when there is more content, the last
+one is used for the rest of the lines. When the paragraph is finished, the shape
+is forgotten. \footnote {Not discussed here is a variant that might end up in
+\LUAMETATEX\ that works with the progression, i.e.\ takes the height of the
+content so far into account. This is somewhat tricky because for that to work
+vertical skips need to be frozen, which is no real big deal but has to be done
+careful in the code.}
The high level interface is a follow up on the example in the \METAFUN\ manual and
uses shapes that carry over to the next paragraph. In addition we can cycle over
@@ -321,7 +546,7 @@ In \in {figure} [fig:shape:shift] we use this instead:
\typebuffer[demo,demo-repeat][option=TEX]
-\startplacefigure[title=Shifted shaping,,reference=fig:shape:shift]
+\startplacefigure[title=Shifted shaping,reference=fig:shape:shift]
\startcombination[nx=2,ny=2]
{\typesetbuffer[setup,demo][page=1,width=.4\textwidth,frame=on]} {shift, finite shape, page 1}
{\typesetbuffer[setup,demo][page=2,width=.4\textwidth,frame=on]} {shift, finite shape, page 2}
@@ -378,25 +603,237 @@ used instead but this makes a good example anyway.
\typebuffer[option=TEX]
-\getbuffer
+\start \getbuffer \stop
-{\em todo: move the new (still in {\em \type {meta-imp-txt.mkxl})} code into the
-core and integrate it in {\em \type {\startshapedparagraph}} as method {\em \type
-{mp}} in which case the list is a list of graphics.}
+Because the idea for this feature originates in \METAFUN, we will now kick in
+some \METAPOST. The following code creates a shape for a circle. We use a
+2mm offset here:
-\starttyping[option=TEX]
-\startshapedparagraph[list={test 1,test 2,test 3,test 4},method=mp]
- .....
+\startbuffer
+\startuseMPgraphic{circle}
+ path p ; p := fullcircle scaled TextWidth ;
+ build_parshape(p,
+ 2mm, 0, 0,
+ LineHeight, StrutHeight, StrutDepth, StrutHeight
+ ) ;
+\stopuseMPgraphic
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\start \getbuffer \stop
+
+We plug this into the already described macros:
+
+\startbuffer
+\startshapedparagraph[list=circle,mp=circle]%
+ \setupalign[verytolerant,stretch,last]%
+ \samplefile{tufte}
+ \samplefile{tufte}
\stopshapedparagraph
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+And get ourself a circular shape. Watch out, at this moment the shape environment
+does not add grouping so when as in this case you change the alignment it can
+influence the document.
+
+\start \getbuffer \stop
+
+\startbuffer[framed]
+\framed[align=normal,width=\textwidth,offset=2mm,strut=no]\bgroup
+ \getbuffer
+\egroup
+\stopbuffer
+
+Assuming that the shape definition above is in a buffer we can do this:
+
+\typebuffer[option=TEX]
+
+The result is shown in \in {figure} [fig:shape:circle]. Because all action
+happens in the framed environment, we can also use this definition:
+
+\starttyping[option=TEX]
+\startuseMPgraphic{circle}
+ path p ; p := fullcircle scaled \the\dimexpr\framedwidth+\framedoffset*2\relax ;
+ build_parshape(p,
+ \framedoffset, 0, 0,
+ LineHeight, StrutHeight, StrutDepth, StrutHeight
+ ) ;
+ draw p ;
+\stopuseMPgraphic
\stoptyping
-{\em So methods then become kind of plugins.}
+\startplacefigure[title=A framed circular shape,reference=fig:shape:circle]
+ \getbuffer[framed]
+\stopplacefigure
A mechanism like this is often never completely automatic in the sense that you
need to keep an eye on the results. Depending on user demands more features can
be added. With weird shapes you might want to set up the alignment to be \type
{tolerant} and have some \type {stretch}.
+The interface described in the \METAFUN\ manual is pretty old, the time stamp of
+the original code is mid 2000, but the principles didn't change. The examples in
+\type {meta-imp-txt.mkxl} can now be written as:
+
+\startuseMPgraphic{test 1}
+ begingroup ;
+ save p ; path p ; p := fullcircle scaled 6cm ;
+ lmt_parshape [
+ path = p,
+ offset = BodyFontSize/2,
+ dx = 0, % default
+ dy = 0, % default
+ lineheight = LineHeight, % default
+ strutheight = StrutHeight, % default
+ strutdepth = StrutDepth, % default
+ topskip = StrutHeight, % default
+ ] ;
+ draw p withpen pencircle scaled 1pt ;
+ endgroup ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 2}
+ begingroup ;
+ save p ; path p ; p := fullsquare rotated 45 scaled 5cm ;
+ lmt_parshape [
+ path = p,
+ offset = BodyFontSize/2,
+ trace = true,
+ ] ;
+ draw p withpen pencircle scaled 1pt ;
+ endgroup ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 3}
+ begingroup ;
+ save w, h, p ; path p ; w := h := 6cm ;
+
+ p := (.5w,h) -- ( 0, h) -- (0,0) -- (w,0) &
+ ( w,0) .. (.75w,.5h) .. (w,h) & (w,h) -- cycle ;
+
+ lmt_parshape [
+ path = p,
+ offset = BodyFontSize/2,
+ ] ;
+
+ draw p withpen pencircle scaled 1pt ;
+ endgroup ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{test 4}
+ begingroup ;
+ save d, p, q ; path p, q ; d := BodyFontSize/2;
+
+ vardef shape(expr w, h, o) =
+ (o,o) -- (w-o,o) & (w-o,o) .. (.75w-o,.5h) ..
+ (w-2o,h-o) & (w-2o,h-o) -- (o,h-o) -- cycle
+ enddef ;
+
+ p := shape(6cm, 6cm, d) ; q := shape(6cm, 6cm, 0) ;
+
+ lmt_parshape [
+ path = p,
+ offsetpath = q,
+ dx = d,
+ dy = d,
+ trace = true,
+ ] ;
+
+ draw q withpen pencircle scaled 1pt ;
+ endgroup ;
+\stopuseMPgraphic
+
+\defineoverlay[test 1][\useMPgraphic{test 1}]
+\defineoverlay[test 2][\useMPgraphic{test 2}]
+\defineoverlay[test 3][\useMPgraphic{test 3}]
+\defineoverlay[test 4][\useMPgraphic{test 4}]
+
+\startbuffer
+ \startshapetext[test 1,test 2,test 3,test 4]
+ \setupalign[verytolerant,stretch,normal]%
+ \samplefile{douglas} % Douglas R. Hofstadter
+ \stopshapetext
+ \startcombination[2*2]
+ {\framed[offset=overlay,frame=off,background=test 1]{\getshapetext}}
+ {test 1}
+ {\framed[offset=overlay,frame=off,background=test 2]{\getshapetext}}
+ {test 2}
+ {\framed[offset=overlay,frame=off,background=test 3]{\getshapetext}}
+ {test 3}
+ {\framed[offset=overlay,frame=off,background=test 4]{\getshapetext}}
+ {test 4}
+ \stopcombination
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+In \in {figure} [fig:shapes:chain] we see the result. Watch how for two shapes
+we have enabled tracing. Of course you need to tweak till all fits well but we're
+talking of special situations anyway.
+
+\startplacefigure[Title=Multiple shapes,reference=fig:shapes:chain]
+ \getbuffer
+\stopplacefigure
+
+Here is a bit more extreme example. Again we use a circle:
+
+\startbuffer
+\startuseMPgraphic{circle}
+ lmt_parshape [
+ path = fullcircle scaled 136mm,
+ offset = 2mm,
+ bottomskip = - 1.5LineHeight,
+ ] ;
+\stopuseMPgraphic
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+But we output a longer text:
+
+\startbuffer
+\startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
+ \setupalign[verytolerant,stretch,last]\dontcomplain
+ {\darkred \samplefile{tufte}}\par
+ {\darkgreen \samplefile{tufte}}\par
+ {\darkblue \samplefile{tufte}}\par
+ {\darkcyan \samplefile{tufte}}\par
+ {\darkmagenta \samplefile{tufte}}\par
+\stopshapedparagraph
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+We get a multi|-|page shape:
+
+\start \getbuffer \stop
+
+Compare this with:
+
+\startbuffer
+\startshapedparagraph[list=circle,mp=circle,repeat=yes,method=cycle]%
+ \setupalign[verytolerant,stretch,last]\dontcomplain
+ {\darkred \samplefile{tufte}}
+ {\darkgreen \samplefile{tufte}}
+ {\darkblue \samplefile{tufte}}
+ {\darkcyan \samplefile{tufte}}
+ {\darkmagenta \samplefile{tufte}}
+\stopshapedparagraph
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+Which gives:
+
+\start \getbuffer \stop
+
+Here the \type {bottomskip} takes care of subtle rounding issues as well as
+discarding the last line in the shape so that we get nicer continuation. There is
+no full automated solution for all you can come up with.
+
\stopsection
% \startsection[title=Linebreaks]
@@ -421,3 +858,18 @@ be added. With weird shapes you might want to set up the alignment to be \type
\stopdocument
+\everyhbox \everyvbox : useless unless one resets
+\parattr
+\snapshotpar
+\wrapuppar
+
+% \parfillleftskip
+
+% I rewarded myself after writing a section by watching the video "Final Thing On
+% My Mind", The Pineapple This, Live, 2020, the usual perfect GH performance,
+% wondering if live would turn to normal so that we could go to such concerts once
+% again given successive covids. Writing manuals can do with a distraction.
+%
+% Gavin Harrison: Soundcheck, Drummerworld Jan 27, 2021 ... I wish I could make
+% something called a check into pefect solo. Okay, another section and I'll check
+% out the latest Simon Phillips and other favourite dummer uploads.
diff --git a/doc/context/sources/general/manuals/metafun/metafun-text.tex b/doc/context/sources/general/manuals/metafun/metafun-text.tex
index f70f53ac3..4442894cb 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-text.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-text.tex
@@ -974,11 +974,8 @@ define an offset too.
\startbuffer
\startuseMPgraphic{text vars}
- baselineskip := 8pt ;
- strutheight := (7.2/10) * baselineskip ;
- strutdepth := (2.8/10) * baselineskip ;
- offset := baselineskip/2 ;
- topskip := strutheight ;
+ MyOffset := LineHeight/2 ;
+ MyTopSkip := StrutHeight ;
\stopuseMPgraphic
\stopbuffer
@@ -999,8 +996,8 @@ dimensions.
hsize := xpart lrcorner p - xpart llcorner p ;
vsize := ypart urcorner p - ypart lrcorner p ;
- q := p xscaled ((hsize-2offset)/hsize)
- yscaled ((vsize-2offset)/vsize) ;
+ q := p xscaled ((hsize-2MyOffset)/hsize)
+ yscaled ((vsize-2MyOffset)/vsize) ;
hsize := xpart lrcorner q - xpart llcorner q ;
vsize := ypart urcorner q - ypart lrcorner q ;
@@ -1061,7 +1058,7 @@ Then we use \type {\useMPgraphic{text}} to call up the picture.
The offset is not optimal. Note the funny gap at the top. We could try to fix
this, but there is a better way to optimize both paths.
-We lower the top edge of \type {q}'s bounding box by \type {topskip}, then cut
+We lower the top edge of \type {q}'s bounding box by \type {MyTopSkip}, then cut
any part of the left and right pieces of \type {q} that lie above it. Similarly,
we raise the bottom edge and cut off the pieces that fall below this line.
@@ -1069,8 +1066,8 @@ we raise the bottom edge and cut off the pieces that fall below this line.
\startuseMPgraphic{text cutoff}
path tt, bb ;
- tt := (ulcorner q -- urcorner q) shifted (0,-topskip) ;
- bb := (llcorner q -- lrcorner q) shifted (0,strutdepth) ;
+ tt := (ulcorner q -- urcorner q) shifted (0,-MyTopSkip) ;
+ bb := (llcorner q -- lrcorner q) shifted (0,StrutDepth) ;
l := l cutbefore (l intersectionpoint tt) ;
l := l cutafter (l intersectionpoint bb) ;
@@ -1120,18 +1117,18 @@ line has a height and depth, we have to determine which part touches first.
\startuseMPgraphic{text calc}
vardef found_point (expr lin, pat, sig) =
pair a, b ;
- a := pat intersection_point (lin shifted (0,strutheight)) ;
+ a := pat intersection_point (lin shifted (0,StrutHeight)) ;
if intersection_found :
- a := a shifted (0,-strutheight) ;
+ a := a shifted (0,-StrutHeight) ;
else :
a := pat intersection_point lin ;
fi ;
- b := pat intersection_point (lin shifted (0,-strutdepth)) ;
+ b := pat intersection_point (lin shifted (0,-StrutDepth)) ;
if intersection_found :
if sig :
- if xpart b > xpart a : a := b shifted (0,strutdepth) fi ;
+ if xpart b > xpart a : a := b shifted (0,StrutDepth) fi ;
else :
- if xpart b < xpart a : a := b shifted (0,strutdepth) fi ;
+ if xpart b < xpart a : a := b shifted (0,StrutDepth) fi ;
fi ;
fi ;
a
@@ -1153,7 +1150,7 @@ subpath).
\startuseMPgraphic{text step}
path line; pair lll, rrr ;
- for i=topskip step baselineskip until vsize :
+ for i=MyTopSkip step LineHeight until vsize :
line := (ulcorner q -- urcorner q) shifted (0,-i) ;
@@ -1165,17 +1162,17 @@ subpath).
\typebuffer \getbuffer
Here we divide the available space in lines. The first line starts at \type
-{strutheight} from the top.
+{StrutHeight} from the top.
We can now finish our graphic by visualizing the lines. Both the height and depth
of the lines are shown.
\startbuffer
\startuseMPgraphic{text line}
- fill (lll--rrr--rrr shifted (0,strutheight)--lll
- shifted (0,strutheight)--cycle) withcolor .5white ;
- fill (lll--rrr--rrr shifted (0,-strutdepth)--lll
- shifted (0,-strutdepth)--cycle) withcolor .7white ;
+ fill (lll--rrr--rrr shifted (0,StrutHeight)--lll
+ shifted (0,StrutHeight)--cycle) withcolor .5white ;
+ fill (lll--rrr--rrr shifted (0,-StrutDepth)--lll
+ shifted (0,-StrutDepth)--cycle) withcolor .7white ;
draw lll withpen pencircle scaled 2pt ;
draw rrr withpen pencircle scaled 2pt ;
draw (lll--rrr) withpen pencircle scaled .5pt ;
@@ -1214,13 +1211,13 @@ we get better results when we (on purpose) take a smaller height.
\startuseMPgraphic{text step}
path line; pair lll, rrr ; numeric vvsize ;
- if (strutheight+strutdepth<baselineskip) :
+ if (StrutHeight+StrutDepth<LineHeight) :
vvsize := vsize ;
else :
- vvsize := (vsize div baselineskip) * baselineskip ;
+ vvsize := (vsize div LineHeight) * LineHeight ;
fi ;
- for i=topskip step baselineskip until vvsize :
+ for i=MyTopSkip step LineHeight until vvsize :
line := (ulcorner q -- urcorner q) shifted (0,-i) ;
@@ -1240,11 +1237,8 @@ better) results.
\startbuffer
\startuseMPgraphic{text vars}
-baselineskip := 8pt ;
-strutheight := 4pt ;
-strutdepth := 2pt ;
-offset := 4pt ;
-topskip := 3pt ;
+MyOffset := .5LineHeight ;
+MyTopSkip := StrutHeight ;
\stopuseMPgraphic
\stopbuffer
@@ -1261,8 +1255,8 @@ this is to let \METAPOST\ write a \type {\parshape} specification.
\startbuffer
\startuseMPgraphic{text macro}
- def provide_parshape (expr p, offset, baselineskip,
- strutheight, strutdepth, topskip) =
+ def provide_parshape (expr p, MyOffset, LineHeight,
+ StrutHeight, StrutDepth, MyTopSkip) =
\includeMPgraphic{text move}
\includeMPgraphic{text split}
@@ -1285,13 +1279,13 @@ the loop we write those values to a file using another loop.
\startuseMPgraphic{text loop}
path line; pair lll, rrr ; numeric vvsize, n ; n := 0 ;
- if (strutheight+strutdepth<baselineskip) :
+ if (StrutHeight+StrutDepth<LineHeight) :
vvsize := vsize ;
else :
- vvsize := (vsize div baselineskip) * baselineskip ;
+ vvsize := (vsize div LineHeight) * LineHeight ;
fi ;
- for i=topskip step baselineskip until vvsize :
+ for i=MyTopSkip step LineHeight until vvsize :
line := (ulcorner q -- urcorner q) shifted (0,-i) ;
@@ -1327,12 +1321,12 @@ We can call this macro using the part we used in the previous examples.
path p ; p := ((0,1)..(-1,0)..(1,0)--cycle) scaled 65pt ;
provide_parshape
- (p, % shape path
- .5*\baselinedistance, % offset
- \baselinedistance, % distance between lines
- \strutheight, % height of a line
- \strutdepth, % depth of a line
- \strutheight) ; % height of first line
+ (p, % shape path
+ .5*LineHeight, % offset
+ LineHeight, % distance between lines
+ StrutHeight, % height of a line
+ StrutDepth, % depth of a line
+ StrutHeight) ; % height of first line
\stopuseMPgraphic
\stopbuffer
@@ -1405,7 +1399,7 @@ happens in border cases. For instance, too small first lines are ignored. First
we define a circle. Watch how the dimensions are set in the graphic. The
arguments passed to \type {build_parshape} are: path, an offset, an additional
horizontal and vertical displacement, the baseline distance, the height and depth
-of the line, and the height of the first line (topskip in \TEX\ terminology). The
+of the line, and the height of the first line (MyTopSkip in \TEX\ terminology). The
height and depth of a line are often called strut height and depth, with a strut
being an invisible character with maximum dimensions.
@@ -1413,8 +1407,8 @@ being an invisible character with maximum dimensions.
\startuseMPgraphic{test 1}
path p ; p := fullcircle scaled 6cm ;
- build_parshape(p,6pt,0,0,\baselinedistance,
- \strutheight,\strutdepth,\strutheight) ;
+ build_parshape(p,6pt,0,0,LineHeight,
+ StrutHeight,StrutDepth,StrutHeight) ;
draw p withpen pencircle scaled 1pt ;
\stopuseMPgraphic
@@ -1429,8 +1423,8 @@ suits the small lines at the top and bottom.
\startuseMPgraphic{test 2}
path p ; p := fullsquare rotated 45 scaled 5cm ;
- build_parshape(p,6pt,0,0,\baselinedistance,
- \strutheight,\strutdepth,\strutheight) ;
+ build_parshape(p,6pt,0,0,LineHeight,
+ StrutHeight,StrutDepth,StrutHeight) ;
draw p withpen pencircle scaled 1pt ;
\stopuseMPgraphic
@@ -1447,8 +1441,8 @@ always trivial.
path p ; p := (.5w,h) -- (0,h) -- (0,0) -- (w,0) &
(w,0) .. (.75w,.5h) .. (w,h) & (w,h) -- cycle ;
- build_parshape(p,6pt,0,0,\baselinedistance,
- \strutheight,\strutdepth,\strutheight) ;
+ build_parshape(p,6pt,0,0,LineHeight,
+ StrutHeight,StrutDepth,StrutHeight) ;
draw p withpen pencircle scaled 1pt ;
\stopuseMPgraphic
@@ -1472,8 +1466,8 @@ needed, since we need these later on.
w := h := 6cm ; o := 6pt ; path p ; p := shape ;
w := h := 6cm ; o := 0pt ; path q ; q := shape ;
- build_parshape(p,q,6pt,6pt,\baselinedistance,
- \strutheight,\strutdepth,\strutheight) ;
+ build_parshape(p,q,6pt,6pt,LineHeight,
+ StrutHeight,StrutDepth,StrutHeight) ;
draw q withpen pencircle scaled 1pt ;
\stopuseMPgraphic
@@ -1591,8 +1585,8 @@ define a quote typeset in a circular paragraph shape.
\startbuffer[shape]
\startuseMPgraphic{center}
- build_parshape(fullcircle scaled 8cm,0,0,0,\baselinedistance,
- \strutheight,\strutdepth,\strutheight) ;
+ build_parshape(fullcircle scaled 8cm,0,0,0,LineHeight,
+ StrutHeight,StrutDepth,StrutHeight) ;
\stopuseMPgraphic
\startshapetext[center]
diff --git a/metapost/context/base/mpxl/metafun.mpxl b/metapost/context/base/mpxl/metafun.mpxl
index 6f817e948..7f9530120 100644
--- a/metapost/context/base/mpxl/metafun.mpxl
+++ b/metapost/context/base/mpxl/metafun.mpxl
@@ -48,6 +48,7 @@ input "mp-apos.mpxl" ;
input "mp-abck.mpxl" ;
input "mp-blob.mpxl" ;
input "mp-lmtx.mpxl" ;
+input "mp-text.mpxl" ;
newinternal string metafunversion ; metafunversion := "metafun xl " & mfun_timestamp;
diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl
index 2835dc89a..ec21b150a 100644
--- a/metapost/context/base/mpxl/mp-lmtx.mpxl
+++ b/metapost/context/base/mpxl/mp-lmtx.mpxl
@@ -2373,7 +2373,7 @@ vardef textual primary p = false enddef ;
newscriptindex mfid_labtorgb ; mfid_labtorgb := scriptindex "labtorgb" ;
-def labtorgb(expr l,a,b) = runscript mfid_labtorgb l a b enddef ;
+def labtorgb(expr l, a, b) = runscript mfid_labtorgb l a b enddef ;
permanent labtorgb ;
diff --git a/metapost/context/base/mpxl/mp-text.mpxl b/metapost/context/base/mpxl/mp-text.mpxl
index 92329c9da..02dbf4479 100644
--- a/metapost/context/base/mpxl/mp-text.mpxl
+++ b/metapost/context/base/mpxl/mp-text.mpxl
@@ -13,50 +13,81 @@
%D This one is only used in metafun so it will become a module.
-if known context_text : endinput ; fi ;
+if known metafun_loaded_text : endinput ; fi ;
-boolean context_text ; context_text := true ;
+newinternal boolean metafun_loaded_text ; metafun_loaded_text := true ; immutable metafun_loaded_text ;
% This is still mostly the same as the one discussed in the good old \METAFUN\
% example code but modernized abit to suit \LMTX.
newscriptindex mfid_setparshapeproperty ; mfid_setparshapeproperty := scriptindex "setparshapeproperty" ;
-def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, strutdepth, topskip) =
+% this is the old name
- if unknown trace_parshape :
- boolean trace_parshape ; trace_parshape := false ;
- fi ;
+presetparameters "parshape" [
+ % offset = 0,
+ % path = fullsquare,
+ % dx = 0,
+ % dy = 0,
+ % strutheight = StrutHeight,
+ % strutdepth = StutDepth,
+ % lineheight = LineHeight,
+ % topskip = StrutHeight,
+ % trace = false,
+] ;
+
+def lmt_parshape = applyparameters "parshape" "lmt_do_parshape" enddef ;
+
+def lmt_do_parshape = % todo: check and improve this rather oldie
begingroup ;
save
- q, l, r, line, tt, bb,
+ p, q, l, r, line, tt, bb,
+ dx, dy, baselineskip, strutheight, strutdepth, topskip, bottomskip, offset, trace,
n, hsize, vsize, vvsize, voffset, hoffset, width, indent,
ll, lll, rr, rrr, cp, cq, t, b ;
path
- q, l, r, line, tt, bb ;
+ p, q, l, r, line, tt, bb ;
numeric
+ dx, dy, baselineskip, strutheight, strutdepth, topskip, offset,
n, hsize, vsize, vvsize, voffset, hoffset, width[], indent[] ;
pair
ll, lll, rr, rrr, cp, cq, t, b ;
+ boolean
+ trace ;
+
+ % specification:
+
+ p := getparameterdefault "parshape" "path" fullsquare ;
+ dx := getparameterdefault "parshape" "dx" 0 ;
+ dy := getparameterdefault "parshape" "dy" 0 ;
+ baselineskip := getparameterdefault "parshape" "baselineskip" LineHeight ;
+ strutheight := getparameterdefault "parshape" "strutheight" StrutHeight ;
+ strutdepth := getparameterdefault "parshape" "strutdepth" StrutDepth ;
+ topskip := getparameterdefault "parshape" "topskip" StrutHeight ;
+ bottomskip := getparameterdefault "parshape" "bottomskip" 0 ;
+ offset := getparameterdefault "parshape" "offset" 0 ;
+ trace := getparameterdefault "parshape" "trace" false ;
+
+ %
n := 0 ;
cp := center p ;
- if path offset_or_path :
- q := offset_or_path ;
- cq := center q ;
+ if hasparameter "parshape" "offsetpath" :
+ q := getparameter "parshape" "offsetpath" ;
voffset := dy ;
hoffset := dx ;
else :
q := p ;
- cq := center q ;
- hoffset := offset_or_path + dx ;
- voffset := offset_or_path + dy ;
+ hoffset := offset + dx ;
+ voffset := offset + dy ;
fi ;
+ cq := center q ;
+
hsize := xpart lrcorner q - xpart llcorner q ;
vsize := ypart urcorner q - ypart lrcorner q ;
@@ -106,7 +137,7 @@ def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, s
a
enddef ;
- if (strutheight+strutdepth<baselineskip) :
+ if (strutheight + strutdepth < baselineskip) :
vvsize := vsize ;
else :
vvsize := (vsize div baselineskip) * baselineskip ;
@@ -114,33 +145,33 @@ def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, s
runscript mfid_setparshapeproperty "first" false ;
- for i=topskip step baselineskip until vvsize :
+ for i = topskip step baselineskip until (vvsize + bottomskip) :
line := (ulcorner q -- urcorner q) shifted (0,-i-eps) ;
ll := found_point(line,l,true ) ;
rr := found_point(line,r,false) ;
- if trace_parshape :
- fill (ll--rr--rr shifted (0,strutheight)--ll shifted (0,strutheight)--cycle) shifted cp withcolor .6white ;
- fill (ll--rr--rr shifted (0,-strutdepth)--ll shifted (0,-strutdepth)--cycle) shifted cp withcolor .8white ;
+ if trace :
+ fill (ll -- rr -- rr shifted (0,strutheight) -- ll shifted (0,strutheight) -- cycle) shifted cp withcolor .6white ;
+ fill (ll -- rr -- rr shifted (0,-strutdepth) -- ll shifted (0,-strutdepth) -- cycle) shifted cp withcolor .8white ;
draw ll shifted cp withpen pencircle scaled 2pt ;
draw rr shifted cp withpen pencircle scaled 2pt ;
- draw (ll--rr) shifted cp withpen pencircle scaled .5pt ;
+ draw (ll -- rr) shifted cp withpen pencircle scaled .5pt ;
fi ;
n := n + 1 ;
indent[n] := abs(xpart ll - xpart llcorner q) ;
width[n] := abs(xpart rr - xpart ll) ;
- if (i=strutheight) and (width[n]<baselineskip) :
+ if (i = strutheight) and (width[n] < baselineskip) :
n := n - 1 ;
runscript mfid_setparshapeproperty "first" true ;
fi ;
endfor ;
- if trace_parshape :
+ if trace :
drawarrow p withpen pencircle scaled 2pt withcolor red ;
drawarrow l shifted cp withpen pencircle scaled 1pt withcolor green ;
drawarrow r shifted cp withpen pencircle scaled 1pt withcolor blue ;
@@ -155,3 +186,31 @@ def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, s
endgroup ;
enddef ;
+
+def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, strutdepth, topskip) =
+ if path offset_or_path :
+ lmt_parshape [
+ path = p,
+ offsetpath = offset_or_path,
+ dx = dx,
+ dy = dy,
+ strutheight = strutheight,
+ strutdepth = strutdepth,
+ lineheight = lineheight,
+ topskip = topskip,
+ trace = (if unknown trace_parshape : false else : trace_parshape fi),
+ ]
+ else :
+ lmt_parshape [
+ path = p,
+ offset = offset_or_path,
+ dx = dx,
+ dy = dy,
+ strutheight = strutheight,
+ strutdepth = strutdepth,
+ lineheight = lineheight,
+ topskip = topskip,
+ trace = (if unknown trace_parshape : false else : trace_parshape fi),
+ ]
+ fi ;
+enddef ;
diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl
index 1d515ffc8..d5da026f2 100644
--- a/metapost/context/base/mpxl/mp-tool.mpxl
+++ b/metapost/context/base/mpxl/mp-tool.mpxl
@@ -3464,12 +3464,8 @@ let dump = relax ;
def loadmodule expr name = % no vardef
% input can't be used directly in a macro
- if unknown scantokens("context_" & name) :
- save s ; string s ;
- % s := "mp-" & name & ".mpiv" ;
- % message("loading module",s) ;
- % s := "input " & s ;
- s := "input " & "mp-" & name & ".mpiv" ;
+ if (unknown scantokens("context_" & name)) and (unknown scantokens("metafun_loaded" & name)) :
+ save s ; string s ; s := "input " & ditto & "mp-" & name & ditto;
expandafter scantokens expandafter s
fi ;
enddef ;
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index aeb27924f..4d176eea7 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -21184,7 +21184,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-env"] = package.loaded["data-env"] or true
--- original size: 9400, stripped down to: 6347
+-- original size: 9501, stripped down to: 6411
if not modules then modules={} end modules ['data-env']={
version=1.001,
@@ -21275,7 +21275,9 @@ local relations=allocate {
mp={
names={ "mp" },
variable='MPINPUTS',
- suffixes={ 'mp','mpvi','mpiv','mpxl','mpii' },
+ suffixes=CONTEXTLMTXMODE>0
+ and { 'mp','mpxl','mpvi','mpiv','mpii' }
+ or { 'mp','mpvi','mpiv','mpii' },
usertype=true,
},
tex={
@@ -25825,8 +25827,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 : 1025202
--- stripped bytes : 405428
+-- original bytes : 1025303
+-- stripped bytes : 405465
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index aeb27924f..4d176eea7 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -21184,7 +21184,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-env"] = package.loaded["data-env"] or true
--- original size: 9400, stripped down to: 6347
+-- original size: 9501, stripped down to: 6411
if not modules then modules={} end modules ['data-env']={
version=1.001,
@@ -21275,7 +21275,9 @@ local relations=allocate {
mp={
names={ "mp" },
variable='MPINPUTS',
- suffixes={ 'mp','mpvi','mpiv','mpxl','mpii' },
+ suffixes=CONTEXTLMTXMODE>0
+ and { 'mp','mpxl','mpvi','mpiv','mpii' }
+ or { 'mp','mpvi','mpiv','mpii' },
usertype=true,
},
tex={
@@ -25825,8 +25827,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 : 1025202
--- stripped bytes : 405428
+-- original bytes : 1025303
+-- stripped bytes : 405465
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index aeb27924f..4d176eea7 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -21184,7 +21184,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-env"] = package.loaded["data-env"] or true
--- original size: 9400, stripped down to: 6347
+-- original size: 9501, stripped down to: 6411
if not modules then modules={} end modules ['data-env']={
version=1.001,
@@ -21275,7 +21275,9 @@ local relations=allocate {
mp={
names={ "mp" },
variable='MPINPUTS',
- suffixes={ 'mp','mpvi','mpiv','mpxl','mpii' },
+ suffixes=CONTEXTLMTXMODE>0
+ and { 'mp','mpxl','mpvi','mpiv','mpii' }
+ or { 'mp','mpvi','mpiv','mpii' },
usertype=true,
},
tex={
@@ -25825,8 +25827,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 : 1025202
--- stripped bytes : 405428
+-- original bytes : 1025303
+-- stripped bytes : 405465
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index aeb27924f..4d176eea7 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -21184,7 +21184,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-env"] = package.loaded["data-env"] or true
--- original size: 9400, stripped down to: 6347
+-- original size: 9501, stripped down to: 6411
if not modules then modules={} end modules ['data-env']={
version=1.001,
@@ -21275,7 +21275,9 @@ local relations=allocate {
mp={
names={ "mp" },
variable='MPINPUTS',
- suffixes={ 'mp','mpvi','mpiv','mpxl','mpii' },
+ suffixes=CONTEXTLMTXMODE>0
+ and { 'mp','mpxl','mpvi','mpiv','mpii' }
+ or { 'mp','mpvi','mpiv','mpii' },
usertype=true,
},
tex={
@@ -25825,8 +25827,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 : 1025202
--- stripped bytes : 405428
+-- original bytes : 1025303
+-- stripped bytes : 405465
-- end library merge
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index b1c603769..623678b40 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.02.27 19:27}
+\newcontextversion{2021.03.01 15:33}
%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 8486049d0..9ac6432f5 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.02.27 19:27}
+\edef\contextversion{2021.03.01 15:33}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index c984f50cf..229feff8a 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.02.27 19:27}
+\newcontextversion{2021.03.01 15:33}
%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 e2afeb0d4..796f686fc 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.02.27 19:27}
+\edef\contextversion{2021.03.01 15:33}
%D Kind of special:
diff --git a/tex/context/base/mkiv/data-env.lua b/tex/context/base/mkiv/data-env.lua
index 53f0c27cc..3b10d89b8 100644
--- a/tex/context/base/mkiv/data-env.lua
+++ b/tex/context/base/mkiv/data-env.lua
@@ -94,7 +94,9 @@ local relations = allocate { -- todo: handlers also here
mp = {
names = { "mp" },
variable = 'MPINPUTS',
- suffixes = { 'mp', 'mpvi', 'mpiv', 'mpxl', 'mpii' },
+ suffixes = CONTEXTLMTXMODE > 0
+ and { 'mp', 'mpxl', 'mpvi', 'mpiv', 'mpii' }
+ or { 'mp', 'mpvi', 'mpiv', 'mpii' },
usertype = true,
},
tex = {
diff --git a/tex/context/base/mkiv/publ-ini.mkiv b/tex/context/base/mkiv/publ-ini.mkiv
index ef2c5cbda..dfed53c73 100644
--- a/tex/context/base/mkiv/publ-ini.mkiv
+++ b/tex/context/base/mkiv/publ-ini.mkiv
@@ -396,6 +396,10 @@
\let\btxsetup\fastsetup
+% This fails when we check field values:
+
+\let\btxrawfield\btxfield
+
\def\btxfield #1{\dostarttagged\t!pubfld{#1}\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\def\btxdetail #1{\dostarttagged\t!pubfld{#1}\clf_btxdetail{\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\def\btxflush #1{\dostarttagged\t!pubfld{#1}\clf_btxflush {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
@@ -681,7 +685,7 @@
\dostarttagged\t!publication\empty
\dotagpublication\currentbtxdataset\currentbtxtag
\redoconvertfont % see (**) in strc-lst, this will become an configuration option
- \edef\currentbtxcategory{\btxfield{category}}%
+ \edef\currentbtxcategory{\btxrawfield{category}}%
\ignorespaces
\ifconditional\c_btx_list_texts
\dostarttagged\t!listtext\s!left
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 0b1992890..58cd21876 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 b52a1d01d..4241ea0a2 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 8e2816e46..088eb9591 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.02.27 19:27}
+\newcontextversion{2021.03.01 15:33}
%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 4976b707d..d84bbb73c 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.02.27 19:27}
+\immutable\edef\contextversion{2021.03.01 15:33}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
@@ -568,6 +568,8 @@
\loadmkxlfile{meta-blb}
\loadmkxlfile{grph-epd}
+\loadmkxlfile{typo-shp}
+
\loadmkxlfile{math-inc} % an experiment
\loadmkxlfile{publ-inc} % an experiment
diff --git a/tex/context/base/mkxl/meta-imp-txt.lmt b/tex/context/base/mkxl/meta-imp-txt.lmt
deleted file mode 100644
index f7721956f..000000000
--- a/tex/context/base/mkxl/meta-imp-txt.lmt
+++ /dev/null
@@ -1,86 +0,0 @@
-if not modules then modules = { } end modules ['meta-imp-txt'] = {
- version = 1.001,
- comment = "companion to meta-imp-txt.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files",
-}
-
-local setmetatableindex = table.setmetatableindex
-
-local texset = tex.set
-
-local scannumeric = mp.scan.numeric
-local scaninteger = mp.scan.integer
-local scanboolean = mp.scan.boolean
-local scanstring = mp.scan.string
-
-local bpfactor = number.dimenfactors.bp
-
-local metapost = metapost
-
-local parshapes = { }
-local properties = { }
-
--- initialize shapes to 0 hsize
-
-metapost.parshapes = { }
-
-function metapost.parshapes.reset()
- parshapes = { }
- properties = { }
-end
-
-function metapost.parshapes.next()
- properties = { }
- parshapes[#parshapes+1] = properties
-end
-
-function metapost.parshapes.inspect()
- inspect(parshapes)
-end
-
-function metapost.parshapes.get(index,name)
- local v = parshapes[index][name]
- if type(v) == "boolean" then
- context(v and 1 or 0)
- else
- context(v)
- end
-end
-
-function metapost.parshapes.wholeshape() -- maybe just collect them earlier
- local t, n = { }, 0
- for i=1,#parshapes do
- local s = parshapes[i].shape
- for i=1,#s do
- n = n + 1
- t[n] = s[i]
- end
- end
- texset("parshape",t)
-end
-
-metapost.registerscript("setparshapeproperty", function()
- local k = scanstring()
- if k == "line" then
- local entry = properties.shape[scannumeric()]
- local indent = scannumeric() / bpfactor
- local width = scannumeric() / bpfactor
- entry[1] = indent
- entry[2] = width
- elseif k == "lines" then
- properties.lines = scaninteger()
- properties.shape = setmetatableindex(function(t,k)
- local v = { 0, properties.width or 0 }
- t[k] = v
- return v
- end)
- elseif k == "first" then
- properties[k] = scanboolean()
- elseif k == "inspect" then
- inspect(properties)
- else
- properties[k] = scannumeric() / bpfactor
- end
-end)
diff --git a/tex/context/base/mkxl/meta-imp-txt.mkxl b/tex/context/base/mkxl/meta-imp-txt.mkxl
index 4654ca722..0c3516a7b 100644
--- a/tex/context/base/mkxl/meta-imp-txt.mkxl
+++ b/tex/context/base/mkxl/meta-imp-txt.mkxl
@@ -21,70 +21,8 @@
%D This time we combine \TEX, \METAPOST\ and \LUA, so we do't need a temporary file
%D to communicate from \METAPOST\ to \TEX. We just store information in \LUA\ tables.
-\ifdefined\startshapetext
-
- % now moved into the core
-
-\else
-
- \ifdefined\shapetextbox \else
- \newbox \shapetextbox
- \newcount\shapetextindex
- \fi
-
- \ctxloadluafile{meta-imp-txt.lmt}
-
- \startMPextensions loadmodule "text" ; \stopMPextensions
-
- \protected\def\startshapetext[#1]%
- {\begingroup
- \global\shapetextindex\zerocount
- \global\setbox\shapetextbox\vbox\bgroup
- % analyze the mp shapes
- \ctxlua{metapost.parshapes.reset()}
- \def\docommand##1%
- {\ctxlua{metapost.parshapes.next()}%
- \startMPcalculation
- \includeMPgraphic{##1}%
- \stopMPcalculation}%
- \processcommalist[#1]\docommand
- \forgetall
- \dontcomplain
- % setup tex part (maybe just enable grid snapping)
- \setuptolerance[\v!verytolerant,\v!stretch]% default
- \setuplayout[\c!grid=\v!yes]%
- \ctxlua{metapost.parshapes.wholeshape()}%
- \pushparagraphtweak {prune}}
-
- \protected\def\stopshapetext
- {\popparagraphtweak
- \egroup
- \endgroup}
-
- \def\getshapeparameter#1{\ctxlua{metapost.parshapes.get(\number\shapetextindex,"#1")}}
-
- \protected\def\getshapetext
- {\vbox\bgroup
- \forgetall
- \dontcomplain
- \global\advance\shapetextindex\plusone
- \scratchcounter\getshapeparameter{lines}\relax
- \scratchwidth \getshapeparameter{width}\scaledpoint\relax
- \scratchheight \getshapeparameter{height}\scaledpoint\relax
- \setbox\scratchbox\vpack to \scratchheight
- {\splittopskip\strutheight
- \vskip\dimexpr\getshapeparameter{voffset}\scaledpoint\relax
- \ifcase\numexpr\getshapeparameter{first}\relax\else
- \vskip\lineheight
- \fi
- \hskip\dimexpr\getshapeparameter{hoffset}\scaledpoint\relax
- \hpack{\vsplit\shapetextbox to \scratchcounter\lineheight}}%
- \wd\scratchbox\scratchwidth
- \ht\scratchbox\scratchheight
- \dp\scratchbox\zeropoint
- \box\scratchbox
- \egroup}
-
+\ifdefined\startshapetext \else
+ \writestatus{system}{something is wrong here}
\fi
%D Following:
diff --git a/tex/context/base/mkxl/mlib-ctx.lmt b/tex/context/base/mkxl/mlib-ctx.lmt
index 558553921..2569a6066 100644
--- a/tex/context/base/mkxl/mlib-ctx.lmt
+++ b/tex/context/base/mkxl/mlib-ctx.lmt
@@ -80,7 +80,7 @@ implement {
}
local patterns = {
- CONTEXTLMTXMODE > 0 and "meta-imp-%s.mkxl" or "",
+ "meta-imp-%s.mkxl",
"meta-imp-%s.mkiv",
"meta-imp-%s.tex",
-- obsolete:
diff --git a/tex/context/base/mkxl/mlib-fio.lmt b/tex/context/base/mkxl/mlib-fio.lmt
index bc890a37d..2e31d56d1 100644
--- a/tex/context/base/mkxl/mlib-fio.lmt
+++ b/tex/context/base/mkxl/mlib-fio.lmt
@@ -69,7 +69,7 @@ local suffixlist = { "mpxl", "mpiv", "mp" } -- no "mf"
local function findmpfile(name,ftype)
local validtyp = validftype(ftype)
local fullname = findfile(name,validtyp)
- if fullname and fulllname ~= "" then
+ if fullname and fullname ~= "" then
return fullname
elseif suffix(name) == "" then
for i=1,#suffixlist do
diff --git a/tex/context/base/mkxl/mlib-lua.lmt b/tex/context/base/mkxl/mlib-lua.lmt
index e8f33a53a..068d17f32 100644
--- a/tex/context/base/mkxl/mlib-lua.lmt
+++ b/tex/context/base/mkxl/mlib-lua.lmt
@@ -63,7 +63,7 @@ scan.property = function(k) if trace then reporti("property") end return s
scan.numeric = function() if trace then reporti("numeric") end return scan_numeric (currentmpx) end
scan.integer = function() if trace then reporti("integer") end return scan_integer (currentmpx) end
scan.boolean = function() if trace then reporti("boolean") end return scan_boolean (currentmpx) end
-scan.string = function() if trace then reporti("string") end if currentmpx then return scan_string (currentmpx) end end
+scan.string = function() if trace then reporti("string") end return scan_string (currentmpx) end
scan.pair = function(t) if trace then reporti("pair") end return scan_pair (currentmpx,t) end
scan.color = function(t) if trace then reporti("color") end return scan_color (currentmpx,t) end
scan.cmykcolor = function(t) if trace then reporti("cmykcolor") end return scan_cmykcolor (currentmpx,t) end
diff --git a/tex/context/base/mkxl/mlib-mpf.lmt b/tex/context/base/mkxl/mlib-mpf.lmt
index 42cee676c..87b6c2d4e 100644
--- a/tex/context/base/mkxl/mlib-mpf.lmt
+++ b/tex/context/base/mkxl/mlib-mpf.lmt
@@ -22,7 +22,8 @@ local report_luarun = logs.reporter("metapost","lua")
local report_script = logs.reporter("metapost","script")
local report_message = logs.reporter("metapost")
-local trace_luarun = false trackers.register("metapost.lua",function(v) trace_luarun = v end)
+local trace_luarun = false trackers.register("metapost.lua", function(v) trace_luarun = v end)
+local trace_script = false trackers.register("metapost.script",function(v) trace_script = v end)
local be_tolerant = true directives.register("metapost.lua.tolerant", function(v) be_tolerant = v end)
@@ -86,11 +87,18 @@ do
else
runscripts[nofscripts] = name
end
+ if trace_script then
+ report_script("registering script %a as %i",name,nofscripts)
+ end
return nofscripts
end
function metapost.scriptindex(name)
- return runnames[name] or 0
+ local index = runnames[name] or 0
+ if trace_script then
+ report_script("fetching scriptindex %i of %a",index,name)
+ end
+ return index
end
-- The gbuffer sharing and such is not really needed now but make a dent when
diff --git a/tex/context/base/mkxl/mlib-run.lmt b/tex/context/base/mkxl/mlib-run.lmt
index a79ce99ef..eacb148cc 100644
--- a/tex/context/base/mkxl/mlib-run.lmt
+++ b/tex/context/base/mkxl/mlib-run.lmt
@@ -327,7 +327,9 @@ function metapost.pushformat(specification,f,m) -- was: instance, name, method
end
end
if preamble then
+ metapost.pushscriptrunner(mpx)
executempx(mpx,preamble)
+ metapost.popscriptrunner()
end
specification.mpx = mpx
return mpx
diff --git a/tex/context/base/mkxl/node-par.lmt b/tex/context/base/mkxl/node-par.lmt
index 9354d769f..125c1b687 100644
--- a/tex/context/base/mkxl/node-par.lmt
+++ b/tex/context/base/mkxl/node-par.lmt
@@ -11,7 +11,10 @@ local stoptiming = statistics.stoptiming
local sequencers = utilities.sequencers
--- This are called a lot!
+-- This is called a lot! I'm a bit reluctant with this one because it is
+-- sensitive for order. In many other callbacks ther eis no action at the
+-- tex end but here ... Anyway, it has been around for a while now (2019)
+-- and so far I had no need for extensive usage so we're okay.
do
@@ -28,6 +31,10 @@ do
end
+-- Originally this one was meant to deal with the indentation (like turn a box into
+-- a skip or prevent it) but that never really was used. The return value still
+-- detemines if an indentation box or skip is injected. Will I change that?
+
do
local actions = sequencers.new {
@@ -41,11 +48,11 @@ do
sequencers.appendgroup(actions,"system") -- private
sequencers.appendgroup(actions,"after" ) -- user
- local function paragraph(mode,indented)
+ local function paragraph(mode,indented,context) -- context used to be the cmd code
local runner = actions.runner
if runner then
starttiming(builders)
- indented = runner(mode,indented)
+ indented = runner(mode,indented,context)
stoptiming(builders)
end
return indented
@@ -58,7 +65,8 @@ end
-- This one is a playground for some old metafun gimmicks that I want to improve
-- while I'm updating the manual to lmtx. but it might also be useful for other
-- purposes. It fits in the category obscure and probably takes while to stabelize
--- (if it stays at all).
+-- (if it stays at all). Again, this is one that has the danger of interference,
+-- so when it finally got an action handler it only got a system one.
do
@@ -86,3 +94,8 @@ do
callbacks.register("paragraph_context",parcontext,"when the context is dealt with")
end
+
+-- This means that we now have most callbacks in use, even the ones that I'm not sure
+-- about. It also means that with the above enabled we might have performance now at
+-- its worst. I can optimize this a little but it's not worth the effort (and added
+-- complication).
diff --git a/tex/context/base/mkxl/publ-ini.mkxl b/tex/context/base/mkxl/publ-ini.mkxl
index b1af17413..2f4d817f2 100644
--- a/tex/context/base/mkxl/publ-ini.mkxl
+++ b/tex/context/base/mkxl/publ-ini.mkxl
@@ -398,12 +398,22 @@
\aliased\let\btxsetup\fastsetup
+\permanent\def\btxrawfield #1{\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}}
+
\permanent\def\btxfield #1{\dostarttagged\t!pubfld{#1}\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\permanent\def\btxdetail #1{\dostarttagged\t!pubfld{#1}\clf_btxdetail{\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\permanent\def\btxflush #1{\dostarttagged\t!pubfld{#1}\clf_btxflush {\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
\permanent\def\btxdirect #1{\dostarttagged\t!pubfld{#1}\clf_btxdirect{\currentbtxdataset}{\currentbtxtag}{#1}\dostoptagged}
%permanent\def\btxauthorfield#1{\dostarttagged\t!pubfld{#1}\clf_btxauthorfield \currentbtxauthorindex{#1}\dostoptagged}
+% Also possible but inefficient:
+%
+% \permanent\def\btxfield #1{\localcontrolled{\dostarttagged\t!pubfld{#1}}\clf_btxfield {\currentbtxdataset}{\currentbtxtag}{#1}\localcontrolled{\dostoptagged}}
+% \permanent\def\btxdetail #1{\localcontrolled{\dostarttagged\t!pubfld{#1}}\clf_btxdetail{\currentbtxdataset}{\currentbtxtag}{#1}\localcontrolled{\dostoptagged}}
+% \permanent\def\btxflush #1{\localcontrolled{\dostarttagged\t!pubfld{#1}}\clf_btxflush {\currentbtxdataset}{\currentbtxtag}{#1}\localcontrolled{\dostoptagged}}
+% \permanent\def\btxdirect #1{\localcontrolled{\dostarttagged\t!pubfld{#1}}\clf_btxdirect{\currentbtxdataset}{\currentbtxtag}{#1}\localcontrolled{\dostoptagged}}
+% %permanent\def\btxauthorfield#1{\localcontrolled{\dostarttagged\t!pubfld{#1}}\clf_btxauthorfield \currentbtxauthorindex{#1}\localcontrolled{\dostoptagged}}
+
%D How complex will we go? Can we assume that e.g. an apa style will not be mixed
%D with another one? I think this assumption is okay. For manuals we might want to
%D mix but we can work around it.
@@ -691,7 +701,7 @@
\dostarttagged\t!publication\empty
\dotagpublication\currentbtxdataset\currentbtxtag
\redoconvertfont % see (**) in strc-lst, this will become an configuration option
- \edef\currentbtxcategory{\btxfield{category}}%
+ \edef\currentbtxcategory{\btxrawfield{category}}%
\ignorespaces
\ifconditional\c_btx_list_texts
\dostarttagged\t!listtext\s!left
diff --git a/tex/context/base/mkxl/spac-par.lmt b/tex/context/base/mkxl/spac-par.lmt
index 3af8ea415..179fc1f43 100644
--- a/tex/context/base/mkxl/spac-par.lmt
+++ b/tex/context/base/mkxl/spac-par.lmt
@@ -78,3 +78,4 @@ implement {
context(t and t[wrappers[id]] or 0)
end
}
+
diff --git a/tex/context/base/mkxl/spac-par.mkxl b/tex/context/base/mkxl/spac-par.mkxl
index 06aeee4d8..134a60e2a 100644
--- a/tex/context/base/mkxl/spac-par.mkxl
+++ b/tex/context/base/mkxl/spac-par.mkxl
@@ -453,59 +453,4 @@
\expandafter\firstofoneargument
\fi}
-%D Something new (experimental and evolving):
-%D
-%D \starttyping
-%D \parshape
-%D 3
-%D options 1 % repeat
-%D 0cm 10cm 2cm 8cm 4cm 6cm
-%D lots of text
-%D \stoptyping
-%D
-%D \starttyping
-%D \parshape 4 5mm 125mm 0mm 120mm 5mm 125mm 0mm 120mm
-%D \pushparagraphtweak {repeat}
-%D verse line 1\crlf
-%D verse line 2\crlf
-%D verse line 3\crlf
-%D verse line 4\par
-%D etc
-%D \popparagraphtweak
-%D \stoptyping
-
-%D But we wrap this in a more abstract interface:
-
-\installcorenamespace {parshapes}
-
-% \installcommandhandler \??shapedparagraph {shapedparagraph} \??shapedparagraph
-
-\aliased\let\stopparagraphshape\relax
-
-\permanent\protected\def\startparagraphshape[#1]#2\stopparagraphshape
- {\defcsname\??parshapes#1\endcsname{#2}}
-
-\permanent\protected\def\rawparagraphshape#1%
- {\begincsname\??parshapes#1\endcsname}
-
-\permanent\protected\def\setparagraphshape[#1]%
- {\ifcsname\??parshapes#1\endcsname
- \expandafter\clf_setparagraphshape\lastnamedcs done\relax
- \fi}
-
-% \permanent\protected\tolerant\def\startshapedparagraph[#1]#*[#2]% no grouping
-% {\setparshape[#1]%
-% \pushparagraphtweak{#2}\relax}
-
-\permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping
- {\begingroup
- \getdummyparameters[\c!method=,\c!list=,#1]%
- \normalexpanded
- {\endgroup
- \setparagraphshape[\dummyparameter\c!list]%
- \pushparagraphtweak{\dummyparameter\c!method}\relax}}
-
-\permanent\protected\def\stopshapedparagraph
- {\popparagraphtweak}
-
\protect \endinput
diff --git a/tex/context/base/mkxl/typo-par.lmt b/tex/context/base/mkxl/typo-par.lmt
index c7204ecd2..b5751e497 100644
--- a/tex/context/base/mkxl/typo-par.lmt
+++ b/tex/context/base/mkxl/typo-par.lmt
@@ -21,31 +21,44 @@ local appendaction = sequencers.appendaction
local enableaction = sequencers.enableaction
local disableaction = sequencers.disableaction
+local implement = interfaces.implement
+
local stack = { }
local top = nil
local enabled = false
-interfaces.implement {
+local trace = false trackers.register("paragraphs.tweaks",function(v) trace = v end)
+
+local report = logs.reporter("paragraphs","tweaks")
+
+implement {
name = "pushparagraphtweak",
public = true,
protected = true,
arguments = "string",
actions = function(t)
insert(stack,top)
- if not top then
+ if not enabled then
+ if trace then
+ report("enabling")
+ end
enableaction("paragraphcontext","builders.checkparcontext")
enabled = true
end
top = t
end
}
-interfaces.implement {
+
+implement {
name = "popparagraphtweak",
public = true,
protected = true,
actions = function()
top = remove(stack)
- if not top then
+ if enabled and not top then
+ if trace then
+ report("disabling")
+ end
disableaction("paragraphcontext","builders.checkparcontext")
enabled = false
end
@@ -61,12 +74,21 @@ function builders.checkparcontext(where)
while p > s do
p = p - s
end
+ if trace then
+ report("cycling %i",s)
+ end
shiftparshape(p,true)
+ return true
end
- return true
elseif top == "shift" then
- shiftparshape(texget("prevgraf"))
- return true
+ local s = texget("parshape",true)
+ if s then
+ if trace then
+ report("shifting %i", s)
+ end
+ shiftparshape(texget("prevgraf"))
+ return true
+ end
end
end
end
@@ -85,7 +107,7 @@ do
local scandimen = scanners.dimen
local scancardinal = scanners.cardinal
- interfaces.implement {
+ implement {
name = "setparagraphshape",
protected = true,
actions = function()
@@ -140,7 +162,7 @@ do
local NR = context.NR
local VL = context.VL
- interfaces.implement {
+ implement {
name = "showparagraphshape",
protected = true,
public = true,
diff --git a/tex/context/base/mkxl/typo-shp.lmt b/tex/context/base/mkxl/typo-shp.lmt
new file mode 100644
index 000000000..27cafe1bd
--- /dev/null
+++ b/tex/context/base/mkxl/typo-shp.lmt
@@ -0,0 +1,117 @@
+if not modules then modules = { } end modules ['meta-imp-txt'] = {
+ version = 1.001,
+ comment = "companion to meta-imp-txt.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files",
+}
+
+local setmetatableindex = table.setmetatableindex
+local settings_to_array = utilities.parsers.settings_to_array
+
+local texset = tex.set
+local texgetcount = tex.getcount
+
+local expandmacro = token.expand_macro
+
+local implement = interfaces.implement
+
+local scan = mp.scan
+local scannumeric = scan.numeric
+local scaninteger = scan.integer
+local scanboolean = scan.boolean
+local scanstring = scan.string
+
+local bpfactor = number.dimenfactors.bp
+
+local context = context
+
+local parshapes = { }
+local properties = { }
+
+metapost.registerscript("setparshapeproperty", function()
+ local k = scanstring()
+ if k == "line" then
+ local entry = properties.shape[scannumeric()]
+ local indent = scannumeric() / bpfactor
+ local width = scannumeric() / bpfactor
+ entry[1] = indent
+ entry[2] = width
+ elseif k == "lines" then
+ properties.lines = scaninteger()
+ properties.shape = setmetatableindex(function(t,k)
+ local v = { 0, properties.width or 0 }
+ t[k] = v
+ return v
+ end)
+ elseif k == "first" then
+ properties[k] = scanboolean()
+ elseif k == "inspect" then
+ inspect(properties)
+ else
+ properties[k] = scannumeric() / bpfactor
+ end
+end)
+
+implement {
+ name = "setparagraphmetashape",
+ public = true,
+ protected = true,
+ arguments = { "optional", "optional" }, -- array
+ actions = function(list,options)
+ if list and list ~= "" then
+ list = settings_to_array(list) -- array
+ options = settings_to_array(options) -- array
+ if #list > 0 then
+ parshapes = { }
+ properties = { }
+ for i=1,#list do
+ properties = { }
+ parshapes[i] = properties
+ expandmacro("spac_shapes_calculate","{"..list[i].."}")
+ end
+ local t, n = { }, 0
+ for i=1,#parshapes do
+ local p = parshapes[i]
+ local s = p.shape
+ if s then
+ for i=1,(p.lines or #s) do
+ n = n + 1
+ t[n] = s[i]
+ end
+ end
+ end
+ if n > 0 then
+ for i=1,#options do
+ t[options[i]] = true
+ end
+ texset("parshape",t)
+ end
+ end
+ end
+ end
+}
+
+-- implement {
+-- name = "resetparagraphmetashape",
+-- public = true,
+-- protected = true,
+-- actions = function(list)
+-- parshapes = { }
+-- properties = { }
+-- end
+-- }
+
+implement {
+ name = "getshapeparameter",
+ public = true,
+ arguments = "string",
+ actions = function(name)
+ local index = texgetcount("shapetextindex")
+ local value = parshapes[index][name]
+ if type(value) == "boolean" then
+ value = value and 1 or 0
+ end
+ context(value)
+ end
+}
diff --git a/tex/context/base/mkxl/typo-shp.mkxl b/tex/context/base/mkxl/typo-shp.mkxl
new file mode 100644
index 000000000..295fe3e1b
--- /dev/null
+++ b/tex/context/base/mkxl/typo-shp.mkxl
@@ -0,0 +1,125 @@
+%D \module
+%D [ file=typo-shp,
+%D version=2021.02.27, % was meta-txt / meta-imp-txt / 2000.07.06
+%D title=\CONTEXT\ Typesetting Macros,
+%D subtitle=Paragraph Shapes,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D I finally decided to move some of the code written in 2000 for the
+%D \METAFUN\ manual to its own core module. Of course it got adapted
+%D to the way \LMTX\ does things.
+
+\writestatus{loading}{ConTeXt Spacing Macros / Paragraph Shapes}
+
+\registerctxluafile{typo-shp}{autosuffix}
+
+\unprotect
+
+%D Something new (experimental and evolving):
+%D
+%D \starttyping
+%D \parshape
+%D 3
+%D options 1 % repeat
+%D 0cm 10cm 2cm 8cm 4cm 6cm
+%D lots of text
+%D \stoptyping
+%D
+%D \starttyping
+%D \parshape 4 5mm 125mm 0mm 120mm 5mm 125mm 0mm 120mm
+%D \pushparagraphtweak {repeat}
+%D verse line 1\crlf
+%D verse line 2\crlf
+%D verse line 3\crlf
+%D verse line 4\par
+%D etc
+%D \popparagraphtweak
+%D \stoptyping
+
+%D But we wrap this in a more abstract interface:
+
+\installcorenamespace {parshapes}
+
+\aliased\let\stopparagraphshape\relax
+
+\permanent\protected\def\startparagraphshape[#1]#2\stopparagraphshape
+ {\defcsname\??parshapes#1\endcsname{#2}}
+
+\permanent\protected\def\rawparagraphshape#1%
+ {\begincsname\??parshapes#1\endcsname}
+
+\permanent\protected\def\setparagraphshape[#1]%
+ {\ifcsname\??parshapes#1\endcsname
+ \expandafter\clf_setparagraphshape\lastnamedcs done\relax
+ \fi}
+
+\def\spac_shapes_calculate#1% called locally in \LUA
+ {\startMPcalculation \includeMPgraphic{#1} \stopMPcalculation}
+
+\permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping
+ {\begingroup
+ \getdummyparameters[\c!method=,\c!list=,\c!mp=,\c!repeat=,#1]%
+ \edef\p_mp {\dummyparameter\c!mp}%
+ \edef\p_repeat{\dummyparameter\c!repeat}%
+ \normalexpanded
+ {\endgroup
+ \ifempty\p_mp
+ \setparagraphshape[\dummyparameter\c!list]%
+ \else
+ \setparagraphmetashape[\dummyparameter\c!mp][\ifx\p_repeat\v!yes repeat\fi]%
+ \fi
+ \pushparagraphtweak{\dummyparameter\c!method}\relax}}
+
+\permanent\protected\def\stopshapedparagraph
+ {\popparagraphtweak}
+
+%D As it is not much code we now put it here:
+
+\newbox \shapetextbox
+\newcount\shapetextindex
+
+\permanent\protected\def\startshapetext[#1]%
+ {\begingroup
+ \global\shapetextindex\zerocount
+ \global\setbox\shapetextbox\vbox\bgroup
+ \setparagraphmetashape[#1]%
+ \forgetall
+ \dontcomplain
+ \setuptolerance[\v!verytolerant,\v!stretch]% default
+ % \setuplayout[\c!grid=\v!yes]% goes wrong, we need a local one
+ \pushparagraphtweak {shift}}
+
+\permanent\protected\def\stopshapetext
+ {\popparagraphtweak
+ \egroup
+ \endgroup}
+
+\permanent\protected\def\getshapetext
+ {\vbox\bgroup
+ \forgetall
+ \dontcomplain
+ \global\advance\shapetextindex\plusone
+ \scratchcounter\getshapeparameter{lines}\relax
+ \scratchwidth \getshapeparameter{width}\scaledpoint\relax
+ \scratchheight \getshapeparameter{height}\scaledpoint\relax
+ \setbox\scratchbox\vpack to \scratchheight
+ {\splittopskip\strutheight
+ \vskip\dimexpr\getshapeparameter{voffset}\scaledpoint\relax
+ \ifcase\numexpr\getshapeparameter{first}\relax\else
+ \vskip\lineheight
+ \fi
+ \hskip\dimexpr\getshapeparameter{hoffset}\scaledpoint\relax
+ \hpack{\vsplit\shapetextbox to \scratchcounter\lineheight}}%
+ \wd\scratchbox\scratchwidth
+ \ht\scratchbox\scratchheight
+ \dp\scratchbox\zeropoint
+ \box\scratchbox
+ \egroup}
+
+\protect
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 2880d77c0..c56b84c59 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-02-27 19:27
+-- merge date : 2021-03-01 15:33
do -- begin closure to overcome local limits and interference