diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-02-20 17:14:42 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-02-20 17:14:42 +0100 |
commit | bc35fdf25e8326c543ea69622d804e211232214a (patch) | |
tree | 7a09df00f6373796a3ccfc87824ecc5e9fb13f76 | |
parent | 1a846ce732270ab6ef770939d4858ccda592b9a0 (diff) | |
download | context-bc35fdf25e8326c543ea69622d804e211232214a.tar.gz |
2021-02-20 16:49:00
23 files changed, 163 insertions, 42 deletions
diff --git a/doc/context/documents/general/manuals/luametafun.pdf b/doc/context/documents/general/manuals/luametafun.pdf Binary files differindex fa15b985d..f1ef790dc 100644 --- a/doc/context/documents/general/manuals/luametafun.pdf +++ b/doc/context/documents/general/manuals/luametafun.pdf diff --git a/doc/context/documents/general/manuals/luametatex.pdf b/doc/context/documents/general/manuals/luametatex.pdf Binary files differindex d05bffdfd..5c2e3aea1 100644 --- a/doc/context/documents/general/manuals/luametatex.pdf +++ b/doc/context/documents/general/manuals/luametatex.pdf diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex b/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex index 72c9528e8..a2c4636ed 100644 --- a/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex +++ b/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex @@ -34,10 +34,10 @@ draw lmt_arrow [ \startbuffer[1c] \startMPcode draw lmt_arrow [ - path = (fullcircle scaled 3cm rotated 45), - pen = (pencircle xscaled 2mm yscaled 1mm rotated 45), + path = (fullcircle scaled 3cm rotated 145), + pen = (pencircle xscaled 4mm yscaled 2mm rotated 45), ] - withpen pencircle xscaled 2mm yscaled 1mm rotated 45 + withpen pencircle xscaled 1mm yscaled .5mm rotated 45 withcolor "darkblue" ; \stopMPcode \stopbuffer diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-technology.tex b/doc/context/sources/general/manuals/luametafun/luametafun-technology.tex new file mode 100644 index 000000000..910a9dd60 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-technology.tex @@ -0,0 +1,89 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-technology + +\startchapter[title={Technology}] + +The \METAPOST\ library that we use in \LUAMETATEX\ is a follow up on the library +used in \LUATEX\ which itself is a follow up on the original \METAPOST\ program +that again was a follow up on Don Knuths \METAFONT, the natural companion to +\TEX. + +When we start with John Hobbies \METAPOST\ we see a graphical engine that +provides a simple but powerful programming language meant for making graphics, +not the freehand kind, but the more systematic ones. The output is \POSTSCRIPT\ +but a simple kind that can easily be converted to \PDF. \footnote {For that +purpose I wrote a converter in the \TEX\ language for \PDFTEX, and even within +the limitations of \TEX\ at that time (fonts, number of registers, memory) it +worked out quite well.} It's output is very accurate and performance is great. + +As part of the \LUATEX\ development project Taco Hoekwater turned \METAPOST\ into +\MPLIB, a downward compatible library where \METAPOST\ became a small program +using that library. But there is more: there are (when enabled) backends that +produce \PNG\ or \SVG, but when used these also add dependencies on moving +targets. The library by default uses the so called scaled numbers: floats that +internally are long integers. But it can also work in doubles, decimal and binary +and especially the last two create a dependency on libraries. It is good to +notice that as in the original \METAPOST\ the \POSTSCRIPT\ output handling is +visible all over the source. Also, the way \TYPEONE\ fonts are handled has been +extended, for instance by providing access to shapes. + +At some point a \LUA\ interface got added that made it possible to call out to +the \LUA\ instance used in \LUATEX, so the three concepts: \TEX, \METAPOST\ and +\LUA\ can combine forces. A snippet of code can be run, and a result can be piped +back. Although there is some limited access to \METAPOST\ internals, the normal +way to go is by serializing \METAPOST\ data to the \LUA\ end and let \METAPOST\ +scan the result using \type {scantokens}. + +The library in \LUAMETATEX\ is a bit different. Of course it has the same core +graphic engine, but there is no longer a backend. In \CONTEXT\ \MKIV\ the +\POSTSCRIPT\ (and other) backends were not used anyway because it operates on the +exported \LUA\ representation of the result. Combined with the \type {prescript} +and \type {postscript} features introduced in the library that provides all we +need to make interesting extensions to the graphical engine (color, shading, +image inclusion, text, etc). The \METAPOST\ font support features are also not +used because we need support for \OPENTYPE\ and even in \MKII\ (for \PDFTEX\ and +\XETEX) we used a different approach to fonts. + +It is for that reason that the library we use in \LUAMETATEX\ is a leaner version +of its ancestor. As mentioned, there is no backend code, only the \LUA\ export, +which saves a lot, and there are no traces of font support left, which also drops +many lines of code. We forget about the binary number model because it needs a +large library that also occasionally changes, but one can add it if needed. This +means that there are no dependencies except for decimal but that library is +relatively small and doesn't change at all. It also means that the resulting +\MPLIB\ library is much smaller, but it's still a substantial component in +\LUAMETATEX. Internally I use the future version number 3. The original +\METAPOST\ program is version 1, so the library got version 2, and that one +basically being frozen (it's in bug|-|fix mode) means that it will stick to that. + +Another difference is that from the \LUA\ end one has access to several scanners +and also has possibilities to efficiently push back results to the engine. +Running scripts can also be done more efficient. This permits a rather efficient +(in terms of performance and memory usage) way to extend the language and add for +instance key|/|value based interfaces. There are some more additions, like for +instance pre- and postscripts to clip, boundary and group objects. Internals can +be numeric, string and boolean. One can use \UTF\ input although that has also be +added to the ancestor. Some redundant internal input|/|output remapping has been +removed and we are more tolerant to newlines in return values from \LUA. Error +messages have been normalized, internal documentation cleaned up a bit. A few +anomalies have been fixed too. All in- and output is now under \LUA\ control. +Etcetera. The (now very few) source files are still \CWEB\ files but the +conversion to \CCODE\ is done with a \LUA\ script that uses (surprise) the +\LUAMETATEX\ engine as \LUA\ processor. This give a bit nicer \CCODE\ output for +when we view it in e.g.\ Visual Studio too (normally the \CWEB\ output is not +meant to be seen by humans). + +Keep in mind that it's still \METAPOST\ with all it provided, but some has to be +implemented in macros or in \LUA\ via callbacks. The simple fact that the +original library is the standard and is also the core of \METAPOST\ most of these +changes and additions cannot be backported to the original, but that is no big +deal. The advantage is that we can experiment with new features without +endangering users outside the \CONTEXT\ bubble. The same is true for the \LUA\ +interface, which already is upgraded in many aspects. + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun.tex b/doc/context/sources/general/manuals/luametafun/luametafun.tex index a75e3d541..f8ca97ada 100644 --- a/doc/context/sources/general/manuals/luametafun/luametafun.tex +++ b/doc/context/sources/general/manuals/luametafun/luametafun.tex @@ -12,6 +12,7 @@ \stopfrontmatter \startbodymatter + \component luametafun-technology \component luametafun-text % \component luametafun-grid \component luametafun-axis diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex b/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex index e8e0dff15..77c2d93d8 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex @@ -713,8 +713,8 @@ In so called base mode, where \TEX\ does the work, the ligature construction \type {ff} ligatures and that one followed by an \type {i} can become a \type {ffi} ligature. The situation can be complicated by hyphenation points between these characters. When there are several in a ligature collapsing happens. Flag -{\tttf "\uchexnumbers {\lazyligatureshyphenationmodecode} in the \lpr -{\hyphenationmode} variable determines if this happens lazy or greedy, i.e.\ the +{\tttf "\uchexnumbers {\lazyligatureshyphenationmodecode}} in the \lpr +{hyphenationmode} variable determines if this happens lazy or greedy, i.e.\ the first hyphen wins or the last one does. In practice a \CONTEXT\ user won't have to deal with this because most fonts are processed in node mode. diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl index 93791e7c5..3a6028954 100644 --- a/metapost/context/base/mpxl/mp-lmtx.mpxl +++ b/metapost/context/base/mpxl/mp-lmtx.mpxl @@ -393,11 +393,11 @@ vardef lmt_do_arrow = save l ; string l ; l := getparameter "location" ; save k ; string k ; k := getparameter "kind" ; save p ; path p ; p := getparameter "path" ; - save ahvariant ; ahvariant := if a = "dimpled" : 1 elseif a = "curved" : 2 else : 0 fi ; - save ahdimple ; ahdimple := getparameter "dimple" ; - save ahscale ; ahscale := getparameter "scale" ; - save ahangle ; ahangle := getparameter "angle" ; - save ahlength ; ahlength := getparameter "length" ; + interim ahvariant := if a = "dimpled" : 1 elseif a = "curved" : 2 else : 0 fi ; + interim ahdimple := getparameter "dimple" ; + interim ahscale := getparameter "scale" ; + interim ahangle := getparameter "angle" ; + interim ahlength := getparameter "length" ; if not getparameter "headonly" : draw p ; fi ; diff --git a/metapost/context/base/mpxl/mp-luas.mpxl b/metapost/context/base/mpxl/mp-luas.mpxl index 9ea130d35..05f7cef05 100644 --- a/metapost/context/base/mpxl/mp-luas.mpxl +++ b/metapost/context/base/mpxl/mp-luas.mpxl @@ -223,8 +223,8 @@ newscriptindex mfid_utfsub ; mfid_utfsub := scriptindex "utfsub" ; % def utflen = runscript mfid_utflen enddef ; % def utfsub = runscript mfid_utfsub enddef ; -vardef utfnum(expr s) = runscript mfid_utfnum s enddef ; % str -vardef utflen(expr s) = runscript mfid_utflen s enddef ; % str +vardef utfnum expr s = runscript mfid_utfnum s enddef ; % str +vardef utflen expr s = runscript mfid_utflen s enddef ; % str vardef utfsub(text t) = runscript mfid_utfsub t enddef ; % str, first, (optional) last permanent utfnum, utflen, utfsub ; @@ -265,14 +265,15 @@ permanent getparameters, presetparameters, hasparameter, hasoption, getparameter getparametercount, getmaxparametercount, getparameterpath, getparameterpen, getparametertext, % getparameteroption, applyparameters, pushparameters, popparameters ; -% This might also be done in stock mkiv: +% No vardef's because we need to scan for an assignment too and we'll see +% an endgroup otherwise. -newscriptindex mfid_year ; mfid_year := scriptindex "year" ; vardef year = runscript mfid_year enddef ; -newscriptindex mfid_month ; mfid_month := scriptindex "month" ; vardef month = runscript mfid_month enddef ; -newscriptindex mfid_day ; mfid_day := scriptindex "day" ; vardef day = runscript mfid_day enddef ; -newscriptindex mfid_hour ; mfid_hour := scriptindex "hour" ; vardef hour = runscript mfid_hour enddef ; -newscriptindex mfid_minute ; mfid_minute := scriptindex "minute" ; vardef minute = runscript mfid_minute enddef ; -newscriptindex mfid_second ; mfid_second := scriptindex "second" ; vardef second = runscript mfid_second enddef ; +newscriptindex mfid_year ; mfid_year := scriptindex "year" ; def year = runscript mfid_year enddef ; +newscriptindex mfid_month ; mfid_month := scriptindex "month" ; def month = runscript mfid_month enddef ; +newscriptindex mfid_day ; mfid_day := scriptindex "day" ; def day = runscript mfid_day enddef ; +newscriptindex mfid_hour ; mfid_hour := scriptindex "hour" ; def hour = runscript mfid_hour enddef ; +newscriptindex mfid_minute ; mfid_minute := scriptindex "minute" ; def minute = runscript mfid_minute enddef ; +newscriptindex mfid_second ; mfid_second := scriptindex "second" ; def second = runscript mfid_second enddef ; permanent year, month, day, hour, minute, second ; % overloaded diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 95611a807..a28d32bd4 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.19 13:12} +\newcontextversion{2021.02.20 16:46} %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 480c9e057..845a90e47 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.19 13:12} +\edef\contextversion{2021.02.20 16:46} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index 39f0f5193..bbfae9556 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -1120,6 +1120,7 @@ \setinterfaceconstant{print}{print} \setinterfaceconstant{printable}{قابلچاپ} \setinterfaceconstant{process}{پردازش} +\setinterfaceconstant{processors}{processors} \setinterfaceconstant{profile}{profile} \setinterfaceconstant{properties}{properties} \setinterfaceconstant{pubsep}{pubsep} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 3d6999949..9569ad872 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.19 13:12} +\newcontextversion{2021.02.20 16:46} %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 cc0f38fe2..bcb398971 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.19 13:12} +\edef\contextversion{2021.02.20 16:46} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 3ee668ec7..ac7f9a639 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 0b767e574..6d34b7e13 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index e46b5df44..9447d0f35 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.19 13:12} +\newcontextversion{2021.02.20 16:46} %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 66be150ef..8a983dd9f 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.19 13:12} +\immutable\edef\contextversion{2021.02.20 16:46} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index 3ea270a79..a936e5592 100644 --- a/tex/context/base/mkxl/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt @@ -29,14 +29,37 @@ local function defaultcolormodel() -- can be helper return (colormethod == 0 or colormethod == 1) and 1 or 3 end -local t = os.date("*t") -- maybe this should be a very early on global - -registerscript("year", function() return t.year end) -registerscript("month", function() return t.month end) -registerscript("day", function() return t.day end) -registerscript("hour", function() return t.hour end) -registerscript("minute", function() return t.min end) -registerscript("second", function() return t.sec end) +do + + local t = os.date("*t") -- maybe this should be a very early on global + + -- If we want to do a vardef then we first need to catch an endgroup and + -- that then fails because we have a variable sitting there, so they need + -- to be def's at the mp end. + + local assignment_code = metapost.codes.assignment + + local mpscannext = mp.scan.next + local mpscaninteger = mp.scan.integer + + local function item(name) + local n = mpscannext(true) -- keep + if n == assignment_code then + mpscannext() + t[name] = mpscaninteger() + else + return t[name] + end + end + + registerscript("year", function() return item("year") end) + registerscript("month", function() return item("month") end) + registerscript("day", function() return item("day") end) + registerscript("hour", function() return item("hour") end) + registerscript("minute", function() return item("min") end) + registerscript("second", function() return item("sec") end) + +end registerscript("PaperHeight", function() return getdimen("paperheight") * factor end) registerscript("PaperWidth", function() return getdimen("paperwidth") * factor end) diff --git a/tex/context/base/mkxl/mlib-pdf.lmt b/tex/context/base/mkxl/mlib-pdf.lmt index c1f5045d7..acd04e9e9 100644 --- a/tex/context/base/mkxl/mlib-pdf.lmt +++ b/tex/context/base/mkxl/mlib-pdf.lmt @@ -161,7 +161,7 @@ local function pen_characteristics(object) local t = pen_info(object) rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty divider = sx*sy - rx*ry - return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width + return not (sx == 1 and rx == 0 and ry == 0 and sy == 1 and tx == 0 and ty == 0), t.width end local function mpconcat(px, py) -- no tx, ty here / we can move this one inline if needed @@ -193,7 +193,8 @@ local function flushnormalpath(path, t, open) pth = path[i] if not ith then t[nt] = f_m(pth.x_coord,pth.y_coord) - elseif curved(ith,pth) then +-- elseif curved(ith,pth) then +elseif pth.curved then t[nt] = f_c(ith.right_x,ith.right_y,pth.left_x,pth.left_y,pth.x_coord,pth.y_coord) else t[nt] = f_l(pth.x_coord,pth.y_coord) @@ -203,8 +204,9 @@ local function flushnormalpath(path, t, open) if not open then nt = nt + 1 local one = path[1] - if curved(pth,one) then - t[nt] = f_c(pth.right_x,pth.right_y,one.left_x,one.left_y,one.x_coord,one.y_coord ) +-- if curved(pth,one) then +if one.curved then + t[nt] = f_c(pth.right_x,pth.right_y,one.left_x,one.left_y,one.x_coord,one.y_coord) else t[nt] = f_l(one.x_coord,one.y_coord) end @@ -233,7 +235,8 @@ local function flushconcatpath(path, t, open) pth = path[i] if not ith then t[nt] = f_m(mpconcat(pth.x_coord,pth.y_coord)) - elseif curved(ith,pth) then +-- elseif curved(ith,pth) then +elseif pth.curved then local a, b = mpconcat(ith.right_x,ith.right_y) local c, d = mpconcat(pth.left_x,pth.left_y) t[nt] = f_c(a,b,c,d,mpconcat(pth.x_coord,pth.y_coord)) @@ -245,7 +248,8 @@ local function flushconcatpath(path, t, open) if not open then nt = nt + 1 local one = path[1] - if curved(pth,one) then +-- if curved(pth,one) then +if one.curved then local a, b = mpconcat(pth.right_x,pth.right_y) local c, d = mpconcat(one.left_x,one.left_y) t[nt] = f_c(a,b,c,d,mpconcat(one.x_coord, one.y_coord)) diff --git a/tex/context/base/mkxl/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index 7a3a64875..8648848bc 100644 --- a/tex/context/base/mkxl/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -179,7 +179,8 @@ \glet\currentstructurecoding\s!tex \fi \iflocation \ifempty\currentstructurebookmark \orelse \ifx\currentstructurebookmark\currentstructuretitle \else - \showmessage\m!structures3{{\currentstructurebookmark}}% + %\showmessage\m!structures3{{\currentstructurebookmark}}% comma interference + \writestatus{\m!structures}{bookmark:\space\currentstructurebookmark}% \fi \fi \setnextinternalreference \storeinternalreference\currentstructurename{\the\locationcount}% diff --git a/tex/context/base/mkxl/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt index e1feba99d..657e3addb 100644 --- a/tex/context/base/mkxl/supp-box.lmt +++ b/tex/context/base/mkxl/supp-box.lmt @@ -382,7 +382,7 @@ implement { arguments = "integer", public = true, actions = function(n) - context.puretext(nodes.toutf(texgetbox(n).list)) -- helper is defined later + context.verbatim(nodes.toutf(texgetbox(n).list)) -- helper is defined later end } diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 4a5558344..d4fbccd21 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -1126,6 +1126,7 @@ <cd:constant name='print' value='print'/> <cd:constant name='printable' value='قابلچاپ'/> <cd:constant name='process' value='پردازش'/> + <cd:constant name='processors' value='processors'/> <cd:constant name='profile' value='profile'/> <cd:constant name='properties' value='properties'/> <cd:constant name='pubsep' value='pubsep'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index f15be4bf6..3b0a7991a 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-19 13:12 +-- merge date : 2021-02-20 16:46 do -- begin closure to overcome local limits and interference |