summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/luatex/luatex-modifications.tex
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-13 18:16:16 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-13 18:16:16 +0200
commit9db0c39e07509226287ef0075dfda8d2386416ed (patch)
tree6daf69803dd8c7cc1eadfeebe65653de6c4a23c1 /doc/context/sources/general/manuals/luatex/luatex-modifications.tex
parent5baf21b979124606cb6503be4e16d403f233ecd4 (diff)
downloadcontext-9db0c39e07509226287ef0075dfda8d2386416ed.tar.gz
2016-06-13 17:04:00
Diffstat (limited to 'doc/context/sources/general/manuals/luatex/luatex-modifications.tex')
-rw-r--r--doc/context/sources/general/manuals/luatex/luatex-modifications.tex139
1 files changed, 137 insertions, 2 deletions
diff --git a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex
index e59e09e1e..7105330a2 100644
--- a/doc/context/sources/general/manuals/luatex/luatex-modifications.tex
+++ b/doc/context/sources/general/manuals/luatex/luatex-modifications.tex
@@ -524,7 +524,9 @@ different:
\stopsubsection
-\startsubsection[reference=backendprimitives,title=The backend primitives \type {\pdf*}]
+\stopsection
+
+\startsection[reference=backendprimitives,title=The backend primitives \type {\pdf*}]
In a previous section we mentioned that some \PDFTEX\ primitives were removed and
others promoted to core \LUATEX\ primitives. That is only part of the story. In
@@ -775,7 +777,140 @@ normally generated by the engine:
So, you even need to include the brackets!
-\stopsubsection
+\stopsection
+
+\startsection[title=Directions]
+
+The directional model in \LUATEX\ is inherited from \OMEGA|/|\ALEPH\ but we tried
+to improve it a bit. At some point we played with recovery of modes but that was
+disabled later on when we found that it interfered with nested directions. That
+itself had as side effect that the node list was no longer balanced with respect
+to directional nodes which in turn can give side effects when a series of dir
+changes happens without grouping.
+
+The current (0.97 onward) approach is that we again make the list balanced but
+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 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 dir injection.
+
+This is what happens:
+
+\starttyping
+\textdir TRT nur {\textdir TLT run \textdir TRT NUR} nur
+\stoptyping
+
+This becomes stepwise:
+
+\startnarrower
+\starttyping
+injected: [+TRT]nur {[+TLT]run [+TRT]NUR} nur
+balanced: [+TRT]nur {[+TLT]run [-TLT][+TRT]NUR[-TRT]} nur[-TRT]
+result : run {RUNrun } run
+\stoptyping
+\stopnarrower
+
+And this:
+
+\starttyping
+\textdir TRT nur {nur \textdir TLT run \textdir TRT NUR} nur
+\stoptyping
+
+becomes:
+
+\startnarrower
+\starttyping
+injected: [+TRT]nur {nur [+TLT]run [+TRT]NUR} nur
+balanced: [+TRT]nur {nur [+TLT]run [-TLT][+TRT]NUR[-TRT]} nur[-TRT]
+result : run {run RUNrun } run
+\stoptyping
+\stopnarrower
+
+Now, in the following examples watch where we put the braces:
+
+\startbuffer
+\textdir TRT nur {{\textdir TLT run} {\textdir TRT NUR}} nur
+\stopbuffer
+
+\typebuffer
+
+This becomes:
+
+\startnarrower
+\getbuffer
+\stopnarrower
+
+Compare this to:
+
+\startbuffer
+\textdir TRT nur {{\textdir TLT run }{\textdir TRT NUR}} nur
+\stopbuffer
+
+\typebuffer
+
+Which renders as:
+
+\startnarrower
+\getbuffer
+\stopnarrower
+
+So how do we deal with the next?
+
+\startbuffer
+\def\ltr{\textdir TLT\relax}
+\def\rtl{\textdir TRT\relax}
+
+run {\rtl nur {\ltr run \rtl NUR \ltr run \rtl NUR} nur}
+run {\ltr run {\rtl nur \ltr RUN \rtl nur \ltr RUN} run}
+\stopbuffer
+
+\typebuffer
+
+It gets typeset as:
+
+\startnarrower
+\startlines
+\getbuffer
+\stoplines
+\stopnarrower
+
+We could define the two helpers to look back, pick up a skip, remove it and
+inject it after the dir node. But that way we loose the subtype information that
+for some applications can be handy to be kept as|-|is. This is why we now have a
+variant of \type {\textdir} which injects the balanced node before the skip.
+Instead of the previous definition we can use:
+
+\startbuffer[def]
+\def\ltr{\linedir TLT\relax}
+\def\rtl{\linedir TRT\relax}
+\stopbuffer
+
+\typebuffer[def]
+
+and this time:
+
+\startbuffer[txt]
+run {\rtl nur {\ltr run \rtl NUR \ltr run \rtl NUR} nur}
+run {\ltr run {\rtl nur \ltr RUN \rtl nur \ltr RUN} run}
+\stopbuffer
+
+\typebuffer[txt]
+
+comes out as a properly spaced:
+
+\startnarrower
+\startlines
+\getbuffer[def,txt]
+\stoplines
+\stopnarrower
+
+Anything more complex that this, like combination of skips and penalties, or
+kerns, should be handled in the input or macro package because there is no way we
+can predict the expected behaviour. In fact, the \type {\linedir} is just a
+convenience extra which could also have been implemented using node list parsing.
\stopsection