From 59e7679528d75e5d523acddf69dabdce42d53734 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 14 Aug 2019 12:32:10 +0200 Subject: 2019-08-14 11:34:00 --- .../documents/general/magazines/mag-1104-mkiv.pdf | Bin 0 -> 781988 bytes doc/context/documents/general/qrcs/setup-cs.pdf | Bin 882515 -> 882637 bytes doc/context/documents/general/qrcs/setup-de.pdf | Bin 884238 -> 884356 bytes doc/context/documents/general/qrcs/setup-en.pdf | Bin 889788 -> 889903 bytes doc/context/documents/general/qrcs/setup-fr.pdf | Bin 881024 -> 881145 bytes doc/context/documents/general/qrcs/setup-it.pdf | Bin 886213 -> 886338 bytes .../documents/general/qrcs/setup-mapping-cs.pdf | Bin 349365 -> 349477 bytes .../documents/general/qrcs/setup-mapping-de.pdf | Bin 434844 -> 434914 bytes .../documents/general/qrcs/setup-mapping-en.pdf | Bin 346829 -> 346936 bytes .../documents/general/qrcs/setup-mapping-fr.pdf | Bin 349708 -> 349826 bytes .../documents/general/qrcs/setup-mapping-it.pdf | Bin 348766 -> 348883 bytes .../documents/general/qrcs/setup-mapping-nl.pdf | Bin 347662 -> 347778 bytes .../documents/general/qrcs/setup-mapping-ro.pdf | Bin 512734 -> 512844 bytes doc/context/documents/general/qrcs/setup-nl.pdf | Bin 875927 -> 876037 bytes doc/context/documents/general/qrcs/setup-ro.pdf | Bin 880672 -> 880785 bytes .../sources/general/magazines/mag-1104-mkiv.tex | 813 +++++++++++++++++++++ scripts/context/lua/mtxrun.lua | 11 +- scripts/context/stubs/mswin/mtxrun.lua | 11 +- scripts/context/stubs/unix/mtxrun | 11 +- scripts/context/stubs/win64/mtxrun.lua | 11 +- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/attr-ini.mkiv | 59 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/context.mkxl | 2 +- tex/context/base/mkiv/lxml-tab.lua | 5 +- tex/context/base/mkiv/node-aux.lua | 17 +- tex/context/base/mkiv/node-nut.lua | 12 +- tex/context/base/mkiv/page-one.mkiv | 8 +- tex/context/base/mkiv/status-files.pdf | Bin 26626 -> 26647 bytes tex/context/base/mkiv/status-lua.pdf | Bin 267827 -> 267852 bytes tex/context/base/mkiv/strc-flt.mkvi | 51 +- tex/context/base/mkiv/typo-drp.lua | 420 +++++------ tex/context/base/mkiv/typo-drp.mkiv | 18 +- tex/context/base/mkiv/typo-fln.lua | 54 +- tex/context/base/mkiv/typo-fln.mkiv | 2 +- tex/context/interface/mkiv/i-context.pdf | Bin 889788 -> 889903 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61165 -> 61165 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 40 files changed, 1193 insertions(+), 322 deletions(-) create mode 100644 doc/context/documents/general/magazines/mag-1104-mkiv.pdf create mode 100644 doc/context/sources/general/magazines/mag-1104-mkiv.tex diff --git a/doc/context/documents/general/magazines/mag-1104-mkiv.pdf b/doc/context/documents/general/magazines/mag-1104-mkiv.pdf new file mode 100644 index 000000000..ee73daea5 Binary files /dev/null and b/doc/context/documents/general/magazines/mag-1104-mkiv.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf index 053434a00..eec546a8f 100644 Binary files a/doc/context/documents/general/qrcs/setup-cs.pdf and b/doc/context/documents/general/qrcs/setup-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf index d2c3e3970..206ed45b1 100644 Binary files a/doc/context/documents/general/qrcs/setup-de.pdf and b/doc/context/documents/general/qrcs/setup-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf index 0060c1245..9c6b51114 100644 Binary files a/doc/context/documents/general/qrcs/setup-en.pdf and b/doc/context/documents/general/qrcs/setup-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf index ad12d606f..1e3bb51fd 100644 Binary files a/doc/context/documents/general/qrcs/setup-fr.pdf and b/doc/context/documents/general/qrcs/setup-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf index ba2082c5e..d62f091e5 100644 Binary files a/doc/context/documents/general/qrcs/setup-it.pdf and b/doc/context/documents/general/qrcs/setup-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf index 8fe71aaa5..2695239de 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf and b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf index b17b2ac41..c57684098 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-de.pdf and b/doc/context/documents/general/qrcs/setup-mapping-de.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf index c6d67a543..b63d13dac 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-en.pdf and b/doc/context/documents/general/qrcs/setup-mapping-en.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf index cc32921ec..16fe62c4e 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf and b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf index d381bab3f..79feb3bb0 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-it.pdf and b/doc/context/documents/general/qrcs/setup-mapping-it.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf index 7c756960b..81e6b0e8f 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf and b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf index b31992fa1..e5560e2cf 100644 Binary files a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf and b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf index 2132fc97d..0a6d65781 100644 Binary files a/doc/context/documents/general/qrcs/setup-nl.pdf and b/doc/context/documents/general/qrcs/setup-nl.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf index 5877b9de7..c3d5de9c8 100644 Binary files a/doc/context/documents/general/qrcs/setup-ro.pdf and b/doc/context/documents/general/qrcs/setup-ro.pdf differ diff --git a/doc/context/sources/general/magazines/mag-1104-mkiv.tex b/doc/context/sources/general/magazines/mag-1104-mkiv.tex new file mode 100644 index 000000000..4cbc3d921 --- /dev/null +++ b/doc/context/sources/general/magazines/mag-1104-mkiv.tex @@ -0,0 +1,813 @@ +% author : Hans Hagen +% copyright : PRAGMA ADE & ConTeXt Development Team +% license : Creative Commons Attribution ShareAlike 4.0 International +% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions +% origin : the ConTeXt distribution +% +% comment : Because this manual is distributed with TeX distributions it comes with a rather +% liberal license. We try to adapt these documents to upgrades in the (sub)systems +% that they describe. Using parts of the content otherwise can therefore conflict +% with existing functionality and we cannot be held responsible for that. Many of +% the manuals contain characteristic graphics and personal notes or examples that +% make no sense when used out-of-context. + +\usemodule[magazine-basic,abr-02] + +\usemodule[scite] + +\startbuffer[abstract] + As part of the \CONTEXT\ \LMTX\ project, we experiment with new ways to + interface subsystems and \METAPOST\ makes a good candidate. Here I wrap up some + experiments. It's not a manual or a recipe, just food for thought. All you see + here might change and|/|or evolve. +\stopbuffer + +\setuplayout + [backspace=20mm, + topspace=10mm] + +\startdocument + [title={New interfacing in \METAFUN, a preview}, + author={Hans Hagen & Alan Braslau}, + %affiliation=PRAGMA ADE, + date=July 2019, + number=1104 LMTX] + +As we move to \CONTEXT\ \LMTX, some decisions need to be made. For instance, how +shall we introduce new functionality while not affecting the \MKIV\ code base too +much with engine related tests, messy and performance sapping. Of course we +remain downward compatible but the \LUAMETATEX\ engine sometimes permits multiple +solutions. As this is something new, for a while we can use experimental features +that may change or later disappear depending on experience. It is not a big deal +to adapt to these new possibilites and users shouldn't notice, unless of course +they currently employ (yet undocumented) low|-|level features. Part of the +solution is to have separate files for \MKIV\ and \LMTX, although that will +mostly concern low level support modules; even then differences will be subtle +and should not affect users. I must admit that some of those changes are mostly +aesthetic and often don't improve performance, although better performance +sometimes may be the case, in particular concerning \quote {extreme} usage. + +But, that said, there are areas where \LMTX\ will offer entirely new +functionality. One of the areas where we are making interesting developments is +in \METAFUN, which means \METAPOST. Now, it is not to be said that some of the +core functionality needed for this will migrate from \LUAMETATEX\ (used by \LMTX) +to \LUATEX\ (used by \MKIV). But, because (due to external pressure), the later +engine is now considered stable and its functionality frozen, it is not likely to +be quickly backported or at least only will happen when this has been throughly +tested in \CONTEXT|/|\LMTX. + +Over the years there have been (small) improvements in the interface but while +Alan Braslau and I experiment with new graphic abilities, we also are coming up +with (graphic) interfaces that suit \CONTEXT\ much better. Below, I will show +some examples. \footnote {These optional argument handlers themselves are +\emphasize {not} part of \METAPOST\ but implemented in \CONTEXT\ using some +experimental parsing related extensions to a version of \MPLIB\ used in +\LUAMETATEX.} + +\startbuffer +\startMPcode{doublefun} + draw lmt_grid [ + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 10, ty = 10, + ] ysized 5cm withpen pencircle scaled 1mm withcolor "red" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +What we see here is an key|/|value driven interface that has been one of the +unique core properties of \CONTEXT\ since it was created. \footnote {Note the use +of the color string \type {"red"} rather then the \METAPOST\ color variable \type +{red := (1,0,0)}. This is a small detail but here imports the color definition +from \CONTEXT, which might be a bit special.} Of course parameters can be +optional as demonstrated in: + +\startbuffer +\startMPcode{doublefun} + draw lmt_grid [ + nx = 10, ny = 10, + dx = 1, dy = 1 + ] ysized 3cm + withpen pencircle scaled 1mm + withcolor "darkblue" ; + + draw lmt_grid [ + nx = 10, ny = 10 + ] ysized 3cm shifted (4cm,0) + withpen pencircle scaled .3mm + withcolor "darkgreen" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +This syntax means that we can also use the already used interface documentation +system. + +We can actually go quite far in what we provide. It's not so much that these +things were not possible before, but the more concise user interface is something +new indeed. Let's start with drawing some simple axis: + +\startbuffer +\startMPcode{doublefun} + draw lmt_axis [ + nx = 20, ny = 10, + dx = 5, dy = 2, + ] ysized 4cm + withpen pencircle scaled 1mm + withcolor "darkcyan" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +This \quote {article} is not meant as tutorial but more as a teaser about what is +possible and hopefully it triggers users in coming up with useful demands. As the +previous axis example is not that interesting we move on to a more complex one: + +\startbuffer +\startMPcode{doublefun} + draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 10, ty = 10, + ] withpen pencircle scaled 1mm withcolor "darkblue" ; + + draw lmt_connected ( + for i = 1 step 2 until 20 : + -- (i, 1 randomized 8) * 5mm + endfor + ) + withpen pencircle scaled 2mm withcolor "darkyellow" ; + + draw lmt_connected ( + for i = 1 step 2 until 20 : + lmt_connection (i, 1 randomized 8) * 5mm + endfor + ) + withpen pencircle scaled 2mm withcolor "darkgreen" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +These examples are made as part of exploring how to best interface with +\METAPOST, to be used by the upcoming luagraph module, a flexible and high +performance set of macros aimed at drawing graphs and to visualize data. On the +one hand, we want to free the user from dealing with details such as scales to +get the graphics right, but on the other hand it should be possible to +fine|-|tune when needed. + +Again we draw an axis. Using strings as color names, mentioned in the footnote +earlier, is not new, but already present for a while. It will use the colors +defined at the \TEX\ end and is more convenient and natural than using the older +\type {\MPcolor}. The \type {lmt_connected} macro is sort of a gimmick: if you +look closely you will see that it has to start with a point (coordinate) but that +one is discarded silently. Again this is something we need to deal with. + +% This is obscure, and silly. I'm sure that we can do better. Sure, but so is the +% HIDE related alternative trrickery. We probably need something getparameterpath. + +The next variant uses a list of samples. Watch the use of braces, this is +something normally not part of \METAPOST\ syntax, and it signals a \LUA|-|like +list. This is a choice of interfacing. There are subtle and somewhat complicated +aspects involved here as \METAPOST\ parsing involves primaries, secondaries, +tertiaries and expressions, symbols, strings, tags and other specialities. + +% Why does samples = {} require a second pair of brackets? Wouldn't a +% comma-separated list be enough in Lua? Because it's \METAPOST\ which has its own +% ideas about where expressions start and end. + +\startbuffer +\startMPcode{doublefun} + draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 5, ty = 2, + startx = 1, starty = 0, + + connect = true, + samples = { + { + 4, 2, 4, 9, 3, 0, 8, 9, 10, 1, + 5, 3, 0, 8, 5, 6, 10, 2, 3, 5 + } + }, + axiscolor = "darkgreen", + textcolor = "darkred", + samplecolors = { + "darkblue" + }, + ] withpen pencircle scaled 1mm ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +We can have multiple sample lists. But of course dealing with that is really up +to the underlying code, which itself is not that much related to \METAPOST\ but +has been delegated to \LUA. + +\startbuffer +\definecolor[tdarkred] [r=.6,a=1,t=.5] +\definecolor[tdarkgreen][g=.6,a=1,t=.5] +\definecolor[tdarkblue] [b=.6,a=1,t=.5] + +\startMPcode{doublefun} + save u ; let u = uniformdeviate ; + draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 10, ty = 2, + samples = { + { + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10 + }, + { + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10 + }, + { + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10, + u10, u10, u10, u10, u10 + } + }, + startx = 1, + starty = 0, + connect = true, + axiscolor = "darkgray", + textcolor = "darkyellow", + samplecolors = { + "tdarkred", + "tdarkgreen", + "tdarkblue" + }, + ] withpen pencircle scaled 1mm ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +Yet another interesting variant might be this: + +\startbuffer +\startluacode + documentdata["lmx-sample-1"] = { + { + 4, 2, 4, 9, 3, 0, 8, 9, 10, 1, + 5, 3, 0, 8, 5, 6, 10, 2, 3, 5 + } + } +\stopluacode +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +\startbuffer +\startMPcode{doublefun} + draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 5, ty = 2, + startx = 1, starty = 0, + + samples = "lmx-sample-1", + axiscolor = "darkgreen", + textcolor = "darkred", + samplecolors = { "darkblue" }, + ] withpen pencircle scaled 1mm ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +% OOPS, doesn't work! + +Adding more tricks is not that complex, take, for example: + +\startbuffer +\startMPcode{doublefun} +draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 10, ty = 10, + + list = { + [ + connect = true, + color = "darkred", + close = true, + points = { (1, 1), (15, 8), (2, 10) }, + texts = { "segment 1", "segment 2", "segment 3" } + ], + [ + connect = true, + color = "darkgreen", + points = { (2, 2), (4, 1), (10, 3), (16, 8), (19, 2) }, + labels = { "a", "b", "c", "d", "e" } + ], + [ + connect = true, + color = "darkblue", + close = true, + points = { (5, 3), (8, 8), (16, 1) }, + labels = { "1", "2", "3" } + ] + }, + +] withpen pencircle scaled 1mm ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +yielding + +\startlinecorrection +\getbuffer +\stoplinecorrection + +but this is experimentation, work in progress, not to be taken as settled. + +\blank + +A variant on this one is the following: + +\startbuffer +\startMPcode{doublefun} +draw lmt_function [ + + xmin = 0, xmax = 10, xstep = .05, + ymin = -2, ymax = 2, + + xticks = "bottom", xsmall = 80, xlarge = 20, + yticks = "left", ysmall = 40, ylarge = 4, + + code = "1.5 * math.cosd(240 * math.sqrt(x))", + + xlabels = "yes", + ylabels = "yes", + + ycaption = "\strut\tfd \rotate[rotation=90]{vertical}", + xcaption = "\strut\tfd horizontal", + + pointsymbol = "dot", pointsize = 4, pointcolor = "orange", + + sx = 2mm, sy = 4mm, linewidth = .025mm, offset = .1mm, +] + xsized 8cm +; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +A valid question is if this should be combined with the previous but having +distinctive variants is less likely to complicate the settings, as these can +depend on the application: + +\startlinecorrection +\getbuffer +\stoplinecorrection + +A more complex usage (still under exploration) is demonstrated next: + +\startbuffer +\definecolor[MyColorR][r=.5,t=.5,a=1] +\definecolor[MyColorG][g=.5,t=.5,a=1] +\definecolor[MyColorB][b=.5,t=.5,a=1] +\definecolor[MyColorY][r=.5,g=.5,t=.5,a=1] + +\startMPcode{doublefun} +draw lmt_function [ + sx = 1mm, sy = 4mm, linewidth = .025mm, offset = .1mm, + + xmin = 0, xmax = 20, xstep = .1, + ymin = -2, ymax = 2, + + xticks = "bottom", xsmall = 80, xlarge = 20, xlabels = "nolimits", + yticks = "left", ysmall = 40, ylarge = 4, ylabels = "yes", + + code = "1.5 * math.sind (50 * x - 150)", + + frame = "sticks", % "ticks" + + functions = { + [ + xmin = 1.0, + xmax = 7.0, + close = true, + fillcolor = "MyColorR" + ], + [ + xmin = 7.0, + xmax = 12.0, + close = true, + fillcolor = "MyColorG" + ], + [ + xmin = 12.0, + xmax = 19.0, + close = true, + fillcolor = "MyColorB" + ], + [ + drawcolor = "darkyellow", + drawsize = 2, + ], + [ + xmin = 4, + xmax = 17, + xstep = .25, + drawcolor = "darkmagenta", + shape = "steps", + code = "0.5 * math.random(-2,2)", + ], + [ + xmin = 5.0, + xmax = 15.0, + close = true, + fillcolor = "MyColorY" + code = "1.75 * math.cosd (50 * x - 150)", + ] + }, + ycaption = "\rotate[rotation=90]{\tfd\strut a mix of drawings}", + xcaption = "\framed[foregroundstyle=\tfd]{a mixture of $\sin(x), \cos(x), \sqrt{x}$ etc.}", +] + xsized 8cm +; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +Of course calling the same command multiple times with different code snippets +will also work. + +\startlinecorrection +\getbuffer +\stoplinecorrection + +The previous examples used new code but how about improving existing features? +Let's look at outlines. + +\startbuffer +\startMPcode{doublefun} + save h ; h = 12mm ; + + draw lmt_outline [ + content = "hello" + kind = "draw", + drawcolor = "darkblue", + ] ysized h ; + + draw lmt_outline [ + content = "hello", + kind = "fill", + fillcolor = "darkred", + ] ysized h shifted (3.75h,0) ; + + draw lmt_outline [ + content = "hello", + kind = "both", + fillcolor = "darkred", + ] ysized h shifted (7.5h,0mm) ; + + draw lmt_outline [ + content = "hello", + kind = "both", + fillcolor = "darkred", + drawcolor = "darkblue", + rulethickness = 1/5, + ] ysized h shifted (0,-1.25h) ; + + draw lmt_outline [ + content = "hello", + kind = "reverse", + fillcolor = "darkred", + drawcolor = "darkblue", + rulethickness = 1/2, + ] ysized h shifted (3.75h,-1.25h) ; + + draw lmt_outline [ + content = "hello", + kind = "u", + fillcolor = "darkgreen", + rulethickness = 0, + ] ysized h shifted (7.5h,-1.25h) ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +This interface is much nicer than the one where each variant (the parameter \type +{kind} above) had its own macro due to the need to group properties of the +outline and fill. Let's show some more: + +\startbuffer +\startMPcode{doublefun} + draw lmt_outline [ + content = "\obeydiscretionaries\samplefile{tufte}", + align = "normal", + kind = "draw", + drawcolor = "darkblue", + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +\startbuffer +\startMPcode{doublefun} + draw lmt_outline [ + content = "\obeydiscretionaries\samplefile{ward}", + align = "normal,tolerant", + width = 10cm, + kind = "draw", + drawcolor = "darkblue", + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +\startbuffer +\startMPcode{doublefun} + draw lmt_outline [ + content = "\obeydiscretionaries\samplefile{sapolsky}", + align = "normal,tolerant", + style = "bold", + width = 10cm, + kind = "draw", + rulethickness = 1/5, + drawcolor = "darkred", + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +Another \METAFUN\ text related mechanism deals with following a specific path. +That interface has evolved over time, also due to more advanced possibilities in +\MKIV. But, it's again time for a upgrade, for example: + +\startbuffer +\startMPcode{doublefun} + draw lmt_followtext [ + content = "How well does it work {\bf 1}! ", + path = (fullcircle scaled 4cm), + trace = true, + spread = true, + ] ysized 5cm ; + + draw lmt_followtext [ + content = "How well does it work {\bf 2}! ", + path = fullcircle scaled 4cm, + trace = true, + spread = false, + reverse = true, + ] ysized 5cm shifted (0,-6cm) ; + + draw lmt_followtext [ + content = "How well does it work {\bf 3}! ", + trace = true, + autoscaleup = "yes" + ] ysized 5cm shifted (6cm,0) ; + + draw lmt_followtext [ + content = "How well does it work {\bf 4}! ", + path = fullcircle scaled 2cm, + trace = true, + autoscaleup = "max" + ] ysized 5cm shifted (6cm,-6cm) ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +Although \METAPOST\ can draw arrows a bit more code is involved than one would +have expected. As a consequence, influencing the way an arrowhead is drawn as +currently using variables is somewhat cumbersome. Here is an alternative: + +\startbuffer +\startMPcode{doublefun} + draw lmt_arrow [ + path = fullcircle + scaled 3cm + shifted (0,0cm), + ] withcolor "darkred" ; + + draw lmt_arrow [ + location = "both" + path = fullcircle + scaled 3cm + rotated 90 + shifted (0,-3.5cm), + ] withcolor "darkgreen" ; + + draw lmt_arrow [ + kind = "draw", + location = "middle", + alternative = "curved", + path = fullcircle + scaled 3cm + shifted (3.5cm,0cm), + ] withcolor "darkblue" ; + + for i = 0 step 5 until 100 : + draw lmt_arrow [ + alternative = "dimpled", + location = "percentage", + percentage = i, + dimple = (1/5 + i/200), + headonly = (i = 0), + path = fullcircle + scaled 3cm + shifted (3.5cm,-3.5cm), + ] withcolor "darkyellow" ; + endfor ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +These new interfaces for outlines, following text and arrows certainly will make +it in some form to be permanent \METAFUN\ extensions. Some will also be used in +macros at the \TEX\ end, for instance, when you load the dummy library: + +\startbuffer +\useMPlibrary[dum] +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +You can do this: + +\startbuffer +\startcombination + {\externalfigure[crap-001]} {one} + {\externalfigure[crap-004][alternative=triangle]} {two} +\stopcombination +\stopbuffer + +\typebuffer[option=TEX] + +and get: + +\startlinecorrection +\getbuffer +\stoplinecorrection + +This placeholder now also can be accessed directly: + +\startbuffer +\useMPmacro + [minifun] + [placeholder] + [width=10cm, + height=3cm, + reduction=.2, + alternative=triangle, + color=orange] +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +The \type {\useMPmacro} is an entirely new interface to \METAFUN\ code. Although +it is still experimental, we show an example. Of course, as needed, you can throw +in some \LUA\ magic. + +\startbuffer +\startMPcalculation + presetparameters "demo" [ + n = 5, + s = 1cm, + ] ; + + def lmt_demo = applyparameters "demo" "lmt_do_demo" enddef ; + + vardef lmt_do_demo = + for i=1 upto getparameter "demo" "n" : + draw fullcircle scaled (i*getparameter "demo" "s"); + endfor ; + enddef ; +\stopMPcalculation +\stopbuffer + +\typebuffer[option=TEX] + +The calculation wrapper makes this code be processed immediately, which is needed +because we don't use a module. + +\getbuffer + +A the \TEX\ end we do this: + +\startbuffer +\defineMPparameterset[demo][n=integer,s=dimension] +\stopbuffer + +\typebuffer[option=TEX] + +\getbuffer + +We can now let the macro do its work: + +\startbuffer +\startcombination[nx=4,location=middle] + {\useMPmacro[demo][n=8,s=2mm]} {Demo 1} + {\useMPmacro[demo][n=4,s=4mm]} {Demo 2} + {\useMPmacro[demo][n=4,s=5\exheight]} {Demo 3} + {\useMPmacro[demo]} {Demo 4} +\stopcombination +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +You can also set the parameters separately. There is one catch: there is no +grouping so in this case you need to reset the parameters afterwards. + +\starttyping +\presetMPparameters[demo][n=8] \useMPmacro[demo]\blank +\presetMPparameters[demo][n=4] \useMPmacro[demo]\blank +\resetMPparameters [demo] \useMPmacro[demo]\blank +\stoptyping + +These examples demonstrate that we can make \METAPOST\ a bit friendlier for users +who are not that fluent with the language. It remains to be seen to what extent +additional modules will be written, but the possibilities are there. + +\stopdocument diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 8881418a4..99fd06d2a 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -16234,7 +16234,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 61099, stripped down to: 35798 +-- original size: 61155, stripped down to: 35846 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -16997,8 +16997,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay,data - if resolvers then - okay,data=resolvers.loadbinfile(n) + local loadbinfile=resolvers and resolvers.loadbinfile + if loadbinfile then + okay,data=loadbinfile(n) else data=io.loaddata(n) okay=data and data~="" @@ -25687,8 +25688,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 util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024697 --- stripped bytes : 405774 +-- original bytes : 1024753 +-- stripped bytes : 405782 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 8881418a4..99fd06d2a 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -16234,7 +16234,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 61099, stripped down to: 35798 +-- original size: 61155, stripped down to: 35846 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -16997,8 +16997,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay,data - if resolvers then - okay,data=resolvers.loadbinfile(n) + local loadbinfile=resolvers and resolvers.loadbinfile + if loadbinfile then + okay,data=loadbinfile(n) else data=io.loaddata(n) okay=data and data~="" @@ -25687,8 +25688,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 util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024697 --- stripped bytes : 405774 +-- original bytes : 1024753 +-- stripped bytes : 405782 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 8881418a4..99fd06d2a 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -16234,7 +16234,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 61099, stripped down to: 35798 +-- original size: 61155, stripped down to: 35846 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -16997,8 +16997,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay,data - if resolvers then - okay,data=resolvers.loadbinfile(n) + local loadbinfile=resolvers and resolvers.loadbinfile + if loadbinfile then + okay,data=loadbinfile(n) else data=io.loaddata(n) okay=data and data~="" @@ -25687,8 +25688,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 util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024697 --- stripped bytes : 405774 +-- original bytes : 1024753 +-- stripped bytes : 405782 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 8881418a4..99fd06d2a 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -16234,7 +16234,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 61099, stripped down to: 35798 +-- original size: 61155, stripped down to: 35846 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -16997,8 +16997,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay,data - if resolvers then - okay,data=resolvers.loadbinfile(n) + local loadbinfile=resolvers and resolvers.loadbinfile + if loadbinfile then + okay,data=loadbinfile(n) else data=io.loaddata(n) okay=data and data~="" @@ -25687,8 +25688,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 util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024697 --- stripped bytes : 405774 +-- original bytes : 1024753 +-- stripped bytes : 405782 -- end library merge diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 2ee1c8da4..a7ee56e1e 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.08.11 20:03} +\newcontextversion{2019.08.14 11:26} %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 7ee0869d6..3d0cf4de2 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} %D For those who want to use this: diff --git a/tex/context/base/mkiv/attr-ini.mkiv b/tex/context/base/mkiv/attr-ini.mkiv index 22e3ba259..e4215ff00 100644 --- a/tex/context/base/mkiv/attr-ini.mkiv +++ b/tex/context/base/mkiv/attr-ini.mkiv @@ -57,31 +57,60 @@ \def\attr_basics_define {\attr_basics_define_indeed\s!public} \def\attr_basics_define_system{\attr_basics_define_indeed\s!private} +% todo: define global ! + % here public means 'visible' so it's not to be confused with 'public' at the lua end +% \def\attr_basics_define_indeed#1[#2][#3]% +% {\ifcsname\??attributecount#2\endcsname\else +% \scratchcounter\clf_defineattribute{#2}{#1}\relax +% %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}% +% \expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter +% \expandafter\newconstant \csname\??attributeid#2\endcsname +% \csname\??attributeid#2\endcsname\scratchcounter +% % some attributes are always global +% \doifelseinset\s!global{#3}% +% {\etoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% \doifinset\s!nomath{#3}% +% {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% +% \doifinset\s!public{#3}% +% {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% +% \doifinset\s!pickup{#3}% +% {\expandafter\newconstant\csname\??attributepickup#2\endcsname +% \csname\??attributepickup#2\endcsname\attributeunsetvalue +% \etoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% +% \ifcsname#2\s!attribute\endcsname +% \expandafter\edef\csname\s!pickup#2\s!attribute\endcsname +% {\csname\??attributepickup#2\endcsname\csname\??attributecount#2\endcsname}% +% \expandafter\edef\csname\s!forget#2\s!attribute\endcsname +% {\csname\??attributepickup#2\endcsname\attributeunsetvalue}% +% \fi}% +% \fi} + \def\attr_basics_define_indeed#1[#2][#3]% {\ifcsname\??attributecount#2\endcsname\else \scratchcounter\clf_defineattribute{#2}{#1}\relax %\writestatus\m!system{defining #1 attribute #2 with number \number\scratchcounter}% - \expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter - \expandafter\newconstant \csname\??attributeid#2\endcsname - \csname\??attributeid#2\endcsname\scratchcounter + \global\expandafter\attributedef\csname\??attributecount#2\endcsname\scratchcounter + \global\expandafter\newconstant \csname\??attributeid#2\endcsname + \global\csname\??attributeid#2\endcsname\scratchcounter % some attributes are always global \doifelseinset\s!global{#3}% - {\etoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% - {\etoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_global{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_local {\csname\??attributecount#2\endcsname\attributeunsetvalue}}% \doifinset\s!nomath{#3}% - {\etoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% + {\xtoksapp\t_attr_list_nomath{\csname\??attributecount#2\endcsname\attributeunsetvalue}}% \doifinset\s!public{#3}% - {\expandafter\let\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% + {\expandafter\glet\csname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% \doifinset\s!pickup{#3}% - {\expandafter\newconstant\csname\??attributepickup#2\endcsname - \csname\??attributepickup#2\endcsname\attributeunsetvalue - \etoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% + {\global\expandafter\newconstant\csname\??attributepickup#2\endcsname + \global\csname\??attributepickup#2\endcsname\attributeunsetvalue + \xtoksapp\t_attr_list_pickup{\csname\??attributecount#2\endcsname\csname\??attributepickup#2\endcsname}% \ifcsname#2\s!attribute\endcsname - \expandafter\edef\csname\s!pickup#2\s!attribute\endcsname + \expandafter\xdef\csname\s!pickup#2\s!attribute\endcsname {\csname\??attributepickup#2\endcsname\csname\??attributecount#2\endcsname}% - \expandafter\edef\csname\s!forget#2\s!attribute\endcsname + \expandafter\xdef\csname\s!forget#2\s!attribute\endcsname {\csname\??attributepickup#2\endcsname\attributeunsetvalue}% \fi}% \fi} @@ -95,9 +124,13 @@ % \unexpanded\def\pickupattributelater#1% % {\csname\??attributepickup#1\endcsname\csname\??attributecount#1\endcsname} +% \unexpanded\def\newattribute#1% +% {\attr_basics_define_indeed\s!public[\csstring#1][]% +% \expandafter\let\expandafter#1\csname\??attributeid\csstring#1\endcsname} + \unexpanded\def\newattribute#1% {\attr_basics_define_indeed\s!public[\csstring#1][]% - \expandafter\let\expandafter#1\csname\??attributeid\csstring#1\endcsname} + \expandafter\glet\expandafter#1\csname\??attributeid\csstring#1\endcsname} % expandable so we can \edef them for speed diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 11d81d603..99f1c2d9c 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{2019.08.11 20:03} +\newcontextversion{2019.08.14 11:26} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index bb8a89065..8694533e8 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{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index f7ea6ad6a..d6aaa9b2c 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.11 20:03} +\edef\contextversion{2019.08.14 11:26} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index a779cd50c..3ade1c92b 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -984,8 +984,9 @@ end local function entityfile(pattern,k,v,n) if n then local okay, data - if resolvers then - okay, data = resolvers.loadbinfile(n) + local loadbinfile = resolvers and resolvers.loadbinfile + if loadbinfile then + okay, data = loadbinfile(n) else data = io.loaddata(n) okay = data and data ~= "" diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua index 45db8807a..e116a2cdc 100644 --- a/tex/context/base/mkiv/node-aux.lua +++ b/tex/context/base/mkiv/node-aux.lua @@ -21,6 +21,7 @@ local glyph_code = nodecodes.glyph local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local attributelist_code = nodecodes.attributelist -- temporary +local localpar_code = nodecodes.localpar local nuts = nodes.nuts local tonut = nuts.tonut @@ -34,6 +35,7 @@ local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getattr = nuts.getattr local getboth = nuts.getboth +local getprev = nuts.getprev local getcomponents = nuts.getcomponents local getwidth = nuts.getwidth local setwidth = nuts.setwidth @@ -49,8 +51,6 @@ local setprev = nuts.setprev local setcomponents = nuts.setcomponents local setattrlist = nuts.setattrlist ------ traverse_nodes = nuts.traverse ------ traverse_id = nuts.traverse_id local nextnode = nuts.traversers.node local nextglyph = nuts.traversers.glyph local flush_node = nuts.flush @@ -59,7 +59,6 @@ local hpack_nodes = nuts.hpack local unset_attribute = nuts.unset_attribute local first_glyph = nuts.first_glyph local copy_node = nuts.copy ------ copy_node_list = nuts.copy_list local find_tail = nuts.tail local getbox = nuts.getbox local count = nuts.count @@ -73,6 +72,7 @@ local unsetvalue = attributes.unsetvalue local current_font = font.current local texsetbox = tex.setbox +local texnest = tex.nest local report_error = logs.reporter("node-aux:error") @@ -472,3 +472,14 @@ end -- end -- end -- end + +function nuts.setparproperty(action,...) + local tail = tonut(texnest[texnest.ptr].tail) + while tail do + if getid(tail) == localpar_code then + return action(tail,...) + else + tail = getprev(tail) + end + end +end diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index d60727eee..158f74a98 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -774,14 +774,22 @@ end nuts.getprop = function(n,k) local p = propertydata[n] if p then - return p[k] + if k then + return p[k] + else + return p + end end end nuts.rawprop = function(n,k) local p = rawget(propertydata,n) if p then - return p[k] + if k then + return p[k] + else + return p + end end end diff --git a/tex/context/base/mkiv/page-one.mkiv b/tex/context/base/mkiv/page-one.mkiv index 9572b3769..dc157fbeb 100644 --- a/tex/context/base/mkiv/page-one.mkiv +++ b/tex/context/base/mkiv/page-one.mkiv @@ -445,7 +445,13 @@ \fi % should be an option \endgroup - \scratchdimenone\dimexpr\pagetotal+\floatheight+\d_strc_floats_top-\pageshrink\relax + \scratchdimenone\dimexpr + \pagetotal + +\floatheight + +\d_strc_floats_top + +\d_strc_floats_overflow + -\pageshrink + \relax \scratchdimentwo\pagegoal \relax % needed \ifcase\c_page_one_float_method diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 1cac838de..3aeda1ce0 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index cc2cf3f29..dd252229f 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/strc-flt.mkvi b/tex/context/base/mkiv/strc-flt.mkvi index 5572a3c6f..584cf915f 100644 --- a/tex/context/base/mkiv/strc-flt.mkvi +++ b/tex/context/base/mkiv/strc-flt.mkvi @@ -899,6 +899,7 @@ \newdimen\d_strc_floats_top \newdimen\d_strc_floats_bottom +\newdimen\d_strc_floats_overflow % \def\strc_floats_calculate_skip#target#skip% % {\begingroup @@ -947,6 +948,7 @@ \global\c_page_one_float_method \floatparameter\c!textmethod \global\c_page_floats_n_of_top \rootfloatparameter\c!ntop \global\c_page_floats_n_of_bottom\rootfloatparameter\c!nbottom + \global\d_strc_floats_overflow \zeropoint \ifconditional\c_strc_floats_par_float \global\d_strc_floats_top \zeropoint \global\d_strc_floats_bottom \zeropoint @@ -1642,7 +1644,6 @@ \fi\fi \strc_floats_align_content{\copy\b_strc_floats_content}}} - \def\strc_floats_prepare_page_caption {\edef\p_strc_floats_caption_width {\floatcaptionparameter\c!width}% \edef\p_strc_floats_caption_minwidth{\floatcaptionparameter\c!minwidth}% @@ -1819,7 +1820,7 @@ {\strc_floats_align_content{\box\b_strc_floats_content}} \def\strc_floats_build_box_next_right#1% - {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi % skip, no pack + {\ifconditional\c_strc_floats_par_float \hpack \else \expandafter \strc_floats_align_content \fi % skip, no pack {\d_strc_float_temp_height\ht\b_strc_floats_content \box\b_strc_floats_content \doifnotinset\v!hang\floatcaptionlocation @@ -1827,7 +1828,7 @@ \vbox to\d_strc_float_temp_height{#1}}} \def\strc_floats_build_box_next_left#1% - {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi % skip, no pack + {\ifconditional\c_strc_floats_par_float \hpack \else \expandafter \strc_floats_align_content \fi % skip, no pack {\d_strc_float_temp_height\ht\b_strc_floats_content \vbox to\d_strc_float_temp_height{#1}% \doifnotinset\v!hang\floatcaptionlocation @@ -1852,6 +1853,36 @@ \vbox to\d_strc_float_temp_height{#1}% \box\b_strc_floats_content}} +% \def\strc_floats_build_box_next_right_margin_indeed#1#2% +% {\ifconditional\c_strc_floats_par_float +% \hpack\bgroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \box\b_strc_floats_content +% \hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}% +% \egroup +% \else +% \begingroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \everyrightofalignedline{\hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}}% +% \strc_floats_align_content{\box\b_strc_floats_content}% +% \endgroup +% \fi} +% +% \def\strc_floats_build_box_next_left_margin_indeed#1#2% +% {\ifconditional\c_strc_floats_par_float +% \hpack\bgroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}% +% \box\b_strc_floats_content +% \egroup +% \else +% \begingroup +% \d_strc_float_temp_height\ht\b_strc_floats_content +% \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}}% +% \strc_floats_align_content{\box\b_strc_floats_content}% +% \endgroup +% \fi} + \def\strc_floats_build_box_next_right_margin_indeed#1#2% {\ifconditional\c_strc_floats_par_float \hpack\bgroup @@ -1862,7 +1893,12 @@ \else \begingroup \d_strc_float_temp_height\ht\b_strc_floats_content - \everyrightofalignedline{\hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}}% + \setbox\scratchboxone\vbox{#2}% + \ifdim\htdp\scratchboxone>\htdp\b_strc_floats_content + \global\d_strc_floats_overflow\dimexpr\htdp\scratchboxone-\htdp\b_strc_floats_content\relax + \fi + \ht\scratchboxone\d_strc_float_temp_height + \everyrightofalignedline{\hsmash{\hskip#1\box\scratchboxone}}% \strc_floats_align_content{\box\b_strc_floats_content}% \endgroup \fi} @@ -1877,7 +1913,12 @@ \else \begingroup \d_strc_float_temp_height\ht\b_strc_floats_content - \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}}% + \setbox\scratchboxone\vbox{#2}% + \ifdim\htdp\scratchboxone>\htdp\b_strc_floats_content + \global\d_strc_floats_overflow\dimexpr\htdp\scratchboxone-\htdp\b_strc_floats_content\relax + \fi + \ht\scratchboxone\d_strc_float_temp_height + \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\scratchboxone\relax\box\scratchboxone}}% \strc_floats_align_content{\box\b_strc_floats_content}% \endgroup \fi} diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua index 6ac59d00c..2f51e5dc0 100644 --- a/tex/context/base/mkiv/typo-drp.lua +++ b/tex/context/base/mkiv/typo-drp.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['typo-drp'] = { license = "see context related readme files" } --- This ons is sensitive for order (e.g. when combined with first line +-- This one is sensitive for order (e.g. when combined with first line -- processing. -- todo: use isglyph @@ -28,6 +28,7 @@ local enableaction = tasks.enableaction local disableaction = tasks.disableaction local nuts = nodes.nuts +local tonut = nodes.tonut local getnext = nuts.getnext local getprev = nuts.getprev @@ -36,6 +37,9 @@ local getid = nuts.getid local getattr = nuts.getattr local getwhd = nuts.getwhd +local getprop = nuts.getprop +local setprop = nuts.setprop + local setattr = nuts.setattr local setlink = nuts.setlink local setprev = nuts.setprev @@ -46,6 +50,7 @@ local setwhd = nuts.setwhd local setkern = nuts.setkern local setoffsets = nuts.setoffsets local setglyphdata = nuts.setglyphdata +local setattr = nuts.setattr local hpack_nodes = nuts.hpack @@ -70,7 +75,6 @@ local v_last = variables.last local texget = tex.get local texset = tex.set -local texsetattribute = tex.setattribute local unsetvalue = attributes.unsetvalue local glyph_code = nodecodes.glyph @@ -89,16 +93,16 @@ local a_colormodel = attributes.private('colormodel') local category = characters.category -local settings = nil - -function initials.set(specification) - settings = specification or { } - settings.enabled = true +local function set(par,specification) enableaction("processors","typesetters.initials.handler") if trace_initials then report_initials("enabling initials") end - texsetattribute(a_initial,1) + setprop(par,a_initial,specification) +end + +function initials.set(specification) + nuts.setparproperty(set,specification) end interfaces.implement { @@ -123,256 +127,224 @@ interfaces.implement { } } --- dropped caps experiment (will be done properly when luatex --- stores the state in the local par node) .. btw, search still --- works with dropped caps, as does an export - --- we need a 'par' attribute and in fact for dropped caps we don't need --- need an attribute ... dropit will become s state counter (or end up --- in the localpar user data - --- for the moment, each paragraph gets a number as id (attribute) ..problem --- with nesting .. or anyhow, needed for tagging anyway - -- todo: prevent linebreak .. but normally a initial ends up at the top of -- a page so this has a low priority actions[v_default] = function(head,setting) - local id = getid(head) - if id == localpar_code then -- and getsubtype(head) == 0 - -- begin of par - local first = getnext(head) - local indent = false - -- parbox .. needs to be set at 0 - if first and getid(first) == hlist_code then - first = getnext(first) - indent = true - end - -- we need to skip over kerns and glues (signals) - while first and getid(first) ~= glyph_code do - first = getnext(first) - end - if first and getid(first) == glyph_code then - local ma = setting.ma or 0 - local ca = setting.ca - local ta = setting.ta - local last = first - local distance = setting.distance or 0 - local voffset = setting.voffset or 0 - local hoffset = setting.hoffset or 0 - local parindent = texget("parindent") - local baseline = texget("baselineskip",false) - local lines = tonumber(setting.n) or 0 - local dynamic = setting.dynamic - local font = setting.font - local method = settings_to_hash(setting.method) - local length = tonumber(setting.m) or 1 - -- - -- 1 char | n chars | skip first quote | ignore punct | keep punct - -- - if getattr(first,a_initial) then - for current in nextnode, getnext(first) do - if getattr(current,a_initial) then - last = current - else - break - end - end - elseif method[v_auto] then - local char = getchar(first) - local kind = category(char) - if kind == "po" or kind == "pi" then - if method[v_first] then - -- remove quote etc before initial - local next = getnext(first) - if not next then - -- don't start with a quote or so - return head - end - last = nil - for current in nextglyph, next do - head, first = remove_node(head,first,true) - first = current - last = first - break - end - if not last then - -- no following glyph or so - return head - end - else - -- keep quote etc with initial - local next = getnext(first) - if not next then - -- don't start with a quote or so - return head - end - for current in nextglyph, next do - last = current - break - end - if last == first then - return head - end - end - elseif kind == "pf" then - -- error: final quote + -- begin of par + local first = getnext(head) + local indent = false + -- parbox .. needs to be set at 0 + if first and getid(first) == hlist_code then + first = getnext(first) + indent = true + end + -- we need to skip over kerns and glues (signals) + while first and getid(first) ~= glyph_code do + first = getnext(first) + end + if first and getid(first) == glyph_code then + local ma = setting.ma or 0 + local ca = setting.ca + local ta = setting.ta + local last = first + local distance = setting.distance or 0 + local voffset = setting.voffset or 0 + local hoffset = setting.hoffset or 0 + local parindent = texget("parindent") + local baseline = texget("baselineskip",false) + local lines = tonumber(setting.n) or 0 + local dynamic = setting.dynamic + local font = setting.font + local method = settings_to_hash(setting.method) + local length = tonumber(setting.m) or 1 + -- + -- 1 char | n chars | skip first quote | ignore punct | keep punct + -- + if getattr(first,a_initial) then + for current in nextnode, getnext(first) do + if getattr(current,a_initial) then + last = current else - -- okay + break end - -- maybe also: get all A. B. etc - local next = getnext(first) - if next then - for current, char in nextglyph, next do - local kind = category(char) - if kind == "po" then - if method[v_last] then - -- remove period etc after initial - remove_node(head,current,true) - else - -- keep period etc with initial - last = current - end - end - break + end + elseif method[v_auto] then + local char = getchar(first) + local kind = category(char) + if kind == "po" or kind == "pi" then + if method[v_first] then + -- remove quote etc before initial + local next = getnext(first) + if not next then + -- don't start with a quote or so + return head end - end - else - for current in nextglyph, first do - last = current - if length <= 1 then + last = nil + for current in nextglyph, next do + head, first = remove_node(head,first,true) + first = current + last = first break - else - length = length - 1 end - end - end - local current = first - while true do - local id = getid(current) - if id == kern_code then - setkern(current,0) - elseif id == glyph_code then - local next = getnext(current) - if font then - setfont(current,font) + if not last then + -- no following glyph or so + return head end - if dynamic > 0 then - setglyphdata(current,dynamic) + else + -- keep quote etc with initial + local next = getnext(first) + if not next then + -- don't start with a quote or so + return head end --- apply font - --- local g = nuts.copy(current) --- g.subtype = 0 --- nodes.handlers.characters(g) --- nodes.handlers.protectglyphs(g) --- setchar(current,g.char) --- nuts.flush_node(g) - - -- can be a helper - if ca and ca > 0 then - setattr(current,a_colormodel,ma == 0 and 1 or ma) - setattr(current,a_color,ca) + for current in nextglyph, next do + last = current + break end - if ta and ta > 0 then - setattr(current,a_transparency,ta) + if last == first then + return head end - -- - end - if current == last then - break - else - current = getnext(current) end + elseif kind == "pf" then + -- error: final quote + else + -- okay end - -- We pack so that successive handling cannot touch the dropped cap. Packaging - -- in a hlist is also needed because we cannot locally adapt e.g. parindent (not - -- yet stored in with localpar). - local prev = getprev(first) - local next = getnext(last) - -- - setprev(first) - setnext(last) - local dropper = hpack_nodes(first) - local width, height, depth = getwhd(dropper) - setwhd(dropper,0,0,0) - -- - setlink(prev,dropper) - setlink(dropper,next) - -- + -- maybe also: get all A. B. etc + local next = getnext(first) if next then - local current = next - while current do - local id = getid(current) - if id == glue_code or id == kern_code then - local next = getnext(current) - -- remove_node(current,current,true) -- created an invalid next link and dangling remains - remove_node(head,current,true) - current = next - else - break + for current, char in nextglyph, next do + local kind = category(char) + if kind == "po" then + if method[v_last] then + -- remove period etc after initial + remove_node(head,current,true) + else + -- keep period etc with initial + last = current + end end + break end end - -- - local hoffset = width + hoffset + distance + (indent and parindent or 0) + else for current in nextglyph, first do - setoffsets(current,-hoffset,-voffset) -- no longer - height here - if current == last then + last = current + if length <= 1 then break + else + length = length - 1 end end - -- - first = dropper - -- - if setting.location == v_margin then - -- okay - else - if lines == 0 then -- safeguard, not too precise - lines = ceil((height+voffset) / baseline) + end + local current = first + while true do + local id = getid(current) + if id == kern_code then + setkern(current,0) + elseif id == glyph_code then + local next = getnext(current) + if font then + setfont(current,font) end - -- We cannot set parshape yet ... when we can I'll add a slope - -- option (positive and negative, in emwidth). - local hangafter = - lines - local hangindent = width + distance - if trace_initials then - report_initials("setting hangafter to %i and hangindent to %p",hangafter,hangindent) + if dynamic > 0 then + setglyphdata(current,dynamic) end - texset("hangafter",hangafter) - texset("hangindent",hangindent) + -- can be a helper + if ca and ca > 0 then + setattr(current,a_colormodel,ma == 0 and 1 or ma) + setattr(current,a_color,ca) + end + if ta and ta > 0 then + setattr(current,a_transparency,ta) + end + -- end - if indent then - insert_after(first,first,new_kern(-parindent)) + if current == last then + break + else + current = getnext(current) end end + -- We pack so that successive handling cannot touch the dropped cap. Packaging + -- in a hlist is also needed because we cannot locally adapt e.g. parindent (not + -- yet stored in with localpar). + local prev = getprev(first) + local next = getnext(last) + -- + setprev(first) + setnext(last) + local dropper = hpack_nodes(first) + local width, height, depth = getwhd(dropper) + setwhd(dropper,0,0,0) + -- + setlink(prev,dropper) + setlink(dropper,next) + -- + if next then + local current = next + while current do + local id = getid(current) + if id == glue_code or id == kern_code then + local next = getnext(current) + -- remove_node(current,current,true) -- created an invalid next link and dangling remains + remove_node(head,current,true) + current = next + else + break + end + end + end + -- + local hoffset = width + hoffset + distance + (indent and parindent or 0) + for current in nextglyph, first do + setoffsets(current,-hoffset,-voffset) -- no longer - height here + if current == last then + break + end + end + -- + first = dropper + -- + if setting.location == v_margin then + -- okay + else + if lines == 0 then -- safeguard, not too precise + lines = ceil((height+voffset) / baseline) + end + -- We cannot set parshape yet ... when we can I'll add a slope + -- option (positive and negative, in emwidth). + local hangafter = - lines + local hangindent = width + distance + if trace_initials then + report_initials("setting hangafter to %i and hangindent to %p",hangafter,hangindent) + end + texset("hangafter",hangafter) + texset("hangindent",hangindent) + end + if indent then + insert_after(first,first,new_kern(-parindent)) + end end return head end +-- we can count ... when all done, we can disable ... + function initials.handler(head) - local start = head - local attr = nil - while start do - attr = getattr(start,a_initial) - if attr then - break - elseif getid(start) == glyph then - break - else - start = getnext(start) - end - end - if attr then - -- here as we can process nested boxes first so we need to keep state - disableaction("processors","typesetters.initials.handler") - -- texsetattribute(attribute,unsetvalue) - local alternative = settings.alternative or v_default - local action = actions[alternative] or actions[v_default] - if action then - if trace_initials then - report_initials("processing initials, alternative %a",alternative) + if getid(head) == localpar_code then + local settings = getprop(head,a_initial) + if settings then + disableaction("processors","typesetters.initials.handler") + local alternative = settings.alternative or v_default + local action = actions[alternative] or actions[v_default] + if action then + if trace_initials then + report_initials("processing initials, alternative %a",alternative) + end + return action(head,settings) end - return action(head,settings) end end return head diff --git a/tex/context/base/mkiv/typo-drp.mkiv b/tex/context/base/mkiv/typo-drp.mkiv index 917b4255b..25b006b2f 100644 --- a/tex/context/base/mkiv/typo-drp.mkiv +++ b/tex/context/base/mkiv/typo-drp.mkiv @@ -88,25 +88,22 @@ \begingroup \edef\currentinitial{#1}% \setupcurrentinitial[#2]% - \scratchcounter \initialparameter\c!n\relax - \scratchdistance\initialparameter\c!distance\relax - \scratchhoffset \initialparameter\c!hoffset \relax - \edef\p_voffset{\initialparameter\c!voffset}% - \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax \resetfontfeature % might be needed in more places \doifelsenothing{\initialparameter\c!style} {\definedfont[\initialparameter\s!font]} {\useinitialstyleparameter\c!style}% \useinitialcolorparameter\c!color - \edef\p_text{\initialparameter\c!text}% optional + \edef\p_voffset{\initialparameter\c!voffset}% + \scratchcounter \initialparameter\c!n\relax + \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax \clf_setinitial location {\initialparameter\c!location}% enabled true\space n \scratchcounter m \numexpr\initialparameter\c!m\relax method {\initialparameter\c!method}% - distance \scratchdistance - hoffset \scratchhoffset + distance \dimexpr\initialparameter\c!distance\relax + hoffset \dimexpr\initialparameter\c!hoffset\relax voffset \scratchvoffset ma \attribute\colormodelattribute ca \attribute\colorattribute @@ -114,9 +111,8 @@ font \fontid\font dynamic \font_dynamic_value % it's a bit over the top to support this here \relax - \stopluacode - \kern\zeropoint % we need a node - \p_text + \attribute\initialattribute\plusone + \initialparameter\c!text \endgroup \glet\typo_initial_handle\relax} diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua index 7ed70296f..3124e80c7 100644 --- a/tex/context/base/mkiv/typo-fln.lua +++ b/tex/context/base/mkiv/typo-fln.lua @@ -48,12 +48,15 @@ local setdisc = nuts.setdisc local setlink = nuts.setlink local setfont = nuts.setfont local setglyphdata = nuts.setglyphdata +local getprop = nuts.getprop +local setprop = nuts.setprop local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local kern_code = nodecodes.kern local glue_code = nodecodes.glue +local localpar_code = nodecodes.localpar local spaceskip_code = nodes.gluecodes.spaceskip @@ -84,26 +87,21 @@ local a_colormodel = attributes.private('colormodel') local texget = tex.get -local texsetattribute = tex.setattribute -local unsetvalue = attributes.unsetvalue - local variables = interfaces.variables local v_default = variables.default local v_line = variables.line local v_word = variables.word ------ is_letter = characters.is_letter ------ categories = characters.categories - -local settings = nil - -function firstlines.set(specification) - settings = specification or { } +local function set(par,specification) enableaction("processors","typesetters.firstlines.handler") if trace_firstlines then report_firstlines("enabling firstlines") end - texsetattribute(a_firstline,1) + setprop(par,a_firstline,specification) +end + +function firstlines.set(specification) + nuts.setparproperty(set,specification) end implement { @@ -123,7 +121,6 @@ implement { } actions[v_line] = function(head,setting) - -- local attribute = fonts.specifiers.contextnumber(setting.feature) -- was experimental local dynamic = setting.dynamic local font = setting.font local noflines = setting.n or 1 @@ -372,29 +369,18 @@ end actions[v_default] = actions[v_line] function firstlines.handler(head) - local start = head - local attr = nil - while start do - attr = getattr(start,a_firstline) - if attr then - break - elseif getid(start) == glyph_code then - break - else - start = getnext(start) - end - end - if attr then - -- here as we can process nested boxes first so we need to keep state - disableaction("processors","typesetters.firstlines.handler") - -- texsetattribute(attribute,unsetvalue) - local alternative = settings.alternative or v_default - local action = actions[alternative] or actions[v_default] - if action then - if trace_firstlines then - report_firstlines("processing firstlines, alternative %a",alternative) + if getid(head) == localpar_code then + local settings = getprop(head,a_firstline) + if settings then + disableaction("processors","typesetters.firstlines.handler") + local alternative = settings.alternative or v_default + local action = actions[alternative] or actions[v_default] + if action then + if trace_firstlines then + report_firstlines("processing firstlines, alternative %a",alternative) + end + return action(head,settings) end - return action(head,settings) end end return head diff --git a/tex/context/base/mkiv/typo-fln.mkiv b/tex/context/base/mkiv/typo-fln.mkiv index bcf67af9b..6cca39f91 100644 --- a/tex/context/base/mkiv/typo-fln.mkiv +++ b/tex/context/base/mkiv/typo-fln.mkiv @@ -88,7 +88,7 @@ font \fontid\font dynamic \font_dynamic_value \relax - \kern\zeropoint % we need a node +% \kern\zeropoint % we need a node % \hskip\zeropoint\s!plus\emwidth\relax % can be an option \endgroup \glet\typo_firstline_handle\relax} diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 0060c1245..9c6b51114 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index bac5181ea..6176d9f3a 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 3120f4513..e64be4310 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 : 08/11/19 20:03:46 +-- merge date : 08/14/19 11:26:57 do -- begin closure to overcome local limits and interference -- cgit v1.2.3