From d6dece4edc2ef86889f99f3dbe5a6d6ed3b68b02 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 5 Jul 2018 23:56:28 +0200 Subject: 2018-07-05 23:13:00 --- doc/context/documents/general/manuals/luatex.pdf | Bin 1389428 -> 1507388 bytes doc/context/documents/general/qrcs/setup-cs.pdf | Bin 840839 -> 840986 bytes doc/context/documents/general/qrcs/setup-de.pdf | Bin 840042 -> 840177 bytes doc/context/documents/general/qrcs/setup-en.pdf | Bin 844592 -> 844730 bytes doc/context/documents/general/qrcs/setup-fr.pdf | Bin 839047 -> 839194 bytes doc/context/documents/general/qrcs/setup-it.pdf | Bin 842292 -> 842444 bytes .../documents/general/qrcs/setup-mapping-cs.pdf | Bin 345550 -> 345688 bytes .../documents/general/qrcs/setup-mapping-de.pdf | Bin 428717 -> 428867 bytes .../documents/general/qrcs/setup-mapping-en.pdf | Bin 343065 -> 343204 bytes .../documents/general/qrcs/setup-mapping-fr.pdf | Bin 345593 -> 345742 bytes .../documents/general/qrcs/setup-mapping-it.pdf | Bin 344247 -> 344406 bytes .../documents/general/qrcs/setup-mapping-nl.pdf | Bin 343329 -> 343476 bytes .../documents/general/qrcs/setup-mapping-ro.pdf | Bin 598014 -> 598160 bytes doc/context/documents/general/qrcs/setup-nl.pdf | Bin 835221 -> 835241 bytes doc/context/documents/general/qrcs/setup-ro.pdf | Bin 837567 -> 837706 bytes .../general/manuals/luatex/luatex-languages.tex | 79 +- .../general/manuals/luatex/luatex-nodes.tex | 943 ++++++++++++++------- .../general/manuals/luatex/luatex-registers.tex | 9 + .../general/manuals/luatex/luatex-style.tex | 23 + metapost/context/base/mpiv/mp-node.mpiv | 6 +- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-nl.mkii | 2 + tex/context/base/mkii/mult-pe.mkii | 2 + tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/font-ocl.lua | 12 +- tex/context/base/mkiv/font-shp.lua | 2 +- tex/context/base/mkiv/font-ttf.lua | 5 +- tex/context/base/mkiv/lpdf-ini.lua | 2 +- tex/context/base/mkiv/lpdf-tag.lua | 161 ++-- tex/context/base/mkiv/lpdf-wid.lua | 4 +- tex/context/base/mkiv/meta-nod.lua | 29 + tex/context/base/mkiv/meta-nod.mkiv | 27 +- tex/context/base/mkiv/mlib-pps.lua | 1 + tex/context/base/mkiv/mlib-run.lua | 3 +- tex/context/base/mkiv/status-files.pdf | Bin 26009 -> 26006 bytes tex/context/base/mkiv/status-lua.pdf | Bin 261982 -> 262508 bytes tex/context/base/mkiv/strc-tag.mkiv | 15 +- tex/context/base/mkiv/typo-dir.mkiv | 2 +- tex/context/interface/mkii/keys-nl.xml | 2 + tex/context/interface/mkii/keys-pe.xml | 2 + tex/context/interface/mkiv/i-context.pdf | Bin 844592 -> 844730 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 61063 -> 61061 bytes 44 files changed, 913 insertions(+), 426 deletions(-) create mode 100644 tex/context/base/mkiv/meta-nod.lua diff --git a/doc/context/documents/general/manuals/luatex.pdf b/doc/context/documents/general/manuals/luatex.pdf index 748da314f..d24fd65c0 100644 Binary files a/doc/context/documents/general/manuals/luatex.pdf and b/doc/context/documents/general/manuals/luatex.pdf differ diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf index 1e199a3aa..85a803a53 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 f05271107..94231ea0d 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 1710e750c..c0cfd1900 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 0ed1fcbf7..123d2c510 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 5fadc1963..02a68bb40 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 4391f3a64..ffaf5d675 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 b105a33b8..d3e165ce0 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 171af0d45..06a617a8e 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 4a7d5d62c..8d1c9fb59 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 c4c3a9b80..f98c14e03 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 fa3965cce..49279d9ef 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 c44f6b6e9..1a0d75b6a 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 e39b64c0f..151503a08 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 d37c9f239..70649f3d0 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/manuals/luatex/luatex-languages.tex b/doc/context/sources/general/manuals/luatex/luatex-languages.tex index 6ec75e375..d4a7bda60 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-languages.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-languages.tex @@ -6,7 +6,7 @@ \startchapter[reference=languages,title={Languages, characters, fonts and glyphs}] -\section {Introduction} +\startsection[title={Introduction}] \topicindex {languages} @@ -51,7 +51,9 @@ font information in the whole list (creating ligatures and adjusting kerning), and finally it adjusts all the subtype identifiers so that the records are \quote {glyph nodes} from now on. -\section[charsandglyphs]{Characters, glyphs and discretionaries} +\stopsection + +\startsection[title={Characters, glyphs and discretionaries},reference=charsandglyphs] \topicindex {characters} \topicindex {glyphs} @@ -390,7 +392,9 @@ command has a more verbose primitive version in \lpr {explicitdiscretionary} and the normally intercepted in the hyphenator character \type {-} (or whatever is configured) is available as \lpr {automaticdiscretionary}. -\section{The main control loop} +\stopsection + +\startsection[title={The main control loop}] \topicindex {main loop} \topicindex {hyphenation} @@ -526,7 +530,9 @@ resulting from an \prm {exhyphenchar}: other values do what we always did in \LUATEX: insert \prm {exhyphenpenalty}. -\section[patternsexceptions]{Loading patterns and exceptions} +\stopsection + +\startsection[title={Loading patterns and exceptions},reference=patternsexceptions] \topicindex {hyphenation} \topicindex {hyphenation+patterns} @@ -644,7 +650,9 @@ effectively we get 30000 in the example. \ShowSample{z{a-}{-b}{z}{a-}{-b}{z}{a-}{-b}{z}{a-}{-b}{z}z}{zzzzzz} \ShowSample{z{a-}{-b}{z}{a-}{-b}{z}[3]{a-}{-b}{z}[1]{a-}{-b}{z}z}{zzzzzz} -\section{Applying hyphenation} +\stopsection + +\startsection[title={Applying hyphenation}] \topicindex {hyphenation+how it works} \topicindex {hyphenation+discretionaries} @@ -750,7 +758,9 @@ that this function expects to receive a list of \quote {character} nodes. It wil not operate properly in the presence of \quote {glyph}, \quote {ligature}, or \quote {ghost} nodes, nor does it know how to deal with kerning. -\section{Applying ligatures and kerning} +\stopsection + +\startsection[title={Applying ligatures and kerning}] \topicindex {ligatures} \topicindex {kerning} @@ -889,7 +899,9 @@ mapping a sequence of glyphs onto one glyph, but also by selective replacement a kerning. This means that the above examples are just representing the traditional approach. -\section{Breaking paragraphs into lines} +\stopsection + +\startsection[title={Breaking paragraphs into lines}] \topicindex {linebreaks} \topicindex {paragraphs} @@ -915,12 +927,17 @@ The combined effect of these two differences is that \LUATEX\ does not always us all of the potential breakpoints in a paragraph, especially when fonts with many ligatures are used. Of course kerning also complicates matters here. -\section{The \type {lang} library} +\stopsection -\subsection {\type {lang.new} and \type {lang.id}} +\startsection[title={The \type {lang} library}][library=lang] + +\subsection {\type {new} and \type {id}} \topicindex {languages+library} +\libindex {new} +\libindex {id} + This library provides the interface to \LUATEX's structure representing a language, and the associated functions. @@ -942,7 +959,9 @@ the internal language with that id number. The number returned is the internal \prm {language} id number this object refers to. -\subsection {\type {lang.hyphenation}} +\subsection {\type {hyphenation}} + +\libindex {hyphenation} You can hyphenate a string directly with: @@ -951,7 +970,10 @@ You can hyphenate a string directly with: lang.hyphenation( l, n) \stopfunctioncall -\subsection {\type {lang.clear_hyphenation} and \type {lang.clean}} +\subsection {\type {clear_hyphenation} and \type {clean}} + +\libindex {clear_hyphenation} +\libindex {clean} This either returns the current hyphenation exceptions for this language, or adds new ones. The syntax of the string is explained in~\in {section} @@ -973,7 +995,10 @@ syntax of the argument string is explained in \in {section} [patternsexceptions] This function is useful if you want to do something else based on the words in a dictionary file, like spell|-|checking. -\subsection {\type {lang.patterns} and \type {lang.clear_patterns}} +\subsection {\type {patterns} and \type {clear_patterns}} + +\libindex {patterns} +\libindex {clear_patterns} \startfunctioncall n = lang.patterns( l) @@ -990,7 +1015,24 @@ lang.clear_patterns( l) This can be used to clear the pattern dictionary for a language. -\subsection {\type {lang.[pre|post]hyphenchar}} +\subsection {\type {hyphenationmin}} + +\libindex {hyphenationmin} + +This function sets (or gets) the value of the \TEX\ parameter +\type {\hyphenationmin}. + +\startfunctioncall +n = lang.hyphenationmin( l) +lang.hyphenationmin( l, n) +\stopfunctioncall + +\subsection {\type {[pre|post][ex|]hyphenchar}} + +\libindex {prehyphenchar} +\libindex {posthyphenchar} +\libindex {preexhyphenchar} +\libindex {postexhyphenchar} \startfunctioncall n = lang.prehyphenchar( l) @@ -1016,7 +1058,9 @@ These gets or set the \quote {pre|-|break} and \quote {post|-|break} hyphen characters for explicit hyphenation in this language. Both are initially decimal~0 (indicating emptiness). -\subsection {\type {lang.hyphenate}} +\subsection {\type {hyphenate}} + +\libindex {hyphenate} The next call inserts hyphenation points (discretionary nodes) in a node list. If \type {tail} is given as argument, processing stops on that node. Currently, @@ -1033,7 +1077,10 @@ nodes with the node subtype having the value \type {1}. Glyph modes with different subtypes are not processed. See \in {section} [charsandglyphs] for more details. -\subsection {\type {lang.[set|get]hjcode}} +\subsection {\type {[set|get]hjcode}} + +\libindex {sethjcode} +\libindex {gethjcode} The following two commands can be used to set or query hj codes: @@ -1045,6 +1092,8 @@ lang.sethjcode( l, char, usedchar) When you set a hjcode the current sets get initialized unless the set was already initialized due to \prm {savinghyphcodes} being larger than zero. +\stopsection + \stopchapter \stopcomponent diff --git a/doc/context/sources/general/manuals/luatex/luatex-nodes.tex b/doc/context/sources/general/manuals/luatex/luatex-nodes.tex index a34008a1c..07f99ba00 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-nodes.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-nodes.tex @@ -6,10 +6,14 @@ \startchapter[reference=nodes,title={Nodes}] -\section{\LUA\ node representation} +\startsection[title={\LUA\ node representation}][library=node] \topicindex {nodes} +\libindex {fields} +\libindex {subtypes} +\libindex {values} + \TEX's nodes are represented in \LUA\ as userdata objects with a variable set of fields. In the following syntax tables, such as the type of such a userdata object is represented as \syntax {}. @@ -32,17 +36,17 @@ names as in traditional \ETEX. Keep in mind that these \ETEX\ node numbers are different from the real internal ones and that there are more \ETEX\ node types than~15. -You can ask for a list of fields with the \type {node.fields} and for valid -subtypes with \type {node.subtypes}. +You can ask for a list of fields with \type {node.fields} and for valid subtypes +with \type {node.subtypes}. The \type {node.values} function reports some used +values. Valid arguments are \nod {dir}, \type {direction}, \nod {glue}, \whs +{pdf_literal}, \whs {pdf_action}, \whs {pdf_window} and \whs {color_stack}. Keep +in mind that the setters normally expect a number, but this helper gives you a +list of what numbers matter. For practical reason the \type {pagestate} values +are also reported with this helper. -The \type {node.values} function reports some used values. Valid arguments are -\nod {dir}, \type {direction}, \nod {glue}, \whs {pdf_literal}, \whs -{pdf_action}, \whs {pdf_window} and \whs {color_stack}. Keep in mind that the -setters normally expect a number, but this helper gives you a list of what -numbers matter. For practical reason the \type {pagestate} values are also -reported with this helper. +\stopsection -\section{Main text nodes} +\startsection[title={Main text nodes}] \topicindex {nodes+text} @@ -552,7 +556,9 @@ Margin kerns result from protrusion. \LL \stoptabulate -\section{Math noads} +\stopsection + +\startsection[title={Math noads}] \topicindex {nodes+math} \topicindex {math+nodes} @@ -769,10 +775,12 @@ can result. Warning: some of these fields are used by the renderer and might get adapted in the process. -\section{whatsit nodes} +\stopsection + +\startsection[title={Front|-|end whatsits}] Whatsit nodes come in many subtypes that you can ask for them by running -\type {node.whatsits()}: +\type {node.whatsits}: \startluacode for id, name in table.sortedpairs(node.whatsits()) do context.type(name) @@ -783,7 +791,9 @@ Whatsit nodes come in many subtypes that you can ask for them by running \stopluacode . % period -\section{Front|-|end whatsits} +Some of them are generic and independent of the output mode and others are +specific to the chosen backend: \DVI\ or \PDF. Here we discuss the generic +font|-|end nodes nodes. \subsection{\whs {open}} @@ -879,7 +889,9 @@ The difference between \type {data} and \type {string} is that on assignment, th \type {data} field is converted to a token list, cf.\ use as \lpr {latelua}. The \type {string} version is treated as a literal string. -\section{\DVI\ backend whatsits} +\stopsection + +\startsection[title={\DVI\ backend whatsits}] \subsection{\whs {special}} @@ -894,7 +906,9 @@ output file. \LL \stoptabulate -\section{\PDF\ backend whatsits} +\stopsection + +\startsection[title={\PDF\ backend whatsits}] \subsection{\whs {pdf_literal}} @@ -1111,7 +1125,9 @@ Valid window types are: \LL \stoptabulate -\section{The \type {node} library} +\stopsection + +\startsection[title={The \type {node} library}][library=node] \subsection {Introduction} @@ -1171,10 +1187,12 @@ and getters handle this for you. There are statistics available with regards to the allocated node memory, which can be handy for tracing. -\subsection{\type {node.is_node}} +\subsection{\type {is_node}} \topicindex {nodes+functions} +\libindex {is_node} + \startfunctioncall t = node.is_node( item) @@ -1183,59 +1201,70 @@ can be handy for tracing. This function returns a number (the internal index of the node) if the argument is a userdata object of type \type {} and false when no node is passed. -\subsection{\type {node.types}} +\subsection{\type {types} and \type {whatsits}} + +\libindex {types} +\libindex {whatsits} + +This function returns an array that maps node id numbers to node type strings, +providing an overview of the possible top|-|level \type {id} types. \startfunctioncall t = node.types() \stopfunctioncall -This function returns an array that maps node id numbers to node type strings, -providing an overview of the possible top|-|level \type {id} types. - -\subsection{\type {node.whatsits}} +\TEX's \quote {whatsits} all have the same \type {id}. The various subtypes are +defined by their \type {subtype} fields. The function is much like \type {types}, +except that it provides an array of \type {subtype} mappings. \startfunctioncall
t = node.whatsits() \stopfunctioncall -\TEX's \quote {whatsits} all have the same \type {id}. The various subtypes are -defined by their \type {subtype} fields. The function is much like \type -{node.types}, except that it provides an array of \type {subtype} mappings. +\subsection{\type {id}} + +\libindex{id} -\subsection{\type {node.id}} +This converts a single type name to its internal numeric representation. \startfunctioncall id = node.id( type) \stopfunctioncall -This converts a single type name to its internal numeric representation. +\subsection{\type {type} and \type {subtype}} -\subsection{\type {node.subtype}} +\libindex {type} +\libindex {subtype} + +In the argument is a number, then the next function converts an internal numeric +representation to an external string representation. Otherwise, it will return +the string \type {node} if the object represents a node, and \type {nil} +otherwise. \startfunctioncall - subtype = - node.subtype( type) + type = + node.type( n) \stopfunctioncall -This converts a single whatsit name to its internal numeric representation (\type -{subtype}). - -\subsection{\type {node.type}} +This next one converts a single whatsit name to its internal numeric +representation (\type {subtype}). \startfunctioncall - type = - node.type( n) + subtype = + node.subtype( type) \stopfunctioncall -In the argument is a number, then this function converts an internal numeric -representation to an external string representation. Otherwise, it will return -the string \type {node} if the object represents a node, and \type {nil} -otherwise. +\subsection{\type {fields}} + +\libindex {fields} -\subsection{\type {node.fields}} +This function returns an array of valid field names for a particular type of +node. If you want to get the valid fields for a \quote {whatsit}, you have to +supply the second argument also. In other cases, any given second argument will +be silently ignored. \startfunctioncall
t = @@ -1244,24 +1273,29 @@ otherwise. node.fields( id, subtype) \stopfunctioncall -This function returns an array of valid field names for a particular type of -node. If you want to get the valid fields for a \quote {whatsit}, you have to -supply the second argument also. In other cases, any given second argument will -be silently ignored. +The function accepts string \type {id} and \type {subtype} values as well. + +\subsection{\type {has_field}} -This function accepts string \type {id} and \type {subtype} values as well. +\libindex {has_field} -\subsection{\type {node.has_field}} +This function returns a boolean that is only true if \type {n} is +actually a node, and it has the field. \startfunctioncall t = node.has_field( n, field) \stopfunctioncall -This function returns a boolean that is only true if \type {n} is -actually a node, and it has the field. +\subsection{\type {new}} + +\libindex{new} -\subsection{\type {node.new}} +The \type {new} function creates a new node. All its fields are initialized to +either zero or \type {nil} except for \type {id} and \type {subtype}. Instead of +numbers you can also use strings (names). If you create a new \nod {whatsit} node +the second argument is required. As with all node functions, this function +creates a node at the \TEX\ level. \startfunctioncall n = @@ -1270,13 +1304,16 @@ actually a node, and it has the field. node.new( id, subtype) \stopfunctioncall -The \type {new} function creates a new node. All its fields are initialized to -either zero or \type {nil} except for \type {id} and \type {subtype}. Instead of -numbers you can also use strings (names). If you create a new \nod {whatsit} node -the second argument is required. As with all node functions, this function -creates a node at the \TEX\ level. +\subsection{\type {free}, \type {flush_node} and \type {flush_list}} + +\libindex{free} +\libindex{flush_node} +\libindex{flush_list} -\subsection{\type {node.free} and \type {node.flush_node}} +The next one the node \type {n} from \TEX's memory. Be careful: no checks are +done on whether this node is still pointed to from a register or some \type +{next} field: it is up to you to make sure that the internal data structures +remain correct. \startfunctioncall next = @@ -1284,35 +1321,33 @@ creates a node at the \TEX\ level. flush_node( n) \stopfunctioncall -Removes the node \type {n} from \TEX's memory. Be careful: no checks are done on -whether this node is still pointed to from a register or some \type {next} field: -it is up to you to make sure that the internal data structures remain correct. - The \type {free} function returns the next field of the freed node, while the \type {flush_node} alternative returns nothing. -\subsection{\type {node.flush_list}} +A list starting with node \type {n} can be flushed from \TEX's memory too. Be +careful: no checks are done on whether any of these nodes is still pointed to +from a register or some \type {next} field: it is up to you to make sure that the +internal data structures remain correct. \startfunctioncall node.flush_list( n) \stopfunctioncall -Removes the node list \type {n} and the complete node list following \type {n} -from \TEX's memory. Be careful: no checks are done on whether any of these nodes -is still pointed to from a register or some \type {next} field: it is up to you -to make sure that the internal data structures remain correct. +\subsection{\type {copy} and \type {copy_list}} + +\libindex{copy} +\libindex{copy_list} -\subsection{\type {node.copy}} +This creates a deep copy of node \type {n}, including all nested lists as in the case +of a hlist or vlist node. Only the \type {next} field is not copied. \startfunctioncall m = node.copy( n) \stopfunctioncall -Creates a deep copy of node \type {n}, including all nested lists as in the case -of a hlist or vlist node. Only the \type {next} field is not copied. - -\subsection{\type {node.copy_list}} +A deep copy of the node list that starts at \type {n} can be created too. If +\type {m} is also given, the copy stops just before node \type {m}. \startfunctioncall m = @@ -1321,42 +1356,37 @@ of a hlist or vlist node. Only the \type {next} field is not copied. node.copy_list( n, m) \stopfunctioncall -Creates a deep copy of the node list that starts at \type {n}. If \type {m} is -also given, the copy stops just before node \type {m}. +Note that you cannot copy attribute lists this way. However, there is normally no +need to copy attribute lists as when you do assignments to the \type {attr} field +or make changes to specific attributes, the needed copying and freeing takes +place automatically. -Note that you cannot copy attribute lists this way, specialized functions for -dealing with attribute lists will be provided later but are not there yet. -However, there is normally no need to copy attribute lists as when you do -assignments to the \type {attr} field or make changes to specific attributes, the -needed copying and freeing takes place automatically. +\subsection{\type {prev} and \type{next}} -\subsection{\type {node.next}} +\libindex{prev} +\libindex{next} + +These returns the node preceding or following the given node, or \type {nil} if +there is no such node. \startfunctioncall m = node.next( n) -\stopfunctioncall - -Returns the node following this node, or \type {nil} if there is no such node. - -\subsection{\type {node.prev}} - -\startfunctioncall m = node.prev( n) \stopfunctioncall -Returns the node preceding this node, or \type {nil} if there is no such node. +\subsection{\type {current_attr}} + +\libindex{current_attr} -\subsection{\type {node.current_attr}} +This returns the currently active list of attributes, if there is one. \startfunctioncall m = node.current_attr() \stopfunctioncall -Returns the currently active list of attributes, if there is one. - The intended usage of \type {current_attr} is as follows: \starttyping @@ -1386,7 +1416,16 @@ attribute list, not a copy thereof. Therefore, changing any of the attributes in the list will change these values for all nodes that have the current attribute list assigned to them. -\subsection{\type {node.hpack}} +\subsection{\type {hpack}} + +\libindex {hpack} + +This function creates a new hlist by packaging the list that begins at node \type +{n} into a horizontal box. With only a single argument, this box is created using +the natural width of its components. In the three argument form, \type {info} +must be either \type {additional} or \type {exactly}, and \type {w} is the +additional (\type {\hbox spread}) or exact (\type {\hbox to}) width to be used. +The second return value is the badness of the generated box. \startfunctioncall h, b = @@ -1397,21 +1436,22 @@ list assigned to them. node.hpack( n, w, info, dir) \stopfunctioncall -This function creates a new hlist by packaging the list that begins at node \type -{n} into a horizontal box. With only a single argument, this box is created using -the natural width of its components. In the three argument form, \type {info} -must be either \type {additional} or \type {exactly}, and \type {w} is the -additional (\type {\hbox spread}) or exact (\type {\hbox to}) width to be used. -The second return value is the badness of the generated box. +Caveat: there can be unexpected side|-|effects to this function, like updating +some of the \prm {marks} and \type {\inserts}. Also note that the content of +\type {h} is the original node list \type {n}: if you call \type {node.free(h)} +you will also free the node list itself, unless you explicitly set the \type +{list} field to \type {nil} beforehand. And in a similar way, calling \type +{node.free(n)} will invalidate \type {h} as well! + +\subsection{\type {vpack}} -Caveat: at this moment, there can be unexpected side|-|effects to this function, -like updating some of the \prm {marks} and \type {\inserts}. Also note that the -content of \type {h} is the original node list \type {n}: if you call \type -{node.free(h)} you will also free the node list itself, unless you explicitly set -the \type {list} field to \type {nil} beforehand. And in a similar way, calling -\type {node.free(n)} will invalidate \type {h} as well! +\libindex {vpack} -\subsection{\type {node.vpack}} +This function creates a new vlist by packaging the list that begins at node \type +{n} into a vertical box. With only a single argument, this box is created using +the natural height of its components. In the three argument form, \type {info} +must be either \type {additional} or \type {exactly}, and \type {w} is the +additional (\type {\vbox spread}) or exact (\type {\vbox to}) height to be used. \startfunctioncall h, b = @@ -1422,17 +1462,26 @@ the \type {list} field to \type {nil} beforehand. And in a similar way, calling node.vpack( n, w, info, dir) \stopfunctioncall -This function creates a new vlist by packaging the list that begins at node \type -{n} into a vertical box. With only a single argument, this box is created using -the natural height of its components. In the three argument form, \type {info} -must be either \type {additional} or \type {exactly}, and \type {w} is the -additional (\type {\vbox spread}) or exact (\type {\vbox to}) height to be used. +The second return value is the badness of the generated box. See the description +of \type {hpack} for a few memory allocation caveats. -The second return value is the badness of the generated box. +\subsection{\type {prepend_prevdepth}} -See the description of \type {node.hpack()} for a few memory allocation caveats. +\libindex {prepend_prevdepth} -\subsection{\type {node.dimensions}, \type {node.rangedimensions}} +This function is somewhat special in the sense that it is an experimental helper +that adds the interlinespace to a line keeping the baselineskip and lineskip into +account. + +\startfunctioncall + n, delta = + node.prepend_prevdepth( n, prevdepth) +\stopfunctioncall + +\subsection{\type {dimensions} and \type {rangedimensions}} + +\libindex{dimensions} +\libindex{rangedimensions} \startfunctioncall w, h, d = @@ -1497,7 +1546,9 @@ cases: node.rangedimensions( parent, first, last) \stopfunctioncall -\subsection{\type {node.mlist_to_hlist}} +\subsection{\type {mlist_to_hlist}} + +\libindex {mlist_to_hlist} \startfunctioncall h = @@ -1508,7 +1559,7 @@ This runs the internal mlist to hlist conversion, converting the math list in \type {n} into the horizontal list \type {h}. The interface is exactly the same as for the callback \cbk {mlist_to_hlist}. -\subsection{\type {node.slide}} +\subsection{\type {slide}} \startfunctioncall m = @@ -1519,7 +1570,9 @@ Returns the last node of the node list that starts at \type {n}. As a side|-|effect, it also creates a reverse chain of \type {prev} pointers between nodes. -\subsection{\type {node.tail}} +\subsection{\type {tail}} + +\libindex {tail} \startfunctioncall m = @@ -1528,7 +1581,10 @@ nodes. Returns the last node of the node list that starts at \type {n}. -\subsection{\type {node.length}} +\subsection{\type {length} and type {count}} + +\libindex {length} +\libindex {count} \startfunctioncall i = @@ -1541,8 +1597,6 @@ Returns the number of nodes contained in the node list that starts at \type {n}. If \type {m} is also supplied it stops at \type {m} instead of at the end of the list. The node \type {m} is not counted. -\subsection{\type {node.count}} - \startfunctioncall i = node.count( id, n) @@ -1553,11 +1607,26 @@ list. The node \type {m} is not counted. Returns the number of nodes contained in the node list that starts at \type {n} that have a matching \type {id} field. If \type {m} is also supplied, counting stops at \type {m} instead of at the end of the list. The node \type {m} is not -counted. +counted. This function also accept string \type {id}'s. + +\subsection{\type {is_char} and \type {is_glyph}} + +\libindex {is_char} +\libindex {is_glyph} + +The subtype of a glyph node signals if the glyph is already turned into a character reference +or not. + +\startfunctioncall + b = + node.is_char( n) + b = + node.is_glyph( n) +\stopfunctioncall -This function also accept string \type {id}'s. +\subsection{\type {traverse}} -\subsection{\type {node.traverse}} +\libindex {traverse} \startfunctioncall t, id, subtype = @@ -1603,7 +1672,9 @@ pointers remain valid. If the above is unclear to you, see the section \quote {For Statement} in the \LUA\ Reference Manual. -\subsection{\type {node.traverse_id}} +\subsection{\type {traverse_id}} + +\libindex {traverse_id} \startfunctioncall t, subtype = @@ -1631,26 +1702,30 @@ See the previous section for details. The change is in the local function \type end \stoptyping -\subsection{\type {node.traverse_char}} +\subsection{\type {traverse_char} and \type {traverse_glyph}} + +\libindex {traverse_char} +\libindex {traverse_glyph} -This iterator loops over the \nod {glyph} nodes in a list. Only nodes with a -subtype less than 256 are seen. +The \type{traverse_char} iterator loops over the \nod {glyph} nodes in a list. +Only nodes with a subtype less than 256 are seen. \startfunctioncall n, font, char = node.traverse_char( n) \stopfunctioncall -\subsection{\type {node.traverse_glyph}} - -This iterator loops over a list and returns the list and filters all glyphs: +The \type{traverse_glyph} iterator loops over a list and returns the list and +filters all glyphs: \startfunctioncall n, font, char = node.traverse_glyph( n) \stopfunctioncall -\subsection{\type {node.traverse_list}} +\subsection{\type {traverse_list}} + +\libindex {traverse_list} This iterator loops over the \nod {hlist} and \nod {vlist} nodes in a list. @@ -1663,7 +1738,9 @@ The four return values can save some time compared to fetching these fields but in practice you seldom need them all. So consider it a (side effect of experimental) convenience. -\subsection{\type {node.has_glyph}} +\subsection{\type {has_glyph}} + +\libindex {has_glyph} This function returns the first glyph or disc node in the given list: @@ -1672,7 +1749,9 @@ This function returns the first glyph or disc node in the given list: node.has_glyph( n) \stopfunctioncall -\subsection{\type {node.end_of_math}} +\subsection{\type {end_of_math}} + +\libindex {end_of_math} \startfunctioncall t = @@ -1684,7 +1763,9 @@ the given node is a math end node this helper returns that node, else it follows the list and returns the next math endnote. If no such node is found nil is returned. -\subsection{\type {node.remove}} +\subsection{\type {remove}} + +\libindex {remove} \startfunctioncall head, current = @@ -1700,7 +1781,9 @@ no such node). The returned \type {head} is more important, because if the function is called with \type {current} equal to \type {head}, it will be changed. -\subsection{\type {node.insert_before}} +\subsection{\type {insert_before}} + +\libindex {insert_before} \startfunctioncall head, new = @@ -1714,7 +1797,9 @@ mutated) \type {head} and the node \type {new}, set up to be part of the list (with correct \type {next} field). If \type {head} is initially \type {nil}, it will become \type {new}. -\subsection{\type {node.insert_after}} +\subsection{\type {insert_after}} + +\libindex {insert_after} \startfunctioncall head, new = @@ -1727,7 +1812,9 @@ following \type {head}. It is your responsibility to make sure that \type the node \type {new}, set up to be part of the list (with correct \type {next} field). If \type {head} is initially \type {nil}, it will become \type {new}. -\subsection{\type {node.first_glyph}} +\subsection{\type {first_glyph}} + +\libindex {first_glyph} \startfunctioncall n = @@ -1741,7 +1828,9 @@ with a subtype indicating it is a glyph, or \type {nil}. If \type {m} is given, processing stops at (but including) that node, otherwise processing stops at the end of the list. -\subsection{\type {node.ligaturing}} +\subsection{\type {ligaturing}} + +\libindex {ligaturing} \startfunctioncall h, t, success = @@ -1754,7 +1843,9 @@ Apply \TEX-style ligaturing to the specified nodelist. The tail node \type {m} i optional. The two returned nodes \type {h} and \type {t} are the new head and tail (both \type {n} and \type {m} can change into a new ligature). -\subsection{\type {node.kerning}} +\subsection{\type {kerning}} + +\libindex {kerning} \startfunctioncall h, t, success = @@ -1768,7 +1859,10 @@ optional. The two returned nodes \type {h} and \type {t} are the head and tail (either one of these can be an inserted kern node, because special kernings with word boundaries are possible). -\subsection{\type {node.unprotect_glyphs} and \type {node.unprotect_glyph}} +\subsection{\type {unprotect_glyph[s]}} + +\libindex {unprotect_glyphs} +\libindex {unprotect_glyph} \startfunctioncall node.unprotect_glyph( n) @@ -1779,7 +1873,10 @@ Subtracts 256 from all glyph node subtypes. This and the next function are helpers to convert from \type {characters} to \type {glyphs} during node processing. The second argument is optional and indicates the end of a range. -\subsection{\type {node.protect_glyphs} and \type {node.protect_glyph}} +\subsection{\type {protect_glyph[s]}} + +\libindex {protect_glyphs} +\libindex {protect_glyph} \startfunctioncall node.protect_glyph( n) @@ -1792,7 +1889,9 @@ that \type {characters} will become \type {glyphs} after subtraction of 256. A single character can be marked by the singular call. The second argument is optional and indicates the end of a range. -\subsection{\type {node.last_node}} +\subsection{\type {last_node}} + +\libindex {last_node} \startfunctioncall n = @@ -1802,7 +1901,9 @@ optional and indicates the end of a range. This function pops the last node from \TEX's \quote{current list}. It returns that node, or \type {nil} if the current list is empty. -\subsection{\type {node.write}} +\subsection{\type {write}} + +\libindex {write} \startfunctioncall node.write( n) @@ -1812,7 +1913,9 @@ 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. -\subsection{\type {node.protrusion_skippable}} +\subsection{\type {protrusion_skippable}} + +\libindex {protrusion_skippable} \startfunctioncall skippable = @@ -1822,9 +1925,13 @@ to enforce horizontal mode in order for this to work as expected. Returns \type {true} if, for the purpose of line boundary discovery when character protrusion is active, this node can be skipped. -\section{Glue handling} +\stopsection -\subsection{\type {node.setglue}} +\startsection[title={Glue handling}][library=node] + +\subsection{\type {setglue}} + +\libindex {setglue} You can set the properties of a glue in one go. If you pass no values, the glue will become a zero glue. @@ -1844,7 +1951,9 @@ will only adapt the width and shrink. When a list node is passed, you set the glue, order and sign instead. -\subsection{\type {node.getglue}} +\subsection{\type {getglue}} + +\libindex {getglue} The next call will return 5 values or nothing when no glue is passed. @@ -1859,7 +1968,9 @@ with \type {tex.get}). When a list node is passed, you get back the glue that is set, the order of that glue and the sign. -\subsection{\type {node.is_zero_glue}} +\subsection{\type {is_zero_glue}} + +\libindex {is_zero_glue} This function returns \type {true} when the width, stretch and shrink properties are zero. @@ -1869,7 +1980,9 @@ are zero. node.is_zero_glue( n) \stopfunctioncall -\section{Attribute handling} +\stopsection + +\startsection[title={Attribute handling}][library=node] \subsection{Attributes} @@ -1885,7 +1998,7 @@ Attributes appear as linked list of userdata objects in the \type {attr} field o individual nodes. They can be handled individually, but it is much safer and more efficient to use the dedicated functions associated with them. -\subsection{attribute_list nodes} +\subsection{\nod {attribute_list} nodes} \topicindex {nodes+attributes} @@ -1919,7 +2032,9 @@ As mentioned it's better to use the official helpers rather than edit these fields directly. For instance the \type {prev} field is used for other purposes and there is no double linked list. -\subsection{\type {node.has_attribute}} +\subsection{\type {has_attribute}} + +\libindex {has_attribute} \startfunctioncall v = @@ -1932,7 +2047,9 @@ Tests if a node has the attribute with number \type {id} set. If \type {val} is also supplied, also tests if the value matches \type {val}. It returns the value, or, if no match is found, \type {nil}. -\subsection{\type {node.get_attribute}} +\subsection{\type {get_attribute}} + +\libindex {get_attribute} \startfunctioncall v = @@ -1943,7 +2060,9 @@ Tests if a node has an attribute with number \type {id} set. It returns the value, or, if no match is found, \type {nil}. If no \type {id} is given then the zero attributes is assumed. -\subsection{\type {node.find_attribute}} +\subsection{\type {find_attribute}} + +\libindex {find_attribute} \startfunctioncall v, n = @@ -1953,7 +2072,9 @@ zero attributes is assumed. Finds the first node that has attribute with number \type {id} set. It returns the value and the node if there is a match and otherwise nothing. -\subsection{\type {node.set_attribute}} +\subsection{\type {set_attribute}} + +\libindex {set_attribute} \startfunctioncall node.set_attribute( n, id, val) @@ -1962,7 +2083,9 @@ node.set_attribute( n, id, val) Sets the attribute with number \type {id} to the value \type {val}. Duplicate assignments are ignored. -\subsection{\type {node.unset_attribute}} +\subsection{\type {unset_attribute}} + +\libindex {unset_attribute} \startfunctioncall v = @@ -1978,7 +2101,9 @@ attributes or attribute|-|value pairs are ignored. If the attribute was actually deleted, returns its old value. Otherwise, returns \type {nil}. -\subsection{\type {node.slide}} +\subsection{\type {slide}} + +\libindex {slide} This helper makes sure that the node lists is double linked and returns the found tail node. @@ -1995,13 +2120,16 @@ pointers but your other callbacks might expect proper \type {prev} pointers too. Future versions of \LUATEX\ can add more checking but this will not influence usage. -\subsection{\type {node.check_discretionary} and \type {node.check_discretionaries}} +\subsection{\type {check_discretionary}, \type {check_discretionaries}} + +\libindex{check_discretionary} +\libindex{check_discretionaries} When you fool around with disc nodes you need to be aware of the fact that they have a special internal data structure. As long as you reassign the fields when you have extended the lists it's ok because then the tail pointers get updated, but when you add to list without reassigning you might end up in trouble when -the linebreak routien kicks in. You can call this function to check the list for +the linebreak routine kicks in. You can call this function to check the list for issues with disc nodes. \startfunctioncall @@ -2012,7 +2140,9 @@ node.check_discretionaries( head) The plural variant runs over all disc nodes in a list, the singular variant checks one node only (it also checks if the node is a disc node). -\subsection{\type {node.flatten_discretionaries}} +\subsection{\type {flatten_discretionaries}} + +\libindex {flatten_discretionaries} This function will remove the discretionaries in the list and inject the replace field when set. @@ -2021,7 +2151,9 @@ field when set. head, count = node.flatten_discretionaries( n) \stopfunctioncall -\subsection{\type {node.family_font}} +\subsection{\type {family_font}} + +\libindex {family_font} When you pass a proper family identifier the next helper will return the font currently associated with it. You can normally also access the font with the @@ -2033,37 +2165,37 @@ noads. node.family_font( fam) \stopfunctioncall -\subsection{\type {node.set_synctex_fields} and \type {node.get_synctex_fields}} - -You can set and query the synctex fields, a file number aka tag and a line -number, for a glue, kern, hlist, vlist, rule and math nodes as well as glyph -nodes (although this last one is not used in native synctex). - -\startfunctioncall -node.set_synctex_fields( f, l) - f, l = - node.get_synctex_fields( n) -\stopfunctioncall - -Of course you need to know what you're doing as no checking on sane values takes -place. Also, the synctex interpreter used in editors is rather peculiar and has -some assumptions (heuristics). +\stopsection -\section{Two access models} +\startsection[title={Two access models}][library=node] \topicindex{nodes+direct} \topicindex{direct nodes} +\libindex {todirect} +\libindex {tonode} +\libindex {tostring} + Deep down in \TEX\ a node has a number which is a numeric entry in a memory table. In fact, this model, where \TEX\ manages memory is real fast and one of the reasons why plugging in callbacks that operate on nodes is quite fast too. Each node gets a number that is in fact an index in the memory table and that -number often is reported when you print node related information. +number often is reported when you print node related information. You go from +userdata nodes and there numeric references and back with: + +\startfunctioncall + d = node.todirect( n)) + n = node.tonode( d)) +\stopfunctioncall + +The userdata model is rather robust as it is a virtual interface with some +additional checking while the more direct access which uses the node numbers +directly. However, even with userdata you can get into troubles when you free +nodes that are no longer allocated or mess up lists. if you apply \type +{tostring} to a node you see its internal (direct) number and id. -There are two access models, a robust one using a so called user data object that -provides a virtual interface to the internal nodes, and a more direct access which -uses the node numbers directly. The first model provides key based access while -the second always accesses fields via functions: +The first model provides key based access while the second always accesses fields +via functions: \starttyping nodeobject.char @@ -2166,133 +2298,146 @@ consistency. You can of course always define additional accessors using \type \def\yes{$+$} \def\nop{$-$} +\def\supported#1#2#3% + {\NC \type{#1} + \NC \ifx#2\yes\libidx{node} {#1}\fi #2 + \NC \ifx#3\yes\libidx{node.direct}{#1}\fi #3 \NC + \NR} + \starttabulate[|l|c|c|] -\DB function \BC node \BC direct \NC \NR +\DB function \BC node \BC direct \NC \NR \TB -%NC \type {do_ligature_n} \NC \yes \NC \yes \NC \NR % was never documented and experimental -\NC \type {check_discretionaries}\NC \yes \NC \yes \NC \NR -\NC \type {copy_list} \NC \yes \NC \yes \NC \NR -\NC \type {copy} \NC \yes \NC \yes \NC \NR -\NC \type {count} \NC \yes \NC \yes \NC \NR -\NC \type {current_attr} \NC \yes \NC \yes \NC \NR -\NC \type {dimensions} \NC \yes \NC \yes \NC \NR -\NC \type {effective_glue} \NC \yes \NC \yes \NC \NR -\NC \type {end_of_math} \NC \yes \NC \yes \NC \NR -\NC \type {family_font} \NC \yes \NC \nop \NC \NR -\NC \type {fields} \NC \yes \NC \nop \NC \NR -\NC \type {find_attribute} \NC \yes \NC \yes \NC \NR -\NC \type {first_glyph} \NC \yes \NC \yes \NC \NR -\NC \type {flush_list} \NC \yes \NC \yes \NC \NR -\NC \type {flush_node} \NC \yes \NC \yes \NC \NR -\NC \type {free} \NC \yes \NC \yes \NC \NR -\NC \type {get_attribute} \NC \yes \NC \yes \NC \NR -\NC \type {getattributelist} \NC \nop \NC \yes \NC \NR -\NC \type {getboth} \NC \yes \NC \yes \NC \NR -\NC \type {getbox} \NC \nop \NC \yes \NC \NR -\NC \type {getchar} \NC \yes \NC \yes \NC \NR -\NC \type {getcomponents} \NC \nop \NC \yes \NC \NR -\NC \type {getdepth} \NC \nop \NC \yes \NC \NR -\NC \type {getdir} \NC \nop \NC \yes \NC \NR -\NC \type {getdisc} \NC \yes \NC \yes \NC \NR -\NC \type {getfam} \NC \nop \NC \yes \NC \NR -\NC \type {getfield} \NC \yes \NC \yes \NC \NR -\NC \type {getfont} \NC \yes \NC \yes \NC \NR -\NC \type {getglue} \NC \yes \NC \yes \NC \NR -\NC \type {getheight} \NC \nop \NC \yes \NC \NR -\NC \type {getid} \NC \yes \NC \yes \NC \NR -\NC \type {getkern} \NC \nop \NC \yes \NC \NR -\NC \type {getlang} \NC \nop \NC \yes \NC \NR -\NC \type {getleader} \NC \yes \NC \yes \NC \NR -\NC \type {getlist} \NC \yes \NC \yes \NC \NR -\NC \type {getnext} \NC \yes \NC \yes \NC \NR -\NC \type {getnucleus} \NC \nop \NC \yes \NC \NR -\NC \type {getoffsets} \NC \nop \NC \yes \NC \NR -\NC \type {getpenalty} \NC \nop \NC \yes \NC \NR -\NC \type {getprev} \NC \yes \NC \yes \NC \NR -\NC \type {getproperty} \NC \yes \NC \yes \NC \NR -\NC \type {getshift} \NC \nop \NC \yes \NC \NR -\NC \type {getwidth} \NC \nop \NC \yes \NC \NR -\NC \type {getwhd} \NC \nop \NC \yes \NC \NR -\NC \type {getsub} \NC \nop \NC \yes \NC \NR -\NC \type {getsubtype} \NC \yes \NC \yes \NC \NR -\NC \type {getsup} \NC \nop \NC \yes \NC \NR -\NC \type {has_attribute} \NC \yes \NC \yes \NC \NR -\NC \type {has_field} \NC \yes \NC \yes \NC \NR -\NC \type {has_glyph} \NC \yes \NC \yes \NC \NR -\NC \type {hpack} \NC \yes \NC \yes \NC \NR -\NC \type {id} \NC \yes \NC \nop \NC \NR -\NC \type {insert_after} \NC \yes \NC \yes \NC \NR -\NC \type {insert_before} \NC \yes \NC \yes \NC \NR -\NC \type {is_char} \NC \yes \NC \yes \NC \NR -\NC \type {is_direct} \NC \nop \NC \yes \NC \NR -\NC \type {is_glue_zero} \NC \yes \NC \yes \NC \NR -\NC \type {is_glyph} \NC \yes \NC \yes \NC \NR -\NC \type {is_node} \NC \yes \NC \yes \NC \NR -\NC \type {kerning} \NC \yes \NC \yes \NC \NR -\NC \type {last_node} \NC \yes \NC \yes \NC \NR -\NC \type {length} \NC \yes \NC \yes \NC \NR -\NC \type {ligaturing} \NC \yes \NC \yes \NC \NR -\NC \type {mlist_to_hlist} \NC \yes \NC \nop \NC \NR -\NC \type {new} \NC \yes \NC \yes \NC \NR -\NC \type {next} \NC \yes \NC \nop \NC \NR -\NC \type {prev} \NC \yes \NC \nop \NC \NR -\NC \type {protect_glyphs} \NC \yes \NC \yes \NC \NR -\NC \type {protect_glyph} \NC \yes \NC \yes \NC \NR -\NC \type {protrusion_skippable} \NC \yes \NC \yes \NC \NR -\NC \type {rangedimensions} \NC \yes \NC \yes \NC \NR -\NC \type {remove} \NC \yes \NC \yes \NC \NR -\NC \type {set_attribute} \NC \nop \NC \yes \NC \NR -\NC \type {setattributelist} \NC \nop \NC \yes \NC \NR -\NC \type {setboth} \NC \nop \NC \yes \NC \NR -\NC \type {setbox} \NC \nop \NC \yes \NC \NR -\NC \type {setchar} \NC \nop \NC \yes \NC \NR -\NC \type {setcomponents} \NC \nop \NC \yes \NC \NR -\NC \type {setdepth} \NC \nop \NC \yes \NC \NR -\NC \type {setdir} \NC \nop \NC \yes \NC \NR -\NC \type {setdisc} \NC \nop \NC \yes \NC \NR -\NC \type {setfield} \NC \yes \NC \yes \NC \NR -\NC \type {setfont} \NC \nop \NC \yes \NC \NR -\NC \type {setglue} \NC \yes \NC \yes \NC \NR -\NC \type {setheight} \NC \nop \NC \yes \NC \NR -\NC \type {setid} \NC \nop \NC \yes \NC \NR -\NC \type {setkern} \NC \nop \NC \yes \NC \NR -\NC \type {setlang} \NC \nop \NC \yes \NC \NR -\NC \type {setleader} \NC \nop \NC \yes \NC \NR -\NC \type {setlist} \NC \nop \NC \yes \NC \NR -\NC \type {setnext} \NC \nop \NC \yes \NC \NR -\NC \type {setnucleus} \NC \nop \NC \yes \NC \NR -\NC \type {setoffsets} \NC \nop \NC \yes \NC \NR -\NC \type {setpenalty} \NC \nop \NC \yes \NC \NR -\NC \type {setprev} \NC \nop \NC \yes \NC \NR -\NC \type {setproperty} \NC \nop \NC \yes \NC \NR -\NC \type {setshift} \NC \nop \NC \yes \NC \NR -\NC \type {setwidth} \NC \nop \NC \yes \NC \NR -\NC \type {setwhd} \NC \nop \NC \yes \NC \NR -\NC \type {setsub} \NC \nop \NC \yes \NC \NR -\NC \type {setsubtype} \NC \nop \NC \yes \NC \NR -\NC \type {setsup} \NC \nop \NC \yes \NC \NR -\NC \type {slide} \NC \yes \NC \yes \NC \NR -\NC \type {subtypes} \NC \yes \NC \nop \NC \NR -\NC \type {subtype} \NC \yes \NC \nop \NC \NR -\NC \type {tail} \NC \yes \NC \yes \NC \NR -\NC \type {todirect} \NC \yes \NC \yes \NC \NR -\NC \type {tonode} \NC \yes \NC \yes \NC \NR -\NC \type {tostring} \NC \yes \NC \yes \NC \NR -\NC \type {traverse_char} \NC \yes \NC \yes \NC \NR -\NC \type {traverse_id} \NC \yes \NC \yes \NC \NR -\NC \type {traverse} \NC \yes \NC \yes \NC \NR -\NC \type {types} \NC \yes \NC \nop \NC \NR -\NC \type {type} \NC \yes \NC \nop \NC \NR -\NC \type {unprotect_glyphs} \NC \yes \NC \yes \NC \NR -\NC \type {unset_attribute} \NC \yes \NC \yes \NC \NR -\NC \type {usedlist} \NC \yes \NC \yes \NC \NR -\NC \type {uses_font} \NC \yes \NC \yes \NC \NR -\NC \type {vpack} \NC \yes \NC \yes \NC \NR -\NC \type {whatsitsubtypes} \NC \yes \NC \nop \NC \NR -\NC \type {whatsits} \NC \yes \NC \nop \NC \NR -\NC \type {write} \NC \yes \NC \yes \NC \NR -\NC \type {set_synctex_fields} \NC \yes \NC \yes \NC \NR -\NC \type {get_synctex_fields} \NC \yes \NC \yes \NC \NR +\supported {check_discretionaries} \yes \yes +\supported {check_discretionary} \yes \yes +\supported {copy_list} \yes \yes +\supported {copy} \yes \yes +\supported {count} \yes \yes +\supported {current_attr} \yes \yes +\supported {dimensions} \yes \yes +\supported {effective_glue} \yes \yes +\supported {end_of_math} \yes \yes +\supported {family_font} \yes \nop +\supported {fields} \yes \nop +\supported {find_attribute} \yes \yes +\supported {first_glyph} \yes \yes +\supported {flatten_discretionaries} \yes \yes +\supported {flush_list} \yes \yes +\supported {flush_node} \yes \yes +\supported {free} \yes \yes +\supported {get_attribute} \yes \yes +\supported {get_synctex_fields} \nop \yes +\supported {getattributelist} \nop \yes +\supported {getboth} \yes \yes +\supported {getbox} \nop \yes +\supported {getchar} \yes \yes +\supported {getcomponents} \nop \yes +\supported {getdepth} \nop \yes +\supported {getdirection} \nop \yes +\supported {getdir} \nop \yes +\supported {getdisc} \yes \yes +\supported {getfam} \nop \yes +\supported {getfield} \yes \yes +\supported {getfont} \yes \yes +\supported {getglue} \yes \yes +\supported {getheight} \nop \yes +\supported {getid} \yes \yes +\supported {getkern} \nop \yes +\supported {getlang} \nop \yes +\supported {getleader} \yes \yes +\supported {getlist} \yes \yes +\supported {getnext} \yes \yes +\supported {getnucleus} \nop \yes +\supported {getoffsets} \nop \yes +\supported {getpenalty} \nop \yes +\supported {getprev} \yes \yes +\supported {getproperty} \yes \yes +\supported {getshift} \nop \yes +\supported {getsubtype} \yes \yes +\supported {getsub} \nop \yes +\supported {getsup} \nop \yes +\supported {getwhd} \yes \yes +\supported {getwidth} \nop \yes +\supported {has_attribute} \yes \yes +\supported {has_field} \yes \yes +\supported {has_glyph} \yes \yes +\supported {hpack} \yes \yes +\supported {id} \yes \nop +\supported {insert_after} \yes \yes +\supported {insert_before} \yes \yes +\supported {is_char} \yes \yes +\supported {is_direct} \nop \yes +\supported {is_glyph} \yes \yes +\supported {is_node} \yes \yes +\supported {is_zero_glue} \yes \yes +\supported {kerning} \yes \yes +\supported {last_node} \yes \yes +\supported {length} \yes \yes +\supported {ligaturing} \yes \yes +\supported {mlist_to_hlist} \yes \nop +\supported {new} \yes \yes +\supported {next} \yes \nop +\supported {prepend_prevdepth} \nop \yes +\supported {prev} \yes \nop +\supported {protect_glyphs} \yes \yes +\supported {protect_glyph} \yes \yes +\supported {protrusion_skippable} \yes \yes +\supported {rangedimensions} \yes \yes +\supported {remove} \yes \yes +\supported {set_attribute} \yes \yes +\supported {set_synctex_fields} \nop \yes +\supported {setattributelist} \nop \yes +\supported {setboth} \nop \yes +\supported {setbox} \nop \yes +\supported {setchar} \nop \yes +\supported {setcomponents} \nop \yes +\supported {setdepth} \nop \yes +\supported {setdirection} \nop \yes +\supported {setdir} \nop \yes +\supported {setdisc} \nop \yes +\supported {setfam} \nop \yes +\supported {setfield} \yes \yes +\supported {setfont} \nop \yes +\supported {setglue} \yes \yes +\supported {setheight} \nop \yes +\supported {setkern} \nop \yes +\supported {setlang} \nop \yes +\supported {setleader} \nop \yes +\supported {setlink} \nop \yes +\supported {setlist} \nop \yes +\supported {setnext} \nop \yes +\supported {setnucleus} \nop \yes +\supported {setoffsets} \nop \yes +\supported {setpenalty} \nop \yes +\supported {setprev} \nop \yes +\supported {setproperty} \yes \yes +\supported {setshift} \nop \yes +\supported {setsplit} \nop \yes +\supported {setsubtype} \nop \yes +\supported {setsub} \nop \yes +\supported {setsup} \nop \yes +\supported {setwhd} \nop \yes +\supported {setwidth} \nop \yes +\supported {slide} \yes \yes +\supported {subtypes} \yes \nop +\supported {subtype} \yes \nop +\supported {tail} \yes \yes +\supported {todirect} \yes \yes +\supported {tonode} \yes \yes +\supported {tostring} \yes \yes +\supported {traverse_char} \yes \yes +\supported {traverse_glyph} \yes \yes +\supported {traverse_id} \yes \yes +\supported {traverse} \yes \yes +\supported {types} \yes \nop +\supported {type} \yes \nop +\supported {unprotect_glyphs} \yes \yes +\supported {unprotect_glyph} \yes \yes +\supported {unset_attribute} \yes \yes +\supported {usedlist} \yes \yes +\supported {uses_font} \yes \yes +\supported {vpack} \yes \yes +\supported {whatsits} \yes \nop +\supported {write} \yes \yes \LL \stoptabulate @@ -2310,6 +2455,196 @@ true for the \type {width}, \type {height} and \type {depth} of glue nodes. Thes actually access the spec node properties, and here we can set as well as get the values. +In some places \LUATEX\ can do a bit of extra checking for valid node lists and +you can enable that with: + +\startfunctioncall +node.fix_node_lists( b) +\stopfunctioncall + +You can set and query the synctex fields, a file number aka tag and a line +number, for a glue, kern, hlist, vlist, rule and math nodes as well as glyph +nodes (although this last one is not used in native synctex). + +\startfunctioncall +node.set_synctex_fields( f, l) + f, l = + node.get_synctex_fields( n) +\stopfunctioncall + +Of course you need to know what you're doing as no checking on sane values takes +place. Also, the synctex interpreter used in editors is rather peculiar and has +some assumptions (heuristics). + +\stopsection + +\startsection[title={Properties}][library=node] + +\topicindex {nodes+properties} +\topicindex {properties} + +\libindex{flush_properties_table} +\libindex{get_properties_table} +\libindex{set_properties_mode} + +Attributes are a convenient way to relate extra information to a node. You can +assign them at the \TEX\ end as well as at the \LUA\ end and and consult them at +the \LUA\ end. One big advantage is that they obey grouping. They are linked +lists and normally checking for them is pretty efficient, even if you use a lot +of them. A macro package has to provide some way to manage these attributes at the +\TEX\ end because otherwise clashes in their usage can occur. + +Each node also can have a properties table and you can assign values to this +table using the \type {setproperty} function and get properties using the \type +{getproperty} function. Managing properties is way more demanding than managing +attributes. + +Take the following example: + +\starttyping +\directlua { + local n = node.new("glyph") + + node.setproperty(n,"foo") + print(node.getproperty(n)) + + node.setproperty(n,"bar") + print(node.getproperty(n)) + + node.free(n) +} +\stoptyping + +This will print \type {foo} and \type {bar} which in itself is not that useful +when multiple mechanisms want to use this feature. A variant is: + +\starttyping +\directlua { + local n = node.new("glyph") + + node.setproperty(n,{ one = "foo", two = "bar" }) + print(node.getproperty(n).one) + print(node.getproperty(n).two) + + node.free(n) +} +\stoptyping + +This time we store two properties with the node. It really makes sense to have a +table as property because that way we can store more. But in order for that to +work well you need to do it this way: + +\starttyping +\directlua { + local n = node.new("glyph") + + local t = node.getproperty(n) + + if not t then + t = { } + node.setproperty(n,t) + end + t.one = "foo" + t.two = "bar" + + print(node.getproperty(n).one) + print(node.getproperty(n).two) + + node.free(n) +} +\stoptyping + +Here our own properties will not overwrite other users properties unless of +course they use the same keys. So, eventually you will end up with something: + +\starttyping +\directlua { + local n = node.new("glyph") + + local t = node.getproperty(n) + + if not t then + t = { } + node.setproperty(n,t) + end + t.myself = { one = "foo", two = "bar" } + + print(node.getproperty(n).myself.one) + print(node.getproperty(n).myself.two) + + node.free(n) +} +\stoptyping + +This assumes that only you use \type {myself} as subtable. The possibilities are +endless but care is needed. For instance, the generic font handler that ships +with \CONTEXT\ uses the \type {injections} subtable and you should not mess with +that one! + +There are a few helper functions that you normally should not touch as user: \typ +{flush_properties_table} will wipe the table (normally a bad idea), \typ +{get_properties_table} and will give the table that stores properties (using +direct entries) and you can best not mess too much with that one either because +\LUATEX\ itself will make sure that entries related to nodes will get wiped when +nodes get freed, so that the \LUA\ garbage collector can do its job. In fact, the +main reason why we have this mechanism is that it saves the user (or macro +package) some work. One can easily write a property mechanism in \LUA\ where +after a shipout properties gets cleaned up but it's not entirely trivial to make +sure that with each freed node also its properties get freed, due to the fact +that there can be nodes left over for a next page. And having a callback bound to +the node deallocator would add way to much overhead. + +Managing properties in the node (de)allocator functions is disabled by default +and is enabled by: + +\starttyping +node.set_properties_mode(true) +\stoptyping + +When we copy a node list that has a table as property, there are several possibilities: we do the same as +a new node, we copy the entry to the table in properties (a reference), we do +a deep copy of a table in the properties, we create a new table and give it +the original one as a metatable. After some experiments (that also included +timing) with these scenarios we decided that a deep copy made no sense, nor +did nilling. In the end both the shallow copy and the metatable variant were +both ok, although the second one is slower. The most important aspect to keep +in mind is that references to other nodes in properties no longer can be +valid for that copy. We could use two tables (one unique and one shared) or +metatables but that only complicates matters. + +When defining a new node, we could already allocate a table but it is rather easy +to do that at the lua end e.g.\ using a metatable \type {__index} method. That +way it is under macro package control. When deleting a node, we could keep the +slot (e.g. setting it to false) but it could make memory consumption raise +unneeded when we have temporary large node lists and after that only small lists. +Both are not done. + +So in the end this is what happens now: when a node is copied, and it has a table +as property, the new node will share that table. If the second argument of \typ +{set_properties_mode} is \type {true} then a metatable approach is chosen: the +copy gets its own table with the original table as metatable. If you use the +generic font loader the mode is enabled that way. + +A few more xperiments were done. For instance: copy attributes to the properties +so that we have fast access at the \LUA\ end. In the end the overhead is not +compensated by speed and convenience, in fact, attributes are not that slow when +it comes to accessing them. So this was rejected. + +Another experiment concerned a bitset in the node but again the gain compared to +attributes was neglectable and given the small amount of available bits it also +demands a pretty strong agreement over what bit represents what, and this is +unlikely to succeed in the \TEX\ community. It doesn't pay off. + +Just in case one wonders why properties make sense: it is not so much speed that +we gain, but more convenience: storing all kind of (temporary) data in attributes +is no fun and this mechanism makes sure that properties are cleaned up when a +node is freed. Also, the advantage of a more or less global properties table is +that we stay at the \LUA\ end. An alternative is to store a reference in the node +itself but that is complicated by the fact that the register has some limitations +(no numeric keys) and we also don't want to mess with it too much. + +\stopsection + \stopchapter \stopcomponent diff --git a/doc/context/sources/general/manuals/luatex/luatex-registers.tex b/doc/context/sources/general/manuals/luatex/luatex-registers.tex index c9d1352f6..36b1ec051 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-registers.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-registers.tex @@ -35,4 +35,13 @@ \stopchapter +\startchapter[title=Libraries] + + This register contains the functions available in libraries. Not all functions + are documented, for instance because they can be experimental or obsolete. + + \placeregister[libraryindex] + +\stopchapter + \stopcomponent diff --git a/doc/context/sources/general/manuals/luatex/luatex-style.tex b/doc/context/sources/general/manuals/luatex/luatex-style.tex index 45129f845..8fd0a6aa5 100644 --- a/doc/context/sources/general/manuals/luatex/luatex-style.tex +++ b/doc/context/sources/general/manuals/luatex/luatex-style.tex @@ -405,6 +405,7 @@ \defineregister[primitiveindex] \defineregister[callbackindex] \defineregister[nodeindex] +\defineregister[libraryindex] \unexpanded\def\lpr#1{\doifmode{*bodypart}{\primitiveindex[#1]{\bf\tex {#1}}}\tex {#1}} \unexpanded\def\prm#1{\doifmode{*bodypart}{\primitiveindex[#1]{\tex {#1}}}\tex {#1}} @@ -416,4 +417,26 @@ \hyphenation{sub-nodes} +\def\currentlibraryindex{\namedstructureuservariable{section}{library}} + +\setupregister + [libraryindex] + [indicator=no,before=] + +\setupregister + [libraryindex] + [1] + [textstyle=\ttbf] + +\setupregister + [libraryindex] + [2] + [textstyle=\tttf] + +\unexpanded\def\lib #1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex+#1}}\type{\currentlibraryindex.#1}}} +\unexpanded\def\libindex#1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex+#1}}}} +\unexpanded\def\libidx#1#2{\doifmode{*bodypart}{\expanded{\libraryindex{#1+#2}}\type{#1.#2}}} + +% \setstructurepageregister[][keys:1=,entries:1=] + \stopenvironment diff --git a/metapost/context/base/mpiv/mp-node.mpiv b/metapost/context/base/mpiv/mp-node.mpiv index 79391220b..b7abcd5e5 100644 --- a/metapost/context/base/mpiv/mp-node.mpiv +++ b/metapost/context/base/mpiv/mp-node.mpiv @@ -51,7 +51,7 @@ clearnodepath ; vardef makenode@#(text t) = for a = t : - if (path a) or (unknown a) : + if (path a) or (unknown a) or ((string a) and (length(a) = 0)) : mfun_makenode@#(t,) else : mfun_makenode@#(nodepath, t,) @@ -62,7 +62,7 @@ enddef ; vardef node@#(text t) = for a = t : - if (path a) or (unknown a) : + if (path a) or (unknown a) or ((string a) and (length(a) = 0)) : mfun_node@#(t,) else : mfun_node@#(nodepath, t,) @@ -73,7 +73,7 @@ enddef ; vardef nodeboundingpoint@#(text t) = for a = t : - if (path a) or (unknown a) : + if (path a) or (unknown a) or ((string a) and (length(a) = 0)) : mfun_nodeboundingpoint@#(t) else : mfun_nodeboundingpoint@#(nodepath,a) diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index a04c2385f..848071dcb 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{2018.07.02 14:39} +\newcontextversion{2018.07.05 23:06} %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 cae8a99d9..acdcfcaa2 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{2018.07.02 14:39} +\edef\contextversion{2018.07.05 23:06} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index 4d5ab2af1..a21064a23 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -1027,6 +1027,7 @@ \setinterfaceconstant{otherstext}{otherstext} \setinterfaceconstant{outermargin}{buitenmarge} \setinterfaceconstant{overprint}{overprint} +\setinterfaceconstant{ownerpassword}{ownerpassword} \setinterfaceconstant{ownnumber}{eigennummer} \setinterfaceconstant{page}{pagina} \setinterfaceconstant{pageboundaries}{paginaovergangen} @@ -1268,6 +1269,7 @@ \setinterfaceconstant{up}{up} \setinterfaceconstant{urlalternative}{urlvariant} \setinterfaceconstant{urlspace}{urlspatie} +\setinterfaceconstant{userpassword}{userpassword} \setinterfaceconstant{validate}{valideer} \setinterfaceconstant{values}{waarden} \setinterfaceconstant{vcommand}{vcommando} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index 0e12a29ed..5493c3308 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -1027,6 +1027,7 @@ \setinterfaceconstant{otherstext}{otherstext} \setinterfaceconstant{outermargin}{حاشیه‌خارجی} \setinterfaceconstant{overprint}{overprint} +\setinterfaceconstant{ownerpassword}{ownerpassword} \setinterfaceconstant{ownnumber}{شماره‌خود} \setinterfaceconstant{page}{صفحه} \setinterfaceconstant{pageboundaries}{مرزهای‌صفحه} @@ -1268,6 +1269,7 @@ \setinterfaceconstant{up}{up} \setinterfaceconstant{urlalternative}{urlalternative} \setinterfaceconstant{urlspace}{urlspace} +\setinterfaceconstant{userpassword}{userpassword} \setinterfaceconstant{validate}{تاییداعتبار} \setinterfaceconstant{values}{values} \setinterfaceconstant{vcommand}{vcommand} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 2a3392732..f15615b0e 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.07.02 14:39} +\newcontextversion{2018.07.05 23:06} %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 dc3bc164b..d50b42f29 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.07.02 14:39} +\edef\contextversion{2018.07.05 23:06} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-ocl.lua b/tex/context/base/mkiv/font-ocl.lua index fcafe99ed..fc9953d88 100644 --- a/tex/context/base/mkiv/font-ocl.lua +++ b/tex/context/base/mkiv/font-ocl.lua @@ -341,15 +341,15 @@ do else - -- todo: bypass backend and directly inject xforms - local openpdf = pdfe.new + ----- prefix = "data:application/pdf," function otf.storepdfdata(pdf) local done = hashed[pdf] if not done then nofstreams = nofstreams + 1 - local n = openpdf(pdf,#pdf,f_name(nofstreams)) + local f = f_name(nofstreams) + local n = openpdf(pdf,#pdf,f) done = f_used(n) hashed[pdf] = done end @@ -436,6 +436,8 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = sbix|svg dy = 0 end if data then + -- We can delay storage by a lua function in commands: but then we need to + -- be able to provide our own mem stream name (so that we can reserve it). local setcode, name, nilcode = storepdfdata(data) if name then local bt = unicode and getactualtext(unicode) @@ -459,8 +461,8 @@ local function pdftovirtual(tfmdata,pdfshapes,kind) -- kind = sbix|svg end local otfsvg = otf.svg or { } -otf.svg = otfsvg -otf.svgenabled = true +otf.svg = otfsvg +otf.svgenabled = true do diff --git a/tex/context/base/mkiv/font-shp.lua b/tex/context/base/mkiv/font-shp.lua index 79c015a63..6e1caf57f 100644 --- a/tex/context/base/mkiv/font-shp.lua +++ b/tex/context/base/mkiv/font-shp.lua @@ -290,7 +290,7 @@ otf.loadoutlinedata = loadoutlinedata -- not public otf.loadstreamdata = loadstreamdata -- not public otf.loadshapes = loadshapes --- experimental code, for me only ... unsupported +-- experimental code, for me only ... unsupported (todo: use %N) local f_c = string.formatters["%F %F %F %F %F %F c"] local f_l = string.formatters["%F %F l"] diff --git a/tex/context/base/mkiv/font-ttf.lua b/tex/context/base/mkiv/font-ttf.lua index 1365b250d..bdfa3e859 100644 --- a/tex/context/base/mkiv/font-ttf.lua +++ b/tex/context/base/mkiv/font-ttf.lua @@ -710,7 +710,10 @@ local function readglyph(f,nofcontours) -- read deltas here, saves space local points = { } local instructions = { } local flags = { } - local contours = readintegertable(f,nofcontours,short) + local contours = { } -- readintegertable(f,nofcontours,short) + for i=1,nofcontours do + contours[i] = readshort(f) + 1 + end local nofpoints = contours[nofcontours] local nofinstructions = readushort(f) skipbytes(f,nofinstructions) diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index d3550a756..3b5aeda84 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -776,7 +776,7 @@ end -- lpdf.deferredobject = pdfdeferredobject -- lpdf.referenceobject = pdfreferenceobject -local pagereference = pdf.pageref -- tex.pdfpageref is obsolete +local pagereference = pdf.getpageref or pdf.pageref -- tex.pdfpageref is obsolete local nofpages = 0 function lpdf.pagereference(n) diff --git a/tex/context/base/mkiv/lpdf-tag.lua b/tex/context/base/mkiv/lpdf-tag.lua index cc3823fef..3eb9363e5 100644 --- a/tex/context/base/mkiv/lpdf-tag.lua +++ b/tex/context/base/mkiv/lpdf-tag.lua @@ -331,10 +331,11 @@ function nodeinjections.addtags(head) for n, id in nextnode, head do if id == glyph_code then -- maybe also disc - local at = getattr(n,a_tagged) - if not at then - range = nil - elseif last ~= at then + local at = getattr(n,a_tagged) or false -- false: pagebody or so, so artifact + -- if not at then + -- range = nil + -- elseif ... + if last ~= at then range = { at, "glyph", n, n, list } -- attr id start stop list ranges[#ranges+1] = range last = at @@ -344,12 +345,12 @@ function nodeinjections.addtags(head) elseif id == hlist_code or id == vlist_code then local at = getattr(n,a_image) if at then - local at = getattr(n,a_tagged) - if not at then - range = nil - else + local at = getattr(n,a_tagged) or false -- false: pagebody or so, so artifact + -- if not at then + -- range = nil + -- else ranges[#ranges+1] = { at, "image", n, n, list } -- attr id start stop list - end + -- end last = nil else collectranges(getlist(n),n) @@ -379,83 +380,93 @@ function nodeinjections.addtags(head) local top = nil local noftop = 0 + + local function inject(start,stop,list,literal) + local prev = getprev(start) + if prev then + setlink(prev,literal) + end + setlink(literal,start) + if list and getlist(list) == start then + setlist(list,literal) + end + local literal = copy_node(EMCliteral) + -- use insert instead: + local next = getnext(stop) + if next then + setlink(literal,next) + end + setlink(stop,literal) + end + for i=1,#ranges do - local range = ranges[i] - local attr = range[1] - local id = range[2] - local start = range[3] - local stop = range[4] - local list = range[5] - local specification = taglist[attr] - local taglist = specification.taglist - local noftags = #taglist - local common = 0 - if top then - for i=1,noftags >= noftop and noftop or noftags do - if top[i] == taglist[i] then - common = i - else - break + + local range = ranges[i] + local attr = range[1] + local id = range[2] + local start = range[3] + local stop = range[4] + local list = range[5] + + if attr then + + local specification = taglist[attr] + local taglist = specification.taglist + local noftags = #taglist + local common = 0 + local literal = nil + local ignore = false + + if top then + for i=1,noftags >= noftop and noftop or noftags do + if top[i] == taglist[i] then + common = i + else + break + end end end - end - local prev = common > 0 and elements[taglist[common]] or root - local ignore = false - local literal = nil - - for j=common+1,noftags do - local tag = taglist[j] - local prv = elements[tag] or makeelement(tag,prev) - if prv == false then - -- ignore this one - prev = false - ignore = true - break - elseif prv == true then - -- skip this one - else - prev = prv + local prev = common > 0 and elements[taglist[common]] or root + + for j=common+1,noftags do + local tag = taglist[j] + local prv = elements[tag] or makeelement(tag,prev) + if prv == false then + -- ignore this one + prev = false + ignore = true + break + elseif prv == true then + -- skip this one + else + prev = prv + end end - end - if prev then - literal = pdfpageliteral(makecontent(prev,id,specification)) - elseif ignore then - literal = pdfpageliteral(makeignore(specification)) - end - if literal then - local prev = getprev(start) if prev then - setlink(prev,literal) - end - setlink(literal,start) - if list and getlist(list) == start then - setlist(list,literal) + literal = pdfpageliteral(makecontent(prev,id,specification)) + elseif ignore then + literal = pdfpageliteral(makeignore(specification)) + else + -- maybe also ignore or maybe better: comment or so end - local literal = copy_node(EMCliteral) - -- use insert instead: - local next = getnext(stop) - if next then - setlink(literal,next) + + if literal then + inject(start,stop,list,literal) end - setlink(stop,literal) + + top = taglist + noftop = noftags + + else + + local literal = pdfpageliteral(makeignore(specification)) + + inject(start,stop,list,literal) + end - -- if literal then - -- if list and getlist(list) == start then - -- setlink(literal,start) - -- setlist(list,literal) - -- else - -- setlink(getprev(start),literal,start) - -- end - -- -- use insert instead: - -- local literal = copy_node(EMCliteral) - -- setlink(stop,literal,getnext(stop)) - -- end - - top = taglist - noftop = noftags end finishpage() diff --git a/tex/context/base/mkiv/lpdf-wid.lua b/tex/context/base/mkiv/lpdf-wid.lua index 03febbf01..8647a7b39 100644 --- a/tex/context/base/mkiv/lpdf-wid.lua +++ b/tex/context/base/mkiv/lpdf-wid.lua @@ -11,11 +11,11 @@ if not modules then modules = { } end modules ['lpdf-wid'] = { -- had renditions but they turned out to be unreliable from the start and look -- obsolete too or at least they are bound to the (obsolete) flash technology for -- rendering. They were already complex constructs. Now we have rich media which --- instead of providing a robust future proof framework fo rgeneral media types +-- instead of providing a robust future proof framework for general media types -- again seems to depend on viewers built in (yes, also kind of obsolete) flash -- technology, and we cannot expect this non-open technology to show up in open -- browsers. So, in the end we can best just use links to external resources to be --- future proof. Just look at the viewer prferences pane to see how fragile support +-- future proof. Just look at the viewer preferences pane to see how fragile support -- is. Interestingly u3d support is kind of built in, while e.g. mp4 support relies -- on wrapping in swf. We used to stay ahead of the pack with support of the fancy -- pdf features but it backfires and is not worth the trouble. And yes, for control diff --git a/tex/context/base/mkiv/meta-nod.lua b/tex/context/base/mkiv/meta-nod.lua new file mode 100644 index 000000000..119c276e2 --- /dev/null +++ b/tex/context/base/mkiv/meta-nod.lua @@ -0,0 +1,29 @@ +if not modules then modules = { } end modules ['meta-nod'] = { + version = 1.001, + comment = "companion to meta-nod.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local references = { } + +metapost.nodes = { + + initialize = function() + references = { } + end, + + register = function(s,r) + references[s] = r + end, + + resolve = function(s) + context(references[s] or ("\\number " .. (tonumber(s) or 0))) + end, + + reset = function() + references = { } + end, + +} diff --git a/tex/context/base/mkiv/meta-nod.mkiv b/tex/context/base/mkiv/meta-nod.mkiv index 5c7b3d503..bf36e315c 100644 --- a/tex/context/base/mkiv/meta-nod.mkiv +++ b/tex/context/base/mkiv/meta-nod.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\registerctxluafile{meta-nod}{} + \unprotect \defineMPinstance @@ -105,6 +107,9 @@ \let\stopnodes\relax +%D Hm, we started out simple but it now quickly becomes the usual mess of +%D \TEX, \METAPOST\ and \LUA. Hard to understand. + \unexpanded\def\startnodes {\dosingleempty\meta_nodes_start} @@ -120,6 +125,7 @@ #2\removeunwantedspaces % for alan, will be commented: \writestatus{metanodes}{\detokenize\expandafter{\the\t_meta_nodes}}% + \ctxlua{metapost.nodes.initialize()}% \startMPcode mfun_node_init(% \the\dimexpr\metanodesparameter\c!dx\relax,% @@ -129,11 +135,9 @@ \the\t_meta_nodes ; mfun_node_flush ; \stopMPcode + \ctxlua{metapost.nodes.reset()}% \egroup} -% \unexpanded\def\grph_nodes_node[#1,#2]#3% -% {\etoksapp\t_meta_nodes{mfun_node_make(\number#1,\number#2,"\metanodesparameter\c!command{#3}");}} - \unexpanded\def\grph_nodes_node {\dodoubleempty\grph_nodes_node_two} @@ -145,10 +149,16 @@ \ifsecondargument \setupcurrentmetanodes[#3]% \fi - \edef\p_label{#4}% + \edef\p_label {#4}% + \edef\p_reference{\metanodesparameter\c!reference}% + \ifx\p_reference\empty\else + \ctxlua{metapost.nodes.register("\p_reference",\number#1)}% + \fi \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{% mfun_node_make(\number#1,\number#2% - \ifx\p_label\empty \else + \ifx\p_label\empty + ,""% + \else ,"\metanodesparameter\c!command{\p_label}"% \fi );% @@ -199,8 +209,11 @@ \space mfun_nodes_fromto\begincsname\??metanodesposition\metanodesparameter\c!position\endcsname(% \metanodesparameter\c!offset,% - \number#1,\number#2% - \ifx\p_label\empty \else + % \number#1,\number#2% + \ctxlua{metapost.nodes.resolve("#1")},\ctxlua{metapost.nodes.resolve("#2")}% + \ifx\p_label\empty + ,""% + \else ,"\ifx\p_command\empty\p_label\else\p_command{\p_label}\fi"% \fi )% diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 5681edfd1..237efe901 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -37,6 +37,7 @@ local stoptiming = statistics.stoptiming local trace_runs = false trackers.register("metapost.runs", function(v) trace_runs = v end) local trace_textexts = false trackers.register("metapost.textexts", function(v) trace_textexts = v end) local trace_scripts = false trackers.register("metapost.scripts", function(v) trace_scripts = v end) +local trace_btexetex = false trackers.register("metapost.btexetex", function(v) trace_btexetex = v end) local report_metapost = logs.reporter("metapost") local report_textexts = logs.reporter("metapost","textexts") diff --git a/tex/context/base/mkiv/mlib-run.lua b/tex/context/base/mkiv/mlib-run.lua index 6aa433627..7b10f6273 100644 --- a/tex/context/base/mkiv/mlib-run.lua +++ b/tex/context/base/mkiv/mlib-run.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['mlib-run'] = { license = "see context related readme files", } +-- todo mpx :execute -> mlib.execute(mpx,) + -- cmyk -> done, native -- spot -> done, but needs reworking (simpler) -- multitone -> @@ -38,7 +40,6 @@ local P = lpeg.P local trace_graphics = false trackers.register("metapost.graphics", function(v) trace_graphics = v end) local trace_tracingall = false trackers.register("metapost.tracingall", function(v) trace_tracingall = v end) -local trace_btexetex = false trackers.register("metapost.btexetex", function(v) trace_btexetex = v end) local report_metapost = logs.reporter("metapost") local texerrormessage = logs.texerrormessage diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 95eed4d50..2cb1e6fa2 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 757509873..5081fb91f 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-tag.mkiv b/tex/context/base/mkiv/strc-tag.mkiv index 4f7449b93..6d05135b5 100644 --- a/tex/context/base/mkiv/strc-tag.mkiv +++ b/tex/context/base/mkiv/strc-tag.mkiv @@ -492,13 +492,16 @@ % }% % \to \everyenableelements -\appendtoks - \dostartignoretagging -\to \everybeforepagebody +% This doesn't work well either, so instead we handle the ornaments in the +% tagging in a different way (see attr -> false code). -\appendtoks - \dostopignoretagging -\to \everyafterpagebody +% \appendtoks +% \dostartignoretagging +% \to \everybeforepagebody +% +% \appendtoks +% \dostopignoretagging +% \to \everyafterpagebody % \doifelseinelement{structure:section} {yes} {no} % \doifelseinelement{structure:chapter} {yes} {no} diff --git a/tex/context/base/mkiv/typo-dir.mkiv b/tex/context/base/mkiv/typo-dir.mkiv index d7d3b178d..dd0a03329 100644 --- a/tex/context/base/mkiv/typo-dir.mkiv +++ b/tex/context/base/mkiv/typo-dir.mkiv @@ -28,7 +28,7 @@ \registerctxluafile{typo-duc}{} } -\definesystemattribute[directions][public] +\definesystemattribute[directions][public,global] \installcorenamespace{directions} \installcorenamespace{directionsbidimode} diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml index 463f1f84d..bfb8b1809 100644 --- a/tex/context/interface/mkii/keys-nl.xml +++ b/tex/context/interface/mkii/keys-nl.xml @@ -1033,6 +1033,7 @@ + @@ -1274,6 +1275,7 @@ + diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 880a07489..620b85ea4 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -1033,6 +1033,7 @@ + @@ -1274,6 +1275,7 @@ + diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 1710e750c..c0cfd1900 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 a7f406e90..ee2bcebcf 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ -- cgit v1.2.3