diff options
Diffstat (limited to 'doc')
19 files changed, 555 insertions, 158 deletions
diff --git a/doc/context/documents/general/manuals/ecmascript-mkiv.pdf b/doc/context/documents/general/manuals/ecmascript-mkiv.pdf Binary files differnew file mode 100644 index 000000000..308dfda78 --- /dev/null +++ b/doc/context/documents/general/manuals/ecmascript-mkiv.pdf diff --git a/doc/context/documents/general/manuals/libraries-mkiv.pdf b/doc/context/documents/general/manuals/libraries-mkiv.pdf Binary files differindex 9b13d7414..aa18726e3 100644 --- a/doc/context/documents/general/manuals/libraries-mkiv.pdf +++ b/doc/context/documents/general/manuals/libraries-mkiv.pdf diff --git a/doc/context/documents/general/manuals/luametatex.pdf b/doc/context/documents/general/manuals/luametatex.pdf Binary files differindex b128ed767..766e9a709 100644 --- a/doc/context/documents/general/manuals/luametatex.pdf +++ b/doc/context/documents/general/manuals/luametatex.pdf diff --git a/doc/context/documents/general/manuals/sql-mkiv.pdf b/doc/context/documents/general/manuals/sql-mkiv.pdf Binary files differindex 09e63bcc8..57f6a9dc0 100644 --- a/doc/context/documents/general/manuals/sql-mkiv.pdf +++ b/doc/context/documents/general/manuals/sql-mkiv.pdf diff --git a/doc/context/sources/general/manuals/libraries/ecmascript-mkiv.tex b/doc/context/sources/general/manuals/libraries/ecmascript-mkiv.tex new file mode 100644 index 000000000..70350142c --- /dev/null +++ b/doc/context/sources/general/manuals/libraries/ecmascript-mkiv.tex @@ -0,0 +1,420 @@ +% language=us + +% 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. +% +% comment : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt +% Group journal or otherwise. Thanks to the editors for corrections. Also thanks +% to users for testing, feedback and corrections. + +% for now: + +\usemodule[article-basic] +\usemodule[abbreviations-smallcaps] +\usemodule[scite] +\usemodule[ecmascript] + +\definecolor + [maincolor] + [r=.4] + +\definecolor + [extracolor] + [g=.4] + +\setupbodyfont + [11pt] + +\setuptype + [color=maincolor] + +% \setuptyping +% [color=maincolor] + +\definefontsynonym + [TitlePageMono] + [file:lmmonoproplt10-bold*default] + +\setuphead + [color=maincolor] + +\usesymbols + [cc] + +\setupinteraction + [hidden] + +\loadfontgoodies[lm] + +\startdocument + [metadata:author=Hans Hagen, + metadata:title=ecmascript in context lmtx, + author=Hans Hagen, + affiliation=PRAGMA ADE, + location=Hasselt NL, + title=\ECNASCRIPT\ in \CONTEXT\ \LMTX, + support=www.contextgarden.net, + website=www.pragma-ade.nl] + +\starttext + +\startMPpage + StartPage; + + fill Page withcolor "darkgreen"; + + draw textext.lrt("\tttf ECMA") + xsized .75PaperWidth + shifted ulcorner (Page enlarged -15mm ) + withcolor "white" ; + + draw textext.llft("\tttf SCRIPT") + xsized .50PaperWidth + shifted urcorner (Page enlarged -15mm topenlarged -70mm) + withcolor "white" ; + + draw textext.llft("\tttf in context lmtx") + xsized .50PaperWidth + shifted urcorner (Page enlarged -15mm topenlarged -110mm) + withcolor "white" ; + + draw textext.llft("\tttf using the optional mujs library") + xsized .50PaperWidth + shifted lrcorner (Page enlarged -15mm bottomenlarged -10mm) + withcolor "white" ; + + StopPage; +\stopMPpage + +\dontcomplain + +% \startsubject[title=Contents] +% +% \placelist[section][alternative=a] +% +% \stopsubject + +\startsection[title=Introduction] + +When you use \CONTEXT\ there is no way around noticing that the \LUA\ scripting +language is an important component. When we progressed from \LUATEX\ to +\LUAMETATEX\ did didn't change. I like that language a lot! Among the reasons are +that it reminds me of \PASCAL, that it's clean, fast and well maintained. There +is no huge infrastructure involved, nor lots of libraries and therefore +dependencies. + +So why bother about another scripting language? One can argue that because of the +World Wide Web one should use \JAVASCRIPT\ instead. It might make sense from a +commercial point of view, or for some promotional reason. But that all makes +little sense in the perspective of \CONTEXT. But, when I was playing with +optional libraries in \LUAMETATEX, + +On and off I wonder if I should spend some time on adding \LUA\ annotation +support to the open source mupdf viewer. After all, it has some basic +\JAVASCRIPT\ support (but currently not enough, for instance it lacks control +over widgets and layers and such.) However, then I noticed that the related +\JAVASCRIPT\ code was actually an independent library and looking at the header +files it looked quite a bit like the \LUA\ interface. So, just for the fun of it I +gave it a try, and when doing so, I realized that having support for \JAVASCRIPT, +or actually \ECMASCRIPT, because that is what it is, could make users who are +afraid of \LUA\ willing to play with simple scripting in \CONTEXT. Of course, +after a while they will figure out that \LUA\ is the real deal. + +Therefore, instead of sticking to an experiment, I decided to make support for +the \type {mujs} library an option. After all, every now and they we need +something new to play with. But be warned: it's an optional thing. The +interpreter is not embedded in the binary and is loaded on demand (when present). +In spite of that performance is quite okay. + +\stopsection + +\startsection[title=A few examples] + +Because the provided interface is pretty limited, a few simple examples will do. +There are plenty of tutorials on the Internet. The main thing to keep in mind is +that an \ECMASCRIPT\ interpreter is normally pretty limited when it comes to +communicating with its environment. For instance, the main application provides +way to print something (to a console) or read from files. So, commands that +relate to this are specific for \LUAMETATEX. Before anything can be done you need +to load the (\type {mujs}) library, which is done with: + +\starttyping +\usemodule[ecmascript] +\stoptyping + +You can write a message to the log (or an output pane or console) with the \type +{console} function, one that normally is present in a \JAVASCRIPT\ (\ECMASCRIPT) +environment: + +\starttyping +\ecmacode {console("Example Three!")} +\stoptyping + +Printing something to the \TEX\ engine is done with this command: + +\startbuffer +\ecmacode {texprint("Just a {\\bf short} sentence.")} +\stopbuffer + +\typebuffer[option=TEX] + +This produces: + +\getbuffer + +and is comparable with the \type {tex.print} (which prints lines) function at the +\LUA\ end. This means that there is also \type {texsprint} (which accumulates +parts into lines). In practice one will probably always use that one. + +When there are two arguments, the first argument has to be a number and sets the +so called catcode table to be used. + +\startbuffer +\ecmacode {texprint(catcodes.vrb,"Just a {\\bf short} sentence.")} +\stopbuffer + +\typebuffer[option=TEX] + +This results in a verbatim print: {\tttf \inlinebuffer} The backslash is just that, +a backslash and not a trigger for a \TEX\ command. + +You can do pretty much everything with these print commands. Take for instance the +following example: + +\startbuffer +\startecmacode + console("We're doing some MetaPost!"); + texsprint( + "\\startMPcode " + + 'fill fullsquare xyscaled (6cm,1cm) withcolor "darkred";' + + 'fill fullsquare xyscaled (4cm,1cm) withcolor "darkgreen";' + + 'fill fullsquare xyscaled (2cm,1cm) withcolor "darkblue";' + + "\\stopMPcode " + ); +\stopecmacode +\stopbuffer + +\typebuffer[option=TEX] + +This produces: + +\startlinecorrection +\getbuffer +\stoplinecorrection + +in \LUA\ we can do this: + +\startbuffer +\startluacode + context.startMPcode() + context('fill fullsquare xyscaled (6cm,1cm) withcolor "middlecyan";') + context('fill fullsquare xyscaled (4cm,1cm) withcolor "middlemagenta";') + context('fill fullsquare xyscaled (2cm,1cm) withcolor "middleyellow";') + context.stopMPcode() +\stopluacode +\stopbuffer + +\typebuffer[option=TEX] + +The result is the same but the code to produce it looks more like \CONTEXT, if +only because way more built in features are provided. It makes no sense to do +the same with another scripting language. + +\startlinecorrection +\getbuffer +\stoplinecorrection + +As mentioned, reading from files is to be provided by the main program and indeed +we do have some basic interface. Actually we delegate all to the \LUA\ end by +using a callback mechanism but users won't see these details. It suffices to know +that file lookups are done the same way as in the main program because we use the +same resolvers. One can (in the spirit of \ECMASCRIPT) open a file by creating a +new file object. After that one can read from the file and, when done, close it. + +\startbuffer +\startecmacode + var f = File("ecmascript-mkiv.tex","r"); + var l = f.read("*a"); + f.close(); + texprint( + "This file has " + + l.length // or: l.length.toString() + + " bytes!" + ) +\stopecmacode +\stopbuffer + +\typebuffer[option=TEX] + +Which reports that: \quotation {\inlinebuffer} The arguments to the \type {read} +method are the same as in \LUA, so for instance \type {*a} reads the whole file, +\type {*l} a single line, and a number will read that many bytes. There is +currently no support for writing as I see no need for it (yet). + +You can load an external file too. + +\startluacode +io.savedata("ecmascript-demo-001.js",[[ +function filesize(name) { + var f = File(name,"r"); + if (f != undefined) { + var l = f.read("*a"); + f.close(); + return l.length; + } else { + return 0; + } +} +]]) +\stopluacode + +\startbuffer +\ecmafile{ecmascript-demo-001.js} +\stopbuffer + +\typebuffer[option=TEX] \getbuffer + +This file defines a function: + +\typefile{ecmascript-demo-001.js} + +We use this as follows: + +\startbuffer +\startecmacode + texsprint( + "This file has " + + filesize("ecmascript-mkiv.tex") + + " bytes!" + ) +\stopecmacode +\stopbuffer + +\typebuffer[option=TEX] + +The result is the same as before: \quotation {\inlinebuffer} but by using a +predefined function we save ourselves some typing. Actually, a more efficient +variant is this: + +\starttyping +function filesize(name) { + var f = File(name,"r"); + if (f != undefined) { + var l = f.seek("end"); + f.close(); + return l; + } else { + return 0; + } +} +\stoptyping + +As with the \type {read} method, the \type {seek} method behaves the same as +its \LUA\ counterpart, which is a good reason to have a look at the \LUA\ +manual. + +If you want you want also access the \ECMASCRIPT\ interpreter from the \LUA\ end, +not that it makes much sense, but maybe you have a lot of complex code that you +don't want to rewrite. Here is an example: + +\startbuffer +\startluacode + optional.loaded.mujs.execute [[ + var MyMax = 10; // an example of persistence + ]] + + optional.loaded.mujs.execute [[ + texsprint("\\startpacked"); + for (var i = 1; i <= MyMax; i++) { + texprint( + "Here is some rather dumb math test: " + + Math.sqrt(i/MyMax) + + "!\\par" + ); + } + texsprint("\\stoppacked"); + ]] +\stopluacode +\stopbuffer + +\typebuffer[option=TEX] + +This assumes that you have loaded the module \type {ecmascript} which does the +necessary preparations. Watch the different ways to add comment and also watch +how we need to escape the \CONTEXT\ commands. Of course the syntax of both +languages is different too. + +\getbuffer + +For now there is not much more to tell. I might add a few features (and more +examples). And the low level optional interface is not yet declared stable but as +we wrap it in higher level commands no one will notice changes at that end. + +\stopsection + +\startsection[title=Extensions] + +To summarize, for printing to \TEX\ we have: + +\starttyping +texsprint([catcodetableid,]string|number) +\stoptyping + +and + +\starttyping +texprint(catcodetableid,]string|number) +\stoptyping + +and for printing to the console: + +\starttyping +console(string|number) +\stoptyping + +A file is opened with: + +\starttyping +var f = File.new(filename[,mode]) +\stoptyping + +and the returned file object has the methods: + +\starttyping +var str = f:read([string|number]) +var pos = f:seek(whence[,offset]) +\stoptyping + +There is a predefined table \type {catcodes} with sybolic entries +for: + +\starttabulate +\NC \type {tex} \NC regular \TEX\ catcode regime \NC \NR +\NC \type {ctx} \NC standard \CONTEXT\ catcode regime \NC \NR +\NC \type {vrb} \NC verbatim catcode regime \NC \NR +\NC \type {prt} \NC protected \CONTEXT\ catcode regime \NC \NR +\stoptabulate + +\stopsection + +\startsection[title=Colofon] + +\starttabulate[|B|p|] +\NC author \NC \getvariable{document}{author}, \getvariable{document}{affiliation}, \getvariable{document}{location} \NC \NR +\NC version \NC \currentdate \NC \NR +\NC website \NC \getvariable{document}{website} \endash\ \getvariable{document}{support} \NC \NR +\stoptabulate + +\stopsection + +\stopdocument diff --git a/doc/context/sources/general/manuals/libraries/libraries-mkiv.tex b/doc/context/sources/general/manuals/libraries/libraries-mkiv.tex index 6a322c771..f1801efc0 100644 --- a/doc/context/sources/general/manuals/libraries/libraries-mkiv.tex +++ b/doc/context/sources/general/manuals/libraries/libraries-mkiv.tex @@ -61,7 +61,7 @@ support=www.contextgarden.net, website=www.pragma-ade.nl] -\startluasetups[swiglib] +\startluasetups[libraries] context.nohyphens() for i=1,640 do context.definedfont { string.formatters["TitlePageMono at %p"](65536*(10+math.random(5))) } @@ -76,7 +76,7 @@ StartPage ; fill Page enlarged 1cm withcolor \MPcolor{extracolor} ; - draw textext("\framed[loffset=2pt,roffset=2pt,frame=off,width=\paperwidth,align={normal,paragraph,verytolerant,stretch}]{\luasetup{swiglib}}") + draw textext("\framed[loffset=2pt,roffset=2pt,frame=off,width=\paperwidth,align={normal,paragraph,verytolerant,stretch}]{\luasetup{libraries}}") xysized (PaperWidth,PaperHeight) shifted center Page withcolor .8white ; @@ -247,6 +247,7 @@ There are some optional libraries present, like: \NC libs-imp-sqlite \NC sqlite \NC sqlite3 \NC sqlite3 \NC \NR %NC libs-imp-postgress \NC libpg \NC libpg \NC libpg \NC \NR % untested \NC libs-imp-zint \NC libzint \NC libzint \NC libzint \NC \NR +\NC libs-imp-mujs \NC libmujs \NC libmujs \NC libmujs \NC \NR \NC libs-imp-ghostscript \NC ghostscript \NC gswin64 \NC libgs \NC \NR \NC libs-imp-graphicsmagick \NC graphicsmagick \NC several \NC unknown \NC \NR %NC font-phb-imp-internal \NC hb \NC libharfbuzz \NC libharfbuzz \NC \NR % maybe, for idris, testing uniscribe diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex b/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex index e713d13c3..e3e2a91e1 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex @@ -13,6 +13,7 @@ \libindex{register} \libindex{list} \libindex{find} +\libindex{known} This library has functions that register, find and list callbacks. Callbacks are \LUA\ functions that are called in well defined places. There are two kind of @@ -28,18 +29,14 @@ but in the end might not give the user the expected outcome. The first thing you need to do is registering a callback: \startfunctioncall -id, error = - callback.register(<string> callback_name, <function> func) -id, error = - callback.register(<string> callback_name, nil) -id, error = - callback.register(<string> callback_name, false) +id = callback.register(<string> callback_name, <function> func) +id = callback.register(<string> callback_name, nil) +id = callback.register(<string> callback_name, false) \stopfunctioncall Here the \syntax {callback_name} is a predefined callback name, see below. The function returns the internal \type {id} of the callback or \type {nil}, if the -callback could not be registered. In the latter case, \type {error} contains an -error message, otherwise it is \type {nil}. +callback could not be registered. \LUATEX\ internalizes the callback function in such a way that it does not matter if you redefine a function accidentally. @@ -65,7 +62,12 @@ The keys in the table are the known callback names, the value is a boolean where <function> f = callback.find(callback_name) \stopfunctioncall -If the callback is not set, \type {find} returns \type {nil}. +If the callback is not set, \type {find} returns \type {nil}. The \type {known} +function can be used to check if a callback is supported. + +\startfunctioncall +if callback.known("foo") then ... end +\stopfunctioncall \stopsection diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-differences.tex b/doc/context/sources/general/manuals/luametatex/luametatex-differences.tex index 19a4078c1..4ec846b38 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-differences.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-differences.tex @@ -15,6 +15,8 @@ what is gone. We start with the primitives that were dropped. \type {\expandglyphsinfont} \type {\ignoreligaturesinfont} \type {\tagcode} + \type {\leftghost} + \type {\rightghost} \NC \NR \NC backend \NC \type {\dviextension} \type {\dvivariable } @@ -151,6 +153,8 @@ show_whatsit Being the core of extensibility, the typesetting callbacks of course stayed. This is what we ended up with: +% \ctxlua{inspect(table.sortedkeys(callbacks.list))} + \starttyping find_log_file, find_data_file, find_format_file, open_data_file, read_data_file, process_jobname, start_run, stop_run, define_font, pre_output_filter, diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex b/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex index 06e0ce327..d70b8f2c0 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex @@ -14,7 +14,7 @@ From day one, \LUATEX\ has offered extra features compared to the superset of \PDFTEX, which includes \ETEX, and \ALEPH. This has not been limited to the possibility to execute \LUA\ code via \prm {directlua}, but \LUATEX\ also adds functionality via new \TEX|-|side primitives or extensions to existing ones. The -same is true fir \LUAMETATEX. Some primitives have \type {luatex} in their name +same is true for \LUAMETATEX. Some primitives have \type {luatex} in their name and there will be no \type {luametatex} variants. This is because we consider \LUAMETATEX\ to be \LUATEX 2\high{+}. @@ -40,14 +40,10 @@ it may be needed to put these assignments before the above line: \stoptyping More fine|-|grained primitives control is possible and you can look up the -details in \in {section} [luaprimitives]. For simplicity's sake, this manual -assumes that you have executed the \prm {directlua} command as given above. - -The startup behaviour documented above is considered stable in the sense that -there will not be backward|-|incompatible changes any more. We have promoted some -rather generic \PDFTEX\ primitives to core \LUATEX\ ones, and a few that we -inherited from \ALEPH\ (\OMEGA) are also promoted. Effectively this means that we -now only have the \type {tex}, \type {etex} and \type {luatex} sets left. +details in \in {section} [luaprimitives]. There are only three kinds of +primitives: \type {tex}, \type {etex} and \type {luatex} but a future version +might drop this and no longer make that distinction as it no longer serves +a purpose. \stopsubsection @@ -225,7 +221,7 @@ commands are: Fonts are loaded via \LUA\ and a minimal amount of information is kept at the \TEX\ end. Sharing resources is up to the loaders. The engine doesn't really care -about what a character (or glyph) number represents (an \UNICODE\ or index) as it +about what a character (or glyph) number represents (a \UNICODE\ or index) as it only is interested in dimensions. \stopsubsection @@ -246,7 +242,7 @@ nodes that have for instance a \type {font} and \type {char} property and \typ {\kern 10pt} becomes a \nod {kern} node with a \type {width} property. Spaces are alien to \TEX\ as they are turned into \nod {glue} nodes. So, a simple paragraph is mostly a mix of sequences of \nod {glyph} nodes (words) and \nod {glue} nodes -(spaces). A node can have a subtype to that it can be recognized as for instance +(spaces). A node can have a subtype so that it can be recognized as for instance a space related glue. The sequences of characters at some point are extended with \nod {disc} nodes @@ -271,7 +267,7 @@ and carry only the minimal amount of information needed. In traditional \TEX\ a character node only held the font and slot number, in \LUATEX\ we also store some language related information, the expansion factor, etc. Now that we have access to these nodes from \LUA\ it makes sense to be able to carry more information -with an node and this is where attributes kick in. +with a node and this is where attributes kick in. \stopsubsection @@ -379,7 +375,7 @@ code: Later we will see that you can access properties of a node. The boxes here are so called \nod {hlist} nodes that have a field \type {list} that points to the content. Because the attributes are a list themselves you can access them by -indexing the node (here we do that with \type {[a]}. Running this snippet gives: +indexing the node (here we do that with \type {[a]}). Running this snippet gives: \start \getbuffer[tex] @@ -597,7 +593,7 @@ function calls is that they are stored in the format (but without upvalues). Catcode tables are a new feature that allows you to switch to a predefined catcode regime in a single statement. You can have lots of different tables, but -if you need a dozen you might wonder what you're doing. . This subsystem is +if you need a dozen you might wonder what you're doing. This subsystem is backward compatible: if you never use the following commands, your document will not notice any difference in behaviour compared to traditional \TEX. The contents of each catcode table is independent from any other catcode table, and its @@ -795,10 +791,10 @@ but faster (only measurable with millions of calls) and probably more convenient \topicindex {expansion} -The \lpr {expanded} primitive takes a token list and expands it content which can +The \lpr {expanded} primitive takes a token list and expands its content which can come in handy: it avoids a tricky mix of \prm {expandafter} and \prm {noexpand}. You can compare it with what happens inside the body of an \prm {edef}. But this -kind of expansion it still doesn't expand some primitive operations. +kind of expansion still doesn't expand some primitive operations. \startbuffer \newcount\NumberOfCalls @@ -890,14 +886,14 @@ so called prefixed commands (except box assignments). \startsubsection[title={\lpr {ignorepars}}] -This primitives is like \prm {ignorespaces} but also skips paragraph ending +This primitive is like \prm {ignorespaces} but also skips paragraph ending commands (normally \prm {par} and empty lines). \stopsubsection \startsubsection[title={\lpr {futureexpand}, \lpr {futureexpandis}, \lpr {futureexpandisap}}] -These commands are use as: +These commands are used as: \starttyping \futureexpand\sometoken\whenfound\whennotfound @@ -1152,7 +1148,7 @@ measurable when you runs tens of millions of complex tests and in that case it i very likely to drown in the real action. It's a convenience mechanism, in the sense that it can make your code look a bit easier to follow. -There is an nice side effect of this mechanism. When you define: +There is a nice side effect of this mechanism. When you define: \starttyping \def\quitcondition{\orelse\iffalse} @@ -1244,7 +1240,7 @@ the backend to include an image. The wrapping is needed because a special itself is a whatsit and as such has no dimensions. In \PDFTEX\ a special whatsit for images was introduced and that one {\em has} -dimensions. As a consequence, in several places where the engine to deal with the +dimensions. As a consequence, in several places where the engine deals with the dimensions of nodes, it now has to check the details of whatsits. By inheriting code from \PDFTEX, the \LUATEX\ engine also had that property. However, at some point this approach was abandoned and a more natural trick was used: images (and @@ -1254,7 +1250,7 @@ dimensions, the code could be simplified. When direction nodes and localpar nodes also became first class nodes, whatsits again became just that: nodes representing whatever you want, but without dimensions, and therefore they could again be ignored when dimensions mattered. -And, because images were disguised as rules, as mentioned ,their dimensions +And, because images were disguised as rules, as mentioned, their dimensions automatically were taken into account. This seperation between front and backend cleaned up the code base already quite a bit. @@ -1263,7 +1259,7 @@ engine never looks at subtypes of rules. That was up to the backend. This means that image support is not present in \LUAMETATEX. When an image specification was parsed the special properties, like the filename, or additional attributes, were stored in the backend and all that \LUATEX\ does is registering a reference to an -image s specification in the rule node. But, having no backend means nothing is +image's specification in the rule node. But, having no backend means nothing is stored, which in turn would make the image inclusion primitives kind of weird. Therefore you need to realize that contrary to \LUATEX, {\em in \LUAMETATEX\ @@ -1286,7 +1282,7 @@ of course be implemented in \LUA. \LL \stoptabulate -An implementation probably should accepts the usual optional dimension parameters +An implementation probably should accept the usual optional dimension parameters for \type {\use...resource} in the same format as for rules. With images, these dimensions are then used instead of the ones given to \lpr {useimageresource} but the original dimensions are not overwritten, so that a \lpr {useimageresource} @@ -1494,7 +1490,7 @@ The approach is that we try to make node lists balanced but also try to avoid some side effects. What happens is quite intuitive if we forget about spaces (turned into glue) but even there what happens makes sense if you look at it in detail. However that logic makes in|-|group switching kind of useless when no -proper nested grouping is used: switching from right to left several times +properly nested grouping is used: switching from right to left several times nested, results in spacing ending up after each other due to nested mirroring. Of course a sane macro package will manage this for the user but here we are discussing the low level injection of directional information. diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex index 077d9e51e..917ebfeb8 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex @@ -9,7 +9,7 @@ \startsection[title={Introduction}] Only traditional font support is built in, anything more needs to be implemented -in \LUA. This is conform the \LUATEX\ philosophy. When you pass a font to the +in \LUA. This conforms to the \LUATEX\ philosophy. When you pass a font to the frontend only the dimensions matter, as these are used in typesetting, and optionally ligatures and kerns when you rely on the built|-|in font handler. For math some extra data is needed, like information about extensibles and next in @@ -79,37 +79,14 @@ The names and their internal remapping are: \LL \stoptabulate -The \type {characters} table is a list of character hashes indexed by an integer -number. The number is the \quote {internal code} \TEX\ knows this character by. -For proper paragraph building and math rendering the following fields can be -present in en entry in the \type {characters} table. You can of course add all -kind of extra fields. The engine only uses those that it needs for typesetting -a paragraph or formula. - -Each character hash itself is a hash. For example, here is the character \quote -{f} (decimal 102) in the font \type {cmr10 at 10pt}. The numbers that represent -dimensions are in scaled points. - -\starttyping -[102] = { - ["width"] = 200250, - ["height"] = 455111, - ["depth"] = 0, - ["italic"] = 50973, - ["kerns"] = { - [63] = 50973, - [93] = 50973, - [39] = 50973, - [33] = 50973, - [41] = 50973 - }, - ["ligatures"] = { - [102] = { ["char"] = 11, ["type"] = 0 }, - [108] = { ["char"] = 13, ["type"] = 0 }, - [105] = { ["char"] = 12, ["type"] = 0 } - } -} -\stoptyping +The \type {characters} table is a \LUA\ hash table where the keys are integers. +When a character in the input is turned into a glyph node, it gets a character +code that normally refers to an entry in that table. For proper paragraph +building and math rendering the following fields can be present in an entry in +the \type {characters} table. You can of course add all kind of extra fields. The +engine only uses those that it needs for typesetting a paragraph or formula. The +subtables that define ligatures and kerns are also hashes with integer keys, and +these indices should point to entries in the main characters table. Providing ligatures and kerns this way permits \TEX\ to construct ligatures and add inter|-|character kerning. However, normally you will use an \OPENTYPE\ font @@ -139,6 +116,31 @@ has no ligatures and kerns and is normally not processed at all. \LL \stoptabulate +For example, here is the character \quote {f} (decimal 102) in the font \type +{cmr10 at 10pt}. The numbers that represent dimensions are in scaled points. + +\starttyping +[102] = { + ["width"] = 200250, + ["height"] = 455111, + ["depth"] = 0, + ["italic"] = 50973, + ["kerns"] = { + [63] = 50973, + [93] = 50973, + [39] = 50973, + [33] = 50973, + [41] = 50973 + }, + ["ligatures"] = { + [102] = { ["char"] = 11, ["type"] = 0 }, + [108] = { ["char"] = 13, ["type"] = 0 }, + [105] = { ["char"] = 12, ["type"] = 0 } + } +} +\stoptyping + + Two very special string indexes can be used also: \type {left_boundary} is a virtual character whose ligatures and kerns are used to handle word boundary processing. \type {right_boundary} is similar but not actually used for anything @@ -235,7 +237,7 @@ indicates the final insertion point. % \topicindex {fonts+virtual} Virtual fonts have been introduced to overcome limitations of good old \TEX. They -were mostly use for providing a direct mapping from for instance accented +were mostly used for providing a direct mapping from for instance accented characters onto a glyph. The backend was responsible for turning a reference to a character slot into a real glyph, possibly constructed from other glyphs. In our case there is no backend so there is also no need to pass this information @@ -247,12 +249,11 @@ A virtual character can itself point to virtual characters but be careful with nesting as you can create loops and overflow the stack (which often indicates an error anyway). -At the font level there can be a \type {fonts} an (indexed) \LUA\ table. The -values are one- or two|-|key hashes themselves, each entry indicating one of the -base fonts in a virtual font. In case your font is referring to itself in for -instance a virtual font, you can use the \type {slot} command with a zero font -reference, which indicates that the font itself is used. So, a table looks like -this: +At the font level there can be a an (indexed) \type {fonts} table. The values are +one- or two|-|key hashes themselves, each entry indicating one of the base fonts +in a virtual font. In case your font is referring to itself in for instance a +virtual font, you can use the \type {slot} command with a zero font reference, +which indicates that the font itself is used. So, a table looks like this: \starttyping fonts = { diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex b/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex index 56d5c7436..774f3d8d9 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-introduction.tex @@ -101,8 +101,9 @@ Hans Hagen \vfilll {\bf remark:} \LUAMETATEX\ development is mostly done by Hans Hagen and Alan -Braslau, who love playing with the three languages involved. Testing is done by -\CONTEXT\ developers and users. Many thanks for their patience! +Braslau, who love playing with the three languages involved. And as usual Mojca +Miklavec make sure all compiles well on the buildbot infrastructure. Testing is +done by \CONTEXT\ developers and users. Many thanks for their patience! {\bf remark:} When there are non|-|intrusive features that also make sense in \LUATEX, these will be applied in the experimental branch first, so that there is diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex b/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex index 19112a7f1..b6607a9bb 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-languages.tex @@ -85,17 +85,6 @@ time (in case of a single|-|glyph word). \startitem \type {ligature}, for constructed ligatures bit 1 is set. \stopitem - \startitem - \type {ghost}, for so called \quote {ghost objects} bit 2 is set. - \stopitem - \startitem - \type {left}, for ligatures created from a left word boundary and for - ghosts created from \lpr {leftghost} bit 3 gets set. - \stopitem - \startitem - \type {right}, for ligatures created from a right word boundary and - for ghosts created from \lpr {rightghost} bit 4 is set. - \stopitem \stopitemize The \nod {glyph} nodes also contain language data, split into four items that @@ -142,8 +131,8 @@ initialized you start out with nothing, otherwise you already have a set. When a \lpr {hjcode} is greater than 0 but less than 32 is indicates the to be used length. In the following example we map a character (\type {x}) onto -another one in the patterns and tell the engine that \type {œ} counts as one -character. Because traditionally zero itself is reserved for inhibiting +another one in the patterns and tell the engine that \type {œ} counts as two +characters. Because traditionally zero itself is reserved for inhibiting hyphenation, a value of 32 counts as zero. Here are some examples (we assume that French patterns are used): @@ -369,7 +358,7 @@ before---after \par \stopcombination \stopbuffer -\startplacefigure[locationreference=automatichyphenmode:1,title={The automatic modes \type {0} (default), \type {1} and \type {2}, with a \prm {hsize} +\startplacefigure[reference=automatichyphenmode:1,title={The automatic modes \type {0} (default), \type {1} and \type {2}, with a \prm {hsize} of 6em and 2pt (which triggers a linebreak).}] \dontcomplain \tt \getbuffer[demo] \stopplacefigure @@ -435,13 +424,6 @@ there are a few exceptions. \stopitem \startitem - The \ALEPH|-|derived commands \lpr {leftghost} and \lpr {rightghost} - create nodes of a third subtype: \quote {ghost}. These nodes are ignored - completely by all further processing until the stage where inter|-|glyph - kerning is added. -\stopitem - -\startitem Automatic discretionaries are handled differently. \TEX82 inserts an empty discretionary after sensing an input character that matches the \prm {hyphenchar} in the current font. This test is wrong in our opinion: whether @@ -511,7 +493,7 @@ have been added: \stoptyping The first parameter has the following consequences for automatic discs (the ones -resulting from an \prm {exhyphenchar}: +resulting from an \prm {exhyphenchar}): \starttabulate[|c|l|l|] \DB mode \BC automatic disc \type {-} \BC explicit disc \prm{-} \NC \NR @@ -609,7 +591,7 @@ actual explicit hyphen character if needed). For example, this matches the word The motivation behind the \ETEX\ extension \prm {savinghyphcodes} was that hyphenation heavily depended on font encodings. This is no longer true in \LUATEX, and the corresponding primitive is basically ignored. Because we now -have \lpr {hjcode}, the case relate codes can be used exclusively for \prm +have \lpr {hjcode}, the case related codes can be used exclusively for \prm {uppercase} and \prm {lowercase}. The three curly brace pair pattern in an exception can be somewhat unexpected so @@ -777,8 +759,8 @@ boundary items after it is done with them, and it does the same for \quote {ghost} nodes. Finally, at the end of the kerning stage, all remaining \quote {character} nodes are converted to \quote {glyph} nodes. -This word separation is worth mentioning because, if you overrule from \LUA\ only -one of the two callbacks related to font handling, then you have to make sure you +This separation is worth mentioning because, if you overrule from \LUA\ only one +of the two callbacks related to font handling, then you have to make sure you perform the tasks normally done by \LUATEX\ itself in order to make sure that the other, non|-|overruled, routine continues to function properly. @@ -826,7 +808,7 @@ Here is that nested solution again, in a different representation: \starttabulate[|l|c|c|c|c|c|c|] \DB \BC pre \BC \BC post \BC \BC replace \BC \NC \NR \TB -\NC topdisc \NC \type {f-} \NC (1) \NC \NC sub 1 \NC \NC sub 2 \NC \NR +\NC topdisc \NC \type {f-} \NC (1) \NC sub 1 \NC \NC sub 2 \NC \NC \NR \NC sub 1 \NC \type {f-} \NC (2) \NC \type {i} \NC (3) \NC \type {<fi>} \NC (4) \NC \NR \NC sub 2 \NC \type {<ff>-} \NC (5) \NC \type {i} \NC (6) \NC \type {<ffi>} \NC (7) \NC \NR \LL @@ -907,13 +889,13 @@ approach. \topicindex {paragraphs} \topicindex {discretionaries} -This code is almost unchanged, but because of the above|-|mentioned changes -with respect to discretionaries and ligatures, line breaking will potentially be +This code is almost unchanged, but because of the above|-|mentioned changes with +respect to discretionaries and ligatures, line breaking will potentially be different from traditional \TEX. The actual line breaking code is still based on -the \TEX82 algorithms, and it does not expect there to be discretionaries inside -of discretionaries. But, as patterns evolve and font handling can influence -discretionaries, you need to be aware of the fact that long term consistency is not -an engine matter only. +the \TEX82 algorithms, and there can be no discretionaries inside of +discretionaries. But, as patterns evolve and font handling can influence +discretionaries, you need to be aware of the fact that long term consistency is +not an engine matter only. But that situation is now fairly common in \LUATEX, due to the changes to the ligaturing mechanism. And also, the \LUATEX\ discretionary nodes are implemented diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex index 111a6cf03..ce4fe1544 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex @@ -593,10 +593,12 @@ with zero being the default behaviour. \start +\def\MathHack#1{\mathsurroundmode#1\relax\inlinebuffer} + \def\OneLiner#1#2% {\NC \type{#1} - \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\mathsurroundmode#1\relax\hsize 100pt x$x$x} - \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\mathsurroundmode#1\relax\hsize 100pt x $x$ x} + \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\hsize 100pt x$\MathHack{#1}x$x} + \NC \dontleavehmode\inframed[align=normal,offset=0pt,frame=off]{\hsize 100pt x $\MathHack{#1}x$ x} \NC #2 \NC \NR} @@ -605,7 +607,7 @@ with zero being the default behaviour. \mathsurroundskip20pt \stopbuffer -\typebuffer \getbuffer +\typebuffer \starttabulate[|c|c|c|pl|] \DB mode \BC x\$x\$x \BC x \$x\$ x \BC effect \NC \NR diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex b/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex index 3f0d0a945..5128f3d2a 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-metapost.tex @@ -448,32 +448,6 @@ id in the range 0 to 255; the returned \type {w} is in AFM units. <number> d = char_depth(mp,<string> fontname, <number> char) \stopfunctioncall -These are rather useless and might become obsolete. - -\subsection{\type {get_[boolean|numeric|string|path]}} - -\libindex{get_boolean} -\libindex{get_numeric} -\libindex{get_path} -\libindex{get_string} - -When a script call brings you from the \METAPOST\ run (temporarily) back to -\LUA\ you can access variables, but only if they are known (so for instance -anonymous capsules like loop variables are not accessible). - -\startfunctioncall -<boolean> w = get_boolean(mp,<string> name) -<number> n = get_numeric(mp,<string> name) -<string> s = get_string (mp,<string> name) -<table> p = get_path (mp,<string> name) -\stopfunctioncall - -The path is returned a a table with subtables that have six numbers: the -coordinates of the point, pre- and postcontrol. A \type {cycle} fields indicates -if a path is cyclic. - -\stopsection - \stopchapter \stopcomponent diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex b/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex index 8b4f6101c..16c6e1202 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-nodes.tex @@ -16,11 +16,11 @@ \TEX's nodes are represented in \LUA\ as userdata objects with a variable set of fields or by a numeric identifier when requested. When you print a node userdata -object you will see these numbers. In the following syntax tables, such as the -type of such a userdata object is represented as \syntax {<node>}. +object you will see these numbers. In the following syntax tables the type of +such a userdata object is represented as \syntax {<node>}. \blank -\dontleavehmode {\bf The return values of \type {node.types()} are:} \showtypes +\dontleavehmode {\bf The return values of \type {node.types} are:} \showtypes \blank In \ETEX\ the \prm {lastnodetype} primitive has been introduced. With this @@ -41,7 +41,7 @@ also reported with this helper, but they are backend specific. \def\ShowValues#1{ \blank \dontleavehmode - {\bf The return values of \type {node.values("#1"} are:} + {\bf The return values of \type {node.values("#1")} are:} \showvalues{#1} \blank } @@ -489,7 +489,7 @@ bits for the \type {subtype} field are: \stoptabulate The \type {expansion_factor} has been introduced as part of the separation -between font- and backend. It is the result of extensive experiments with a more +between front- and backend. It is the result of extensive experiments with a more efficient implementation of expansion. Early versions of \LUATEX\ already replaced multiple instances of fonts in the backend by scaling but contrary to \PDFTEX\ in \LUATEX\ we now also got rid of font copies in the frontend and @@ -1011,7 +1011,7 @@ providing an overview of the possible top|-|level \type {id} types. <table> t = node.types() \stopfunctioncall -when we issue this command, we get a table. The currently visible types are +When we issue this command, we get a table. The currently visible types are \inlineluavalue { node.types() } where the numbers are the internal identifiers. Only those nodes are reported that make sense to users so there can be gaps in the range of numbers. @@ -1031,7 +1031,7 @@ This converts a single type name to its internal numeric representation. The \type {node.id("glyph")} command returns the number \inlineluavalue { node.id ("glyph") } and \type {node.id("hlist")} returns \inlineluavalue { node.id -("hlist") } where the number don't relate to importance or some ordering; they +("hlist") } where the numbers don't relate to importance or some ordering; they just appear in the order that is handy for the engine. Commands like this are rather optimized so performance should be ok but you can of course always store the id in a \LUA\ number. @@ -1056,8 +1056,8 @@ there is no node with that id. \libindex {fields} \libindex {has_field} -This function returns an indexed table with valid field names for a particular type of -node. +This function returns an indexed table with valid field names for a particular +type of node. \startfunctioncall <table> t = node.fields(<number|string> id) @@ -1185,9 +1185,9 @@ affect all the nodes that share that list. node.write(<node> n) \stopfunctioncall -This function that will append a node list to \TEX's \quote {current list}. The -node list is not deep|-|copied! There is no error checking either! You mignt need -to enforce horizontal mode in order for this to work as expected. +This function will append a node list to \TEX's \quote {current list}. The node +list is not deep|-|copied! There is no error checking either! You might need to +enforce horizontal mode in order for this to work as expected. \stopsubsubsection @@ -1199,7 +1199,7 @@ to enforce horizontal mode in order for this to work as expected. \libindex {slide} -This helper makes sure that the node lists is double linked and returns the found +This helper makes sure that the node list is double linked and returns the found tail node. \startfunctioncall @@ -1445,8 +1445,8 @@ experimental) convenience. This helper returns the location of the first match at or after node \type {n}: \startfunctioncall -<node> n = node.traverse_list(<node> n, <integer> subtype) -<node> n, subtype = node.traverse_list(<node> n) +<node> n = node.find_node(<node> n, <integer> subtype) +<node> n, subtype = node.find_node(<node> n) \stopfunctioncall \stopsubsubsection diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex b/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex index 382ed05a4..9e26c6bc4 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex @@ -337,8 +337,6 @@ new primitives, a summary is given below. \NC \type {noboundary} \NC command \NC \NC \NR \NC \type {protrusionboundary} \NC command \NC \NC \NR \NC \type {wordboundary} \NC command \NC \NC \NR -\NC \type {leftghost} \NC charactercode \NC \NC \NR -\NC \type {rightghost} \NC charactercode \NC \NC \NR \NC \type {nohrule} \NC command \NC \NC \NR \NC \type {novrule} \NC command \NC \NC \NR \NC \type {insertht} \NC number \NC \NC \NR diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex b/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex index 839bae409..25f70dd2f 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex @@ -273,7 +273,7 @@ on the actual \TEX\ values. As a result, most of the \LUA\ table operators (like \type {pairs} and \type {#}) do not work on such items. At the moment, it is possible to access almost every parameter that you can use -after \prm {the}, is a single tokens or is sort of special in \TEX. This excludes +after \prm {the}, is a single token or is sort of special in \TEX. This excludes parameters that need extra arguments, like \type {\the\scriptfont}. The subset comprising simple integer and dimension registers are writable as well as readable (like \prm {tracingcommands} and \prm {parindent}). @@ -1133,6 +1133,11 @@ The known fields are: \LL \stoptabulate +When a second string argument is given to the \type {getnest}, the value with +that name is returned. Of course the level must be valid. When \type {setnest} +gets a third argument that value is assigned to the field given as second +argument. + \stopsubsection \startsubsection[reference=sec:luaprint,title={Print functions}] @@ -2171,7 +2176,7 @@ a bit but for passing strings conversion to and from tokens has to be done anywa \stopsubsection -\startsubsection[title= {Picking up one token}] +\startsubsection[title={Picking up one token}] \libindex {get_next} \libindex {scan_token} diff --git a/doc/context/sources/general/manuals/sql/sql-mkiv.tex b/doc/context/sources/general/manuals/sql/sql-mkiv.tex index 4d2ecbc6e..835065ba0 100644 --- a/doc/context/sources/general/manuals/sql/sql-mkiv.tex +++ b/doc/context/sources/general/manuals/sql/sql-mkiv.tex @@ -493,8 +493,8 @@ context --extra=sql-tables --help \startsection[title=Example] -The distribution has a few examples, for instance a logger. The following code shows -a bit of this (we assume that the swiglib sqlite module is present): +The distribution has a few examples, for instance a logger. The following code +shows a bit of this (we assume that \SQLITE\ is installed): \startbuffer require("util-sql") diff --git a/doc/context/sources/general/manuals/svg/svg-lmtx-mozilla.lua b/doc/context/sources/general/manuals/svg/svg-lmtx-mozilla.lua index 0797f6406..802efcf3d 100644 --- a/doc/context/sources/general/manuals/svg/svg-lmtx-mozilla.lua +++ b/doc/context/sources/general/manuals/svg/svg-lmtx-mozilla.lua @@ -351,4 +351,15 @@ return { <path d="M0,5 h-3 M0,7 h3 M0,9 h-1" stroke="rgba(255,0,0,.5)" /> </svg> ]], + [[ + svg viewBox="0 0 120 120" xmlns="http://www.w3.org/2000/svg"> + <path d="M60,15 L60,110 M30,40 L90,40 M30,75 L90,75 M30,110 L90,110" stroke="grey" /> + <text text-anchor="start" x="60" y="40">A</text> + <text text-anchor="middle" x="60" y="75">A</text> + <text text-anchor="end" x="60" y="110">A</text> + <circle cx="60" cy="40" r="3" fill="red" /> + <circle cx="60" cy="75" r="3" fill="red" /> + <circle cx="60" cy="110" r="3" fill="red" /> + </svg> + ]], } |